本文介绍了不接收有关用户配置文件更新的通知的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要获取有关Azure B2C中用户配置文件更新的通知,并使用Azure Functions HttpTrigger处理它们.

I need to get notifications about user profiles updates in Azure B2C and handle them using Azure Functions HttpTrigger.

我遵循了这两个指南:

  1. https://docs.microsoft.com/zh-cn/graph/tutorials/change-notifications

https://github.com/microsoftgraph/webjobs-webhooks-sample

这两者的结果都是成功订阅了用户更新,并成功处理了带有验证码的初始请求,但是当我在应用程序中编辑用户个人资料时,没有任何关于更新的通知.

Result of both of them is successful subscription to user updates and successfully processed initial request with verification code, but when I am editing user profile in my app I don't get any notifications about updates.

订阅注册:

var subscription = new Subscription
            {
                ChangeType = "updated,deleted",
                NotificationUrl = "https://<ngrok_url>/persons",
                Resource = "Users",
                ExpirationDateTime = DateTime.UtcNow.AddMinutes(30),
                ClientState = "SecretClientState"
            };

更改的函数处理程序:

[FunctionName(nameof(GetChangesAsync))]
        public async Task<IActionResult> GetChangesAsync(
            [HttpTrigger(AuthorizationLevel.Function, "POST", Route = "persons")]
            HttpRequest request,
            ILogger logger)
        {
            if (request.Query.ContainsKey("validationToken"))
            {
                string validationToken = request.Query["validationToken"];

                return new OkObjectResult(validationToken);
            }

            using (var reader = new StreamReader(request.Body))
            {
                var content = await reader.ReadToEndAsync();

                var notifications = JsonConvert.DeserializeObject<Notifications>(content);

                if (notifications != null)
                {
                    foreach (var notification in notifications.Items)
                    {
                        logger.LogInformation(
                            $"Received notification: '{notification.Resource}', {notification.ResourceData?.Id}");
                    }
                }
            }

            return new OkResult();
        }

我希望每次在Azure B2C中编辑用户配置文件时都会收到通知->用户.

I expected to get notification every time when I'm editing user profile in Azure B2C -> Users.

也如上面的GitHub页面所述,我可以附加我的订阅ID:

Also as mentioned in GitHub page above I can attach my subscription id:

5ea124b2-6a48-4c09-baf0-0ed5f1c98ff0

5ea124b2-6a48-4c09-baf0-0ed5f1c98ff0

及其创建时间:

03.08.2019 11:16:03 +00:00

03.08.2019 11:16:03 +00:00

推荐答案

恐怕当前不支持使用Microsoft Graph API管理Azure AD B2C.请参阅此博客的底部: Microsoft Graph或Azure AD Graph .

I'm afraid that Managing Azure AD B2C using Microsoft Graph API is not supported currently. See the bottom of this blog: Microsoft Graph or Azure AD Graph.

当我们配置此样本时: https://github.com/microsoftgraph/webjobs-webhooks-sample 在Visual Studio中,我们需要在App.config文件中设置客户端ID和密码.但是在Azure B2C应用程序中,我们找不到设置Microsoft Graph权限的地方.您可以从 Azure门户网站-> Azure AD B2C -> 应用程序-> 选择应用程序->查看详细信息 API访问权限.

When we configure this sample: https://github.com/microsoftgraph/webjobs-webhooks-sample in Visual Studio, we need to set the Client ID and Secret in App.config file. But in Azure B2C app, we cannot find a place to set Microsoft Graph permission. You can see details from Azure Portal -> Azure AD B2C -> Applications -> Select your application -> API access.

这就是为什么在Azure B2C->用户中编辑用户配置文件时无法收到通知的原因.

So that's why you can't get notification while editing user profile in Azure B2C -> Users.

这篇关于不接收有关用户配置文件更新的通知的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-19 02:38