Skip to content

Commit 225b485

Browse files
committed
Update exposed-apis-create-app-webapp.md
1 parent 52fdfd3 commit 225b485

File tree

1 file changed

+35
-22
lines changed

1 file changed

+35
-22
lines changed

defender-endpoint/api/exposed-apis-create-app-webapp.md

Lines changed: 35 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,12 @@ In general, you'll need to take the following steps to use the APIs:
5151

5252
This article explains how to create a Microsoft Entra application, get an access token to Microsoft Defender for Endpoint, and validate the token.
5353

54+
> [!IMPORTANT]
55+
> Microsoft recommends that you use roles with the fewest permissions. This helps improve security for your organization. Global Administrator is a highly privileged role that should be limited to emergency scenarios when you can't use an existing role.
56+
5457
## Create an app
5558

56-
1. Log on to [Azure](https://portal.azure.com) with a user that has the **Global Administrator** role.
59+
1. Sign in to the [Azure portal](https://portal.azure.com) with a user that has the Global Administrator role.
5760

5861
2. Navigate to **Microsoft Entra ID** \> **App registrations** \> **New registration**.
5962

@@ -64,55 +67,55 @@ This article explains how to create a Microsoft Entra application, get an access
6467
4. To enable your app to access Defender for Endpoint and assign it **'Read all alerts'** permission, on your application page, select **API Permissions** \> **Add permission** \> **APIs my organization uses** >, type **WindowsDefenderATP**, and then select **WindowsDefenderATP**.
6568

6669
> [!NOTE]
67-
> *WindowsDefenderATP* does not appear in the original list. Start writing its name in the text box to see it appear.
70+
> `WindowsDefenderATP` does not appear in the original list. Start writing its name in the text box to see it appear.
6871
6972
:::image type="content" source="../media/add-permission.png" alt-text="The API permissions pane" lightbox="../media/add-permission.png":::
7073

7174
Select **Application permissions** \> **Alert.Read.All**, and then select **Add permissions**.
7275

7376
:::image type="content" source="../media/application-permissions.png" alt-text="The application permission information pane" lightbox="../media/application-permissions.png":::
7477

75-
You need to select the relevant permissions. 'Read All Alerts' is only an example. For example:
78+
5. Select appropriate permissions. `Read All Alerts` is only an example. Here are some examples:
7679

77-
- To [run advanced queries](run-advanced-query-api.md), select the 'Run advanced queries' permission.
78-
- To [isolate a device](isolate-machine.md), select the 'Isolate machine' permission.
79-
- To determine which permission you need, look at the **Permissions** section in the API you are interested to call.
80+
- To [run advanced queries](run-advanced-query-api.md), select the `Run advanced queries` permission.
81+
- To [isolate a device](isolate-machine.md), select the `Isolate machine` permission.
82+
- To determine which permission you need, look at the **Permissions** section in the API you are interested to call.
8083

8184
5. Select **Grant consent**.
8285

83-
> [!NOTE]
84-
> Every time you add a permission, you must select **Grant consent** for the new permission to take effect.
86+
> [!NOTE]
87+
> Every time you add a permission, you must select **Grant consent** for the new permission to take effect.
8588
86-
:::image type="content" source="../media/grant-consent.png" alt-text="The grant permissions page" lightbox="../media/grant-consent.png":::
89+
:::image type="content" source="../media/grant-consent.png" alt-text="The grant permissions page" lightbox="../media/grant-consent.png":::
8790

8891
6. To add a secret to the application, select **Certificates & secrets**, add a description to the secret, and then select **Add**.
8992

90-
> [!NOTE]
91-
> After you select **Add**, select **copy the generated secret value**. You won't be able to retrieve this value after you leave.
93+
> [!NOTE]
94+
> After you select **Add**, select **copy the generated secret value**. You won't be able to retrieve this value after you leave.
9295
93-
:::image type="content" source="../media/webapp-create-key2.png" alt-text="The create application option" lightbox="../media/webapp-create-key2.png":::
96+
:::image type="content" source="../media/webapp-create-key2.png" alt-text="The create application option" lightbox="../media/webapp-create-key2.png":::
9497

9598
7. Write down your application ID and your tenant ID. On your application page, go to **Overview** and copy the following.
9699

97100
:::image type="content" source="../media/app-and-tenant-ids.png" alt-text="The created app and tenant IDs" lightbox="../media/app-and-tenant-ids.png":::
98101

99-
8. **For Microsoft Defender for Endpoint Partners only**. Set your app to be multi-tenanted (available in all tenants after consent). This is **required** for third-party apps (for example, if you create an app that is intended to run in multiple customers' tenant). This is **not required** if you create a service that you want to run in your tenant only (for example, if you create an application for your own usage that will only interact with your own data). To set your app to be multi-tenanted:
102+
8. **For Microsoft Defender for Endpoint Partners only**. Set your app to be multi-tenanted (available in all tenants after consent). This is **required** for third-party apps (for example, if you create an app that is intended to run in multiple customers' tenant). This is **not required** if you create a service that you want to run in your tenant only (for example, if you create an application for your own usage that will only interact with your own data). To set your app to be multi-tenanted, follow these steps:
100103

101-
- Go to **Authentication**, and add `https://portal.azure.com` as the **Redirect URI**.
104+
1. Go to **Authentication**, and add `https://portal.azure.com` as the **Redirect URI**.
102105

103-
- On the bottom of the page, under **Supported account types**, select the **Accounts in any organizational directory** application consent for your multi-tenant app.
106+
2. On the bottom of the page, under **Supported account types**, select the **Accounts in any organizational directory** application consent for your multi-tenant app.
104107

105-
You need your application to be approved in each tenant where you intend to use it. This is because your application interacts Defender for Endpoint on behalf of your customer.
108+
You need your application to be approved in each tenant where you intend to use it. This is because your application interacts Defender for Endpoint on behalf of your customer.
106109

107-
You (or your customer if you are writing a third-party app) need to select the consent link and approve your app. The consent should be done with a user who has administrative privileges in Active Directory.
110+
You (or your customer if you are writing a third-party app) need to select the consent link and approve your app. The consent should be done with a user who has administrative privileges in Active Directory.
108111

109-
The consent link is formed as follows:
112+
The consent link is formed as follows:
110113

111-
```https
112-
https://login.microsoftonline.com/common/oauth2/authorize?prompt=consent&client_id=00000000-0000-0000-0000-000000000000&response_type=code&sso_reload=true
113-
```
114+
```https
115+
https://login.microsoftonline.com/common/oauth2/authorize?prompt=consent&client_id=00000000-0000-0000-0000-000000000000&response_type=code&sso_reload=true
116+
```
114117
115-
Where 00000000-0000-0000-0000-000000000000 is replaced with your application ID.
118+
Where `00000000-0000-0000-0000-000000000000` is replaced with your application ID.
116119
117120
118121
**Done!** You have successfully registered an application! See examples below for token acquisition and validation.
@@ -152,7 +155,9 @@ The following code was tested with NuGet Microsoft.Identity.Client 3.19.8.
152155
> The [Microsoft.IdentityModel.Clients.ActiveDirectory](https://www.nuget.org/packages/Microsoft.IdentityModel.Clients.ActiveDirectory) NuGet package and Azure AD Authentication Library (ADAL) have been deprecated. No new features have been added since June 30, 2020. We strongly encourage you to upgrade, see the [migration guide](/azure/active-directory/develop/msal-migration) for more details.
153156
154157
1. Create a new console application.
158+
155159
1. Install NuGet [Microsoft.Identity.Client](https://www.nuget.org/packages/Microsoft.Identity.Client/).
160+
156161
1. Add the following:
157162

158163
```csharp
@@ -176,6 +181,7 @@ The following code was tested with NuGet Microsoft.Identity.Client 3.19.8.
176181

177182
string token = authResult.AccessToken;
178183
```
184+
179185
### Use Python
180186

181187
See [Get token using Python](run-advanced-query-sample-python.md#get-token).
@@ -186,8 +192,11 @@ See [Get token using Python](run-advanced-query-sample-python.md#get-token).
186192
> The following procedure assumes that Curl for Windows is already installed on your computer.
187193

188194
1. Open a command prompt, and set CLIENT_ID to your Azure application ID.
195+
189196
1. Set CLIENT_SECRET to your Azure application secret.
197+
190198
1. Set TENANT_ID to the Azure tenant ID of the customer that wants to use your app to access Defender for Endpoint.
199+
191200
1. Run the following command:
192201

193202
```console
@@ -215,7 +224,9 @@ Ensure that you got the correct token:
215224
## Use the token to access Microsoft Defender for Endpoint API
216225

217226
1. Choose the API you want to use. For more information, see [Supported Defender for Endpoint APIs](exposed-apis-list.md).
227+
218228
1. Set the authorization header in the http request you send to "Bearer {token}" (Bearer is the authorization scheme).
229+
219230
1. The expiration time of the token is one hour. You can send more than one request with the same token.
220231

221232
The following is an example of sending a request to get a list of alerts **using C#**:
@@ -233,6 +244,8 @@ var response = httpClient.SendAsync(request).GetAwaiter().GetResult();
233244
```
234245

235246
## See also
247+
236248
- [Supported Microsoft Defender for Endpoint APIs](exposed-apis-list.md)
237249
- [Access Microsoft Defender for Endpoint on behalf of a user](exposed-apis-create-app-nativeapp.md)
250+
238251
[!INCLUDE [Microsoft Defender for Endpoint Tech Community](../../includes/defender-mde-techcommunity.md)]

0 commit comments

Comments
 (0)