Skip to content

Latest commit

 

History

History
27 lines (23 loc) · 1.1 KB

create-ms-graph-api-subscription-javascript-snippet.md

File metadata and controls

27 lines (23 loc) · 1.1 KB
title description ms.devlang ms.topic ms.date
JavaScript - Create Graph API subscription to subscribe to Microsoft Graph API events using Event Grid partner topics as a notification destination.
This article provides a sample JavaScript code that shows how to create a Microsoft Graph API subscription to receive events via Azure Event Grid partner topics.
javascript
sample
12/08/2023
const options = {
	authProvider,
};

const client = Client.init(options);

const subscription = {
   changeType: 'updated,deleted,created',
   notificationUrl: 'EventGrid:?azuresubscriptionid=8A8A8A8A-4B4B-4C4C-4D4D-12E12E12E12E&resourcegroup=yourResourceGroup&partnertopic=yourPartnerTopic&location=theNameOfAzureRegionFortheTopic',
   lifecycleNotificationUrl: 'EventGrid:?azuresubscriptionid=8A8A8A8A-4B4B-4C4C-4D4D-12E12E12E12E&resourcegroup=yourResourceGroup&partnertopic=yourPartnerTopic&location=theNameOfAzureRegionFortheTopic',
   resource: 'users',
   expirationDateTime: '2024-03-31T18:23:45.9356913Z',
   clientState: 'secretClientValue'
};

await client.api('/subscriptions')
	.post(subscription);