AnalyzingTasks
AnalyzingTasks

Reputation: 57

Azure EventGrid Partner Topic Filter with CloudEventSchema

How can I only capture the change of a user email with the Partner Topic for Microsoft Graph API?

This article states that you can use custom data.key:

"For events in Cloud Events schema, use the following values for the key: eventid, source, eventtype, eventtypeversion, or event data (like data.key1)".

So do I add the key as data.state and value as *? I tried it and nothing gets returned. I want to capture the oldValue and newValue, is this something the partner topic cannot do?

enter image description here

Upvotes: 0

Views: 343

Answers (1)

vijaya
vijaya

Reputation: 1731

AFAIK and according to this MS document You can build a Graph API subscription with the following properties to leverage the Partner Topic for Microsoft Graph API to capture the change of a user email.

  • Below is the sample request provided in the mentioned MS document.

    POST to https://graph.microsoft.com/beta/subscriptions
    
      x-ms-enable-features: EventGrid
    
      Body:
      {
          "changeType": "Updated,Deleted,Created",
          "notificationUrl": "EventGrid:?azuresubscriptionid=8A8A8A8A-4B4B-4C4C-4D4D-12E12E12E12E&resourcegroup=yourResourceGroup&partnertopic=youPartnerTopic&location=theNameOfAzureRegionFortheTopic",
          "resource": "users",
          "expirationDateTime": "2022-04-30T00:00:00Z",
          "clientState": "mysecret"
      }
    
  • Note: Change the above values based on your requirement for example change type is Updated and Data.key1 should be set to UserPrincipalName, data.key2 to OldValue, and data.key3 to NewValue in the notificationUrl. The user's UserPrincipalName, the OldValue, and the NewValue are all provided in the event data when the user's email is modified.

  • Another option is to use an advanced filter with the "Data" column and the "CloudEvent" schema version as per this similar SO question.

Upvotes: 0

Related Questions