0

First, I subscribed to receive notifications when users are updated, and I received notifications when I updated any user. However, my problem is that when I change the ChangeType to "created" I expected to receive notifications when a new user is created, but unfortunately, I didn't receive any notifications.

Am I wrong in my expectation? If my expectation is wrong, is there another way to achieve this?

My subscription settings below.

    var sub = new Microsoft.Graph.Models.Subscription();
    sub.ChangeType = "created";
    sub.NotificationUrl = "https://*********.eu.ngrok.io" + "/api/notifications";
    sub.Resource = "/users";
    sub.LifecycleNotificationUrl = "https://*******.eu.ngrok.io" + "/api/notifications";
    sub.ExpirationDateTime = DateTime.UtcNow.AddMinutes(10);
    sub.ClientState = "SecretClientState";

1 Answers1

0

Am I wrong in my expectation? If my expectation is wrong, is there another way to achieve this?

You can create an alert using Log Analytics workspace when Azure Ad user is created.

I have followed below steps to create an alert when the Azure AD user is created.

  1. I have created Log Analytics Workspace as below.

Go to Azure Portal > Log Analytics workspace > create

enter image description here

  1. Once create a Log Analytics workspace, add Active Directory Logs to LAW as below.

Azure Active directory > Diagnostic settings > Add diagnostic setting.

enter image description here

  1. Go to Log Analytics workspace and ran the below query to check AD Activity logs as below.

Query to check when the Azure AD account is created.

AuditLogs
| where Category contains "UserManagement"
| where OperationName contains "Add user"
| project TimeGenerated, OperationName,Category,InitiatedBy,Result

Output:

enter image description here

  1. Create an alert as below.

enter image description here

  1. Create an Action Group as below to send an email.

enter image description here

  1. If Azure AD account is created, you will get an alert as below.

enter image description here

Email Notification

enter image description here

Venkat V
  • 2,197
  • 1
  • 1
  • 10
  • Thank you for comment VenkatV, But ı need to do this using a webhook in the API. This because when I recieve a notification for a newly created user, I need to take action on it using Microsoft Graph API – Baha Bayar Mar 24 '23 at 09:21
  • Did you ever find a solution to use a webhook? I need to do something similar. – dot Aug 02 '23 at 18:43