Skip to content

Commit 4668602

Browse files
authored
Merge pull request #214379 from spelluru/egridwebhook1012
added some detail
2 parents 2831108 + 98477ee commit 4668602

File tree

1 file changed

+50
-34
lines changed

1 file changed

+50
-34
lines changed

articles/event-grid/secure-webhook-delivery.md

Lines changed: 50 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -2,33 +2,47 @@
22
title: Secure WebHook delivery with Azure AD in Azure Event Grid
33
description: Describes how to deliver events to HTTPS endpoints protected by Azure Active Directory using Azure Event Grid
44
ms.topic: how-to
5-
ms.date: 01/20/2022
5+
ms.date: 10/12/2022
66
---
77

88
# Deliver events to Azure Active Directory protected endpoints
9-
This article describes how to use Azure Active Directory (Azure AD) to secure the connection between your **event subscription** and your **webhook endpoint**. For an overview of Azure AD applications and service principals, see [Microsoft identity platform (v2.0) overview](../active-directory/develop/v2-overview.md).
10-
11-
This article uses the Azure portal for demonstration, however the feature can also be enabled using CLI, PowerShell, or the SDKs.
9+
This article describes how to use Azure Active Directory (Azure AD) to secure the connection between your **event subscription** and your **webhook endpoint**. It uses the Azure portal for demonstration, however the feature can also be enabled using CLI, PowerShell, or the SDKs.
1210

1311
> [!IMPORTANT]
14-
> Additional access check has been introduced as part of create or update of event subscription on March 30, 2021 to address a security vulnerability. The subscriber client's service principal needs to be either an owner or have a role assigned on the destination application service principal. Please reconfigure your Azure AD Application following the new instructions below.
12+
> Additional access check has been introduced as part of create or update of event subscription on March 30, 2021 to address a security vulnerability. The subscriber client's service principal needs to be either an owner or have a role assigned on the destination application service principal. Reconfigure your Azure AD Application following the new instructions below.For an overview of Azure AD applications and service principals, see [Microsoft identity platform (v2.0) overview](../active-directory/develop/v2-overview.md).
13+
14+
## Scenarios
15+
This article explains how to implement the following two scenarios in detail:
16+
17+
- [Delivering events to a webhook that is in the same Azure AD tenant as the event subscription](#deliver-events-to-a-webhook-in-the-same-azure-ad-tenant). You can use either an Azure AD user or an Azure AD application as the event subscription writer in this scenario.
18+
- [Delivering events to a webhook that is in a different Azure AD tenant from the event subscription](#deliver-events-to-a-webhook-in-a-different-azure-ad-tenant). You can only use an Azure AD application as an event subscription writer in this scenario.
19+
20+
In the first scenario, you run all the steps or scripts in a single tenant that has both the event subscription and the webhook. And, in the second scenario, you run some steps in the tenant that has the event subscription and some steps in the tenant that has the webhook.
1521

1622
## Deliver events to a Webhook in the same Azure AD tenant
1723

18-
![Secure WebHook delivery with Azure AD in Azure Event Grid](./media/secure-webhook-delivery/single-tenant-diagram.png)
24+
The following diagram depicts how Event Grid events are delivered to a webhook in the same tenant as the event subscription.
25+
26+
:::image type="content" source="./media/secure-webhook-delivery/single-tenant-diagram.png" alt-text="Image that depicts secure delivery of events to a webhook that's in the same tenant.":::
27+
28+
There are two subsections in this section. Read through both the scenarios or the one that you're interested in.
1929

20-
Based on the diagram above, follow the next steps to configure the tenant.
30+
- [Configure the event subscription by using an Azure AD **user**](#configure-the-event-subscription-by-using-an-azure-ad-user)
31+
- [Configure the event subscription by using an Azure AD **application**](#configure-the-event-subscription-by-using-an-azure-ad-application)
2132

22-
### Configure the event subscription by using Azure AD User
2333

24-
1. Create an Azure AD Application for the webhook configured to work with the Microsoft directory (Single tenant).
34+
### Configure the event subscription by using an Azure AD user
35+
36+
This section shows how to configure the event subscription by using an Azure AD user.
37+
38+
1. Create an Azure AD application for the webhook configured to work with the Microsoft directory (single tenant).
2539

2640
2. Open the [Azure Shell](https://portal.azure.com/#cloudshell/) in the tenant and select the PowerShell environment.
2741

2842
3. Modify the value of **$webhookAadTenantId** to connect to the tenant.
2943

3044
- Variables:
31-
- **$webhookAadTenantId**: Azure Tenant ID
45+
- **$webhookAadTenantId**: Azure tenant ID
3246

3347
```Shell
3448
PS /home/user>$webhookAadTenantId = "[REPLACE_WITH_YOUR_TENANT_ID]"
@@ -38,11 +52,11 @@ Based on the diagram above, follow the next steps to configure the tenant.
3852
4. Open the [following script](scripts/event-grid-powershell-webhook-secure-delivery-azure-ad-user.md) and update the values of **$webhookAppObjectId** and **$eventSubscriptionWriterUserPrincipalName** with your identifiers, then continue to run the script.
3953

4054
- Variables:
41-
- **$webhookAppObjectId**: Azure AD Application ID created for the webhook
42-
- **$eventSubscriptionWriterUserPrincipalName**: Azure User Principal Name of the user who will create event subscription
55+
- **$webhookAppObjectId**: Azure AD application ID created for the webhook
56+
- **$eventSubscriptionWriterUserPrincipalName**: Azure user principal name of the user who will create event subscription
4357

4458
> [!NOTE]
45-
> You don't need to modify the value of **$eventGridAppId**, for this script we set **AzureEventGridSecureWebhookSubscriber** as the value for the **$eventGridRoleName**. Remember, you must be a member of the [Azure AD Application Administrator role](../active-directory/roles/permissions-reference.md#all-roles) or be an owner of the service principal of Webhook app in Azure AD to execute this script.
59+
> You don't need to modify the value of **$eventGridAppId**. In this script, **AzureEventGridSecureWebhookSubscriber** is set for the **$eventGridRoleName**. Remember, you must be a member of the [Azure AD Application Administrator role](../active-directory/roles/permissions-reference.md#all-roles) or be an owner of the service principal of webhook app in Azure AD to execute this script.
4660
4761
If you see the following error message, you need to elevate to the service principal. An additional access check has been introduced as part of create or update of event subscription on March 30, 2021 to address a security vulnerability. The subscriber client's service principal needs to be either an owner or have a role assigned on the destination application service principal.
4862

@@ -65,22 +79,24 @@ Based on the diagram above, follow the next steps to configure the tenant.
6579
6680
![Secure Webhook action](./media/secure-webhook-delivery/aad-configuration.png)
6781
68-
### Configure the event subscription by using Azure AD Application
82+
### Configure the event subscription by using an Azure AD application
6983
70-
1. Create an Azure AD Application for the Event Grid subscription writer configured to work with the Microsoft directory (Single tenant).
84+
This section shows how to configure the event subscription by using an Azure AD application.
7185
72-
2. Create a secret for the Azure AD Application previously created and save the value (you'll need this value later).
86+
1. Create an Azure AD application for the Event Grid subscription writer configured to work with the Microsoft directory (Single tenant).
7387
74-
3. Go to the Access control (IAM) in the Event Grid Topic and add the role assignment of the Event Grid subscription writer as Event Grid Contributor, this step will allow us to have access to the Event Grid resource when we logged-in into Azure with the Azure AD Application by using the Azure CLI.
88+
2. Create a secret for the Azure AD application and save the value (you'll need this value later).
7589
76-
4. Create an Azure AD Application for the webhook configured to work with the Microsoft directory (Single tenant).
90+
3. Go to the **Access control (IAM)** page for the Event Grid topic and assign **Event Grid Contributor** role to the Event Grid subscription writer app. This step will allow you to have access to the Event Grid resource when you logged-in into Azure with the Azure AD application by using Azure CLI.
91+
92+
4. Create an Azure AD application for the webhook configured to work with the Microsoft directory (Single tenant).
7793
7894
5. Open the [Azure Shell](https://portal.azure.com/#cloudshell/) in the tenant and select the PowerShell environment.
7995
8096
6. Modify the value of **$webhookAadTenantId** to connect to the tenant.
8197
8298
- Variables:
83-
- **$webhookAadTenantId**: Azure Tenant ID
99+
- **$webhookAadTenantId**: Azure tenant ID
84100
85101
```Shell
86102
PS /home/user>$webhookAadTenantId = "[REPLACE_WITH_YOUR_TENANT_ID]"
@@ -90,13 +106,13 @@ Based on the diagram above, follow the next steps to configure the tenant.
90106
7. Open the [following script](scripts/event-grid-powershell-webhook-secure-delivery-azure-ad-app.md) and update the values of **$webhookAppObjectId** and **$eventSubscriptionWriterAppId** with your identifiers, then continue to run the script.
91107
92108
- Variables:
93-
- **$webhookAppObjectId**: Azure AD Application ID created for the webhook
94-
- **$eventSubscriptionWriterAppId**: Azure AD Application ID for Event Grid subscription writer
109+
- **$webhookAppObjectId**: Azure AD application ID created for the webhook
110+
- **$eventSubscriptionWriterAppId**: Azure AD application ID for Event Grid subscription writer app.
95111
96112
> [!NOTE]
97-
> You don't need to modify the value of **```$eventGridAppId```**, for this script we set **AzureEventGridSecureWebhookSubscriber** as the value for the **```$eventGridRoleName```**. Remember, you must be a member of the [Azure AD Application Administrator role](../active-directory/roles/permissions-reference.md#all-roles) or be an owner of the service principal of Webhook app in Azure AD to execute this script.
113+
> You don't need to modify the value of **```$eventGridAppId```**. In this script, **AzureEventGridSecureWebhookSubscriber** as set for the **```$eventGridRoleName```**. Remember, you must be a member of the [Azure AD Application Administrator role](../active-directory/roles/permissions-reference.md#all-roles) or be an owner of the service principal of webhook app in Azure AD to execute this script.
98114
99-
8. Login as the Event Grid subscription writer Azure AD Application by running the command.
115+
8. Log in as the Event Grid subscription writer Azure AD Application by running the command.
100116
101117
```azurecli
102118
PS /home/user>az login --service-principal -u [REPLACE_WITH_EVENT_GRID_SUBSCRIPTION_WRITER_APP_ID] -p [REPLACE_WITH_EVENT_GRID_SUBSCRIPTION_WRITER_APP_SECRET_VALUE] --tenant [REPLACE_WITH_TENANT_ID]
@@ -109,16 +125,16 @@ Based on the diagram above, follow the next steps to configure the tenant.
109125
```
110126
111127
> [!NOTE]
112-
> In this scenario we are using an Event Grid System Topic. See [here](/cli/azure/eventgrid), if you want to create a subscription for Custom Topics or Event Grid Domains by using the Azure CLI.
128+
> This scenario uses a system topic. If you want to create a subscription for custom topics or domains by using Azure CLI, see [CLI reference](/cli/azure/eventgrid).
113129
114-
10. If everything was correctly configured, you can successfully create the webhook subscription in your Event Grid Topic.
130+
10. If everything was correctly configured, you can successfully create the webhook subscription in your Event Grid topic.
115131
116132
> [!NOTE]
117-
> At this point Event Grid is now passing the Azure AD Bearer token to the webhook client in every message, you'll need to validate the Authorization token in your webhook.
133+
> At this point, Event Grid is now passing the Azure AD bearer token to the webhook client in every message. You'll need to validate the authorization token in your webhook.
118134
119135
## Deliver events to a Webhook in a different Azure AD tenant
120136
121-
To secure the connection between your event subscription and your webhook endpoint that are in different Azure AD tenants, you'll need to use an Azure AD application as shown in this section. Currently, it's not possible to secure this connection by using an Azure AD user in the Azure portal.
137+
To secure the connection between your event subscription and your webhook endpoint that are in different Azure AD tenants, you'll need to use an Azure AD **application** as shown in this section. Currently, it's not possible to secure this connection by using an Azure AD **user** in the Azure portal.
122138
123139
![Multitenant events with Azure AD and Webhooks](./media/secure-webhook-delivery/multitenant-diagram.png)
124140
@@ -128,17 +144,17 @@ Based on the diagram above, follow next steps to configure both tenants.
128144
129145
Do the following steps in **Tenant A**:
130146
131-
1. Create an Azure AD application for the Event Grid subscription writer configured to work with any Azure AD directory (Multitenant).
147+
1. Create an Azure AD application for the Event Grid subscription writer configured to work with any Azure AD directory (Multi-tenant).
132148
133-
2. Create a secret for the Azure AD application previously created in the **Tenant A**, and save the value (you'll need this value later).
149+
2. Create a secret for the Azure AD application, and save the value (you'll need this value later).
134150
135-
3. Navigate to the **Access control (IAM)** page for the event grid topic. Add Azure AD application of the Event Grid subscription writer to the **Event Grid Contributor** role. This step allows the application to have access to the Event Grid resource when you log in into Azure with the Azure AD application by using the Azure CLI.
151+
3. Navigate to the **Access control (IAM)** page for the Event Grid topic. Assign the **Event Grid Contributor** role to Azure AD application of the Event Grid subscription writer. This step allows the application to have access to the Event Grid resource when you sign in into Azure with the Azure AD application by using Azure CLI.
136152
137153
### Tenant B
138154
139155
Do the following steps in **Tenant B**:
140156
141-
1. Create an Azure AD Application for the webhook configured to work with the Microsoft directory (Single tenant).
157+
1. Create an Azure AD Application for the webhook configured to work with the Microsoft directory (single tenant).
142158
5. Open the [Azure Shell](https://portal.azure.com/#cloudshell/), and select the PowerShell environment.
143159
6. Modify the **$webhookAadTenantId** value to connect to the **Tenant B**.
144160
- Variables:
@@ -155,7 +171,7 @@ Do the following steps in **Tenant B**:
155171
- **$eventSubscriptionWriterAppId**: Azure AD application ID for Event Grid subscription writer
156172
157173
> [!NOTE]
158-
> You don't need to modify the value of **```$eventGridAppId```**, for this script we set **AzureEventGridSecureWebhookSubscriber** as the value for the **```$eventGridRoleName```**. Remember, you must be a member of the [Azure AD Application Administrator role](../active-directory/roles/permissions-reference.md#all-roles) or be an owner of the service principal of Webhook app in Azure AD to execute this script.
174+
> You don't need to modify the value of **```$eventGridAppId```**. In this script, **AzureEventGridSecureWebhookSubscriber** is set for **```$eventGridRoleName```**. Remember, you must be a member of the [Azure AD Application Administrator role](../active-directory/roles/permissions-reference.md#all-roles) or be an owner of the service principal of webhook app in Azure AD to execute this script.
159175
160176
If you see the following error message, you need to elevate to the service principal. An additional access check has been introduced as part of create or update of event subscription on March 30, 2021 to address a security vulnerability. The subscriber client's service principal needs to be either an owner or have a role assigned on the destination application service principal.
161177
@@ -169,7 +185,7 @@ Do the following steps in **Tenant B**:
169185
170186
Back in **Tenant A**, do the following steps:
171187
172-
1. Open the [Azure Shell](https://portal.azure.com/#cloudshell/), and login as the Event Grid subscription writer Azure AD Application by running the command.
188+
1. Open the [Azure Shell](https://portal.azure.com/#cloudshell/), and sign in as the Event Grid subscription writer Azure AD Application by running the command.
173189
174190
```azurecli
175191
PS /home/user>az login --service-principal -u [REPLACE_WITH_APP_ID] -p [REPLACE_WITH_SECRET_VALUE] --tenant [REPLACE_WITH_TENANT_ID]
@@ -182,7 +198,7 @@ Back in **Tenant A**, do the following steps:
182198
183199
> [!NOTE]
184200
> In this scenario we are using an Event Grid System Topic. See [here](/cli/azure/eventgrid), if you want to create a subscription for custom topics or Event Grid domains by using the Azure CLI.
185-
3. If everything was correctly configured, you can successfully create the webhook subscription in your event grid topic.
201+
3. If everything was correctly configured, you can successfully create the webhook subscription in your Event Grid topic.
186202
187203
> [!NOTE]
188204
> At this point, Event Grid is now passing the Azure AD Bearer token to the webhook client in every message. You'll need to validate the Authorization token in your webhook.

0 commit comments

Comments
 (0)