Do not receive notifications about user profile updates

你说的曾经没有我的故事 提交于 2021-02-08 04:18:05

问题


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

I followed this two guides:

  1. https://docs.microsoft.com/en-us/graph/tutorials/change-notifications

  2. 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.

Subscription registration:

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

Function handler of changes:

[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();
        }

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

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

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

and time it was created:

03.08.2019 11:16:03 +00:00


回答1:


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.

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.

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



来源:https://stackoverflow.com/questions/57337828/do-not-receive-notifications-about-user-profile-updates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!