You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+15-15Lines changed: 15 additions & 15 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,14 +32,14 @@ This sample ASP.NET Core web application shows how to subscribe for change notif
32
32
33
33
This sample uses:
34
34
35
-
-[Microsoft Authentication Library for .NET](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet) (MSAL.NET) to obtain an access token
35
+
-[Microsoft Authentication Library for .NET](https://github.com/AzureAD/microsoft-authentication-library-for-dotnet) (MSAL.NET) to obtain an access token.
36
36
- The [Microsoft Graph Client Library for .NET](https://github.com/microsoftgraph/msgraph-sdk-dotnet) (SDK) to call Microsoft Graph.
37
-
- The [Microsoft.Identity.Web](https://github.com/AzureAD/microsoft-identity-web) library to abstract some of the token acquisition complexities.
37
+
- The [Microsoft.Identity.Web](https://github.com/AzureAD/microsoft-identity-web) library to abstract token acquisition.
38
38
39
39
This sample supports user-delegated authentication and uses:
40
40
41
-
- OpenID Connect for sign in / sign out using the Microsoft identity platform for developers
42
-
- The [auth code flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow)
41
+
- OpenID Connect for sign in / sign out using the Microsoft identity platform for developers.
42
+
- The [auth code flow](https://docs.microsoft.com/azure/active-directory/develop/v2-oauth2-auth-code-flow).
43
43
44
44
This sample supports app-only authentication and uses:
45
45
@@ -53,7 +53,8 @@ The following are common tasks that an application performs with webhooks subscr
53
53
- Use the access token to [create a subscription](https://docs.microsoft.com/graph/api/subscription-post-subscriptions) to a resource.
54
54
- Send back a validation token to confirm the notification URL.
55
55
- Listen for notifications from Microsoft Graph and respond with a 202 status code.
56
-
- Request more information about changed resources using data in the notification or decrypts the resource data provided with the notification if any has been provided.
56
+
- Request more information about changed resources using data in the notification if no data is provided with the notification.
57
+
- Decrypts the resource data provided with the notification if any has been provided with the notification.
57
58
58
59
## Using the Microsoft Graph Webhooks Sample
59
60
@@ -63,7 +64,7 @@ The screenshot below shows the app's start page.
63
64
64
65
After the app creates a subscription, Microsoft Graph sends a notification to the registered endpoint when events happen for the subscribed resource. The app then reacts to the event.
65
66
66
-
This sample app subscribes to any resource configured in `appsettings.json` in `SubscriptionSettings:Resource` (default is `me/messages`) for any change configured in `SubscriptionSettings:ChangeType` (default `created,updated`). When notified that of any notification, the app then updates a page with information about the resource.
67
+
This sample app subscribes to any resource configured in `appsettings.json` in `SubscriptionSettings:Resource` (default is `me/messages`) for any change configured in `SubscriptionSettings:ChangeType` (default `created,updated`). When receiving any notification, the app then updates a page with information about the resource.
67
68
68
69
This project uses git submodules. After cloning the repository, make sure you execute the following commands:
69
70
@@ -81,7 +82,7 @@ To use the Microsoft Graph Webhook Sample for ASP.NET Core, you need the followi
81
82
- A [work, school or personal account](https://dev.office.com/devprogram). A tenant administrator account is required to grant application permissions.
82
83
- The application ID and key from the application that you [register on the Azure Portal](#register-the-app).
83
84
- A public HTTPS endpoint to receive and send HTTP requests. You can host this on Microsoft Azure or another service, or you can [use ngrok](#ngrok) or a similar tool while testing.
84
-
- If you are also testing change notifications with resource data (preview), you also need a Microsoft Azure subscription to create an Azure KeyVault. If you do not have a Microsoft Azure subscription, you can [start a free trial](https://azure.microsoft.com/free/)
85
+
- If you are also testing change notifications with resource data (preview), you also need a Microsoft Azure subscription to create an Azure KeyVault. If you do not have a Microsoft Azure subscription, you can [start a free trial](https://azure.microsoft.com/free/).
85
86
86
87
### Create your app
87
88
@@ -99,14 +100,14 @@ To use the Microsoft Graph Webhook Sample for ASP.NET Core, you need the followi
99
100
100
101

101
102
1. When the **Register an application page** appears, enter your app's registration information:
102
-
1. In the **Name** section, enter a meaningful name that will be displayed to users of the app. For example: `MyWebApp`
103
+
1. In the **Name** section, enter a meaningful name that will be displayed to users of the app. For example: `MyWebApp`.
103
104
1. In the **Supported account types** section, select **Accounts in any organizational directory (Any Azure AD directory) and personal Microsoft accounts (e.g. Skype, Xbox)**.
104
105
> You can leave the redirect URI empty, you'll add these from the **Authentication** tab later after the app has been successfully created.
105
106
106
107

107
108
1. Select **Register** to create the app.
108
109
1. On the app's **Overview** page, find the **Application (client) ID** value and record it for later. You'll need this value to configure the Visual Studio configuration file for this project.
109
-
1. In the list of pages for the app, select **Authentication**. (this step is only required if you are using a user-delegated authentication context)
110
+
1. In the list of pages for the app, select **Authentication**. (this step is only required if you are using a user-delegated authentication context):
110
111
1. In the **Redirect URIs** section, select **Web** in the combo-box and enter the following redirect URIs:
@@ -134,7 +135,7 @@ To use the Microsoft Graph Webhook Sample for ASP.NET Core, you need the followi
134
135
135
136
### Setting up Azure Key Vault
136
137
137
-
*Note: you are only required to follow these steps if the resource you are subscribing to supports including resouces data in notifications and if you set `includeResourceData` to `true` in the configuration. In any other case, you can skip these steps. Refer to [the documentation](https://docs.microsoft.com/graph/api/resources/webhooks?view=graph-rest-beta) for a complete list of resources that support or not including resources data.*
138
+
*Note: you are only required to follow these steps if the resource you are subscribing to supports including resources data in notifications and if you set `includeResourceData` to `true` in the configuration. In any other case, you can skip these steps. Refer to [the documentation](https://docs.microsoft.com/graph/api/resources/webhooks?view=graph-rest-beta) for a complete list of resources that support or not including resources data.*
138
139
139
140
Follow the [documented steps](./KEYVAULT.md) to configure your Azure KeyVault in order to add support for change notifications with resource data (preview).
140
141
@@ -170,15 +171,17 @@ Keep the console open while testing. If you close it, the tunnel also closes and
170
171
171
172
## Configure and run the sample
172
173
174
+
> Note: To avoid errors while installing packages from dependencies, make sure the local path where you placed the solution is not too long/deep. Moving the solution closer to the root drive resolves this issue.
175
+
173
176
1. Expose a public HTTPS notification endpoint. It can run on a service such as Microsoft Azure, or you can create a proxy web server by [using ngrok](#ngrok) or a similar tool.
174
177
175
178
1. Open the **GraphWebhooks-Core.sln** sample file in Visual Studio.
176
179
177
180
1. In Solution Explorer, open the **appsettings.json** file in the root directory of the project.
178
181
179
182
- Settings under **SubscriptionSettings**:
180
-
-**ChangeType**: CSV; possible values created, updated, deleted
181
-
-**Resource**: resource to create subscription for (e.g. teams/allMessages)
183
+
-**ChangeType**: CSV; possible values created, updated, deleted.
184
+
-**Resource**: resource to create subscription for (e.g. teams/allMessages).
182
185
-**IncludeResourceData**: whether the notifications should include resource data. `true` or `false`
183
186
-**NotificationUrl**: The HTTPS Notification URL that will receive subscription validation callbacks and notification events from Graph, replace *ENTER_YOUR_URL* with the HTTPS URL. Keep the */notification/listen* portion. If you're using ngrok, use the HTTPS URL that you copied eg `https://2885f9c5.ngrok.io/notification/listen`.
184
187
-**Scope**: The permission to use to create the subscription, eg `Mail.Read` or `ChannelMessage.Read.All`.
@@ -216,8 +219,6 @@ Keep the console open while testing. If you close it, the tunnel also closes and
216
219
217
220
1. Make sure that the ngrok console is still running, then press F5 to build and run the solution in debug mode.
218
221
219
-
>If you get errors while installing packages, make sure the local path where you placed the solution is not too long/deep. Moving the solution closer to the root drive resolves this issue.
220
-
221
222
### Use the app to create a subscription
222
223
223
224
#### Sign-in and grant permissions
@@ -303,7 +304,6 @@ You can suggest changes for Microsoft Graph on [UserVoice](https://microsoftgrap
303
304
304
305
## Additional resources
305
306
306
-
- [Microsoft Graph Webhooks sample for ASP.NET 4.6](https://github.com/microsoftgraph/aspnet-webhooks-rest-sample)
307
307
- [Microsoft Graph Webhooks sample for Node.js](https://github.com/microsoftgraph/nodejs-webhooks-rest-sample) (Delegated permissions)
308
308
- [Working with Webhooks in Microsoft Graph](https://docs.microsoft.com/graph/api/resources/webhooks)
0 commit comments