Skip to content

Commit 5bbd938

Browse files
Merge pull request #300051 from spelluru/egridupdates0519
Event Grid: updated based on Seth's input
2 parents 767d1d8 + 3831614 commit 5bbd938

File tree

5 files changed

+39
-44
lines changed

5 files changed

+39
-44
lines changed

articles/event-grid/authenticate-with-namespaces-using-webhook-authentication.md

Lines changed: 39 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -51,49 +51,44 @@ For information on configuring system and user-assigned identities using the Azu
5151
## Grant the managed identity appropriate access to function or webhook
5252
Grant the managed identity of your Event Grid namespace the appropriate access to the target Azure function or webhook.
5353

54-
### Use Azure portal
55-
56-
1. Identify the managed identity.
57-
1. Navigate to your **Event Grid namespace** in the [Azure portal](https://portal.azure.com).
58-
1. On the **Event Grid namespace** page, select **Identity** on the left menu.
59-
1. Copy the **object ID** of the managed identity.
60-
1. Navigate to your **Azure function app** or the **app service hosting the Webhook**.
61-
1. Assign appropriate role to the managed identity.
62-
1. On the **Function App** page, select **Access Control (IAM)** on the left menu, and then select **Add Role Assignment**.
63-
1. Choose a role like **Contributor** or **Function App Contributor** (or a custom role with required permissions).
64-
1. Scope it appropriately (for example, at the resource or resource group level).
65-
1. Select **Assign access to**, and then select user, group, or service principal.
66-
1. Paste the object ID of the managed identity for your Event Grid namespace.
67-
1. **Save** and **Confirm** access. Complete the role assignment and confirm access is reflected under the **Role assignments** tab.
68-
69-
### Use Azure CLI
70-
71-
1. Get the object ID of the managed identity for your Event Grid namespace.
72-
73-
```azurecli
74-
az eventgrid namespace identity show \
75-
--name <eventgrid-namespace-name> \
76-
--resource-group <eventgrid-resource-group> \
77-
--query principalId \
78-
--output tsv
79-
```
80-
81-
Save the output (let’s call it EG_MI_ID).
82-
2. Assign a role (for example, Contributor) to the managed identity on the Azure function or Webhook resource.
83-
84-
```azurecli
85-
az role assignment create \
86-
--assignee-object-id <EG_MI_ID> \
87-
--assignee-principal-type ServicePrincipal \
88-
--role "Contributor" \ # or use a least-privileged custom role
89-
--scope $(az functionapp show \
90-
--name <function-app-name> \
91-
--resource-group <function-app-resource-group> \
92-
--query id --output tsv)
93-
```
94-
You can replace **Contributor** with a custom role name that grants only required permissions (for example, **Azure Event Grid Event Subscription Contributor** for webhooks).
95-
96-
## Configure custom webhook authentication settings on your Event Grid namespace
54+
To set up custom authentication for an Azure function, follow these steps:
55+
56+
### Create a Microsoft Entra app
57+
1. [Create a Microsoft Entra App in Microsoft Entra ID](/entra/identity-platform/quickstart-register-app).
58+
1. On the overview page of the app, note the **Application (client) ID**.
59+
60+
:::image type="content" source="./media/authenticate-with-namespaces-using-webhook-authentication/application-client-id.png" alt-text="Screenshot showing the Overview page of a Microsoft Entra ID app with the application or client ID highlighted.":::
61+
1. On the left menu, select **Expose an API**, and then select **Add** next to **Application ID URI**.
62+
1. Note down the **application ID URI** On the **Edit application ID URI** page, then select **Save**.
63+
64+
:::image type="content" source="./media/authenticate-with-namespaces-using-webhook-authentication/application-id-uri.png" alt-text="Screenshot showing the application ID URI of the Microsoft Entra app." lightbox="./media/authenticate-with-namespaces-using-webhook-authentication/application-id-uri.png":::
65+
66+
### Set up authentication for Azure function
67+
If you have a basic Azure Function created from the Azure portal, follow these steps to set up authentication and validate the Microsoft Entra ID token created using a managed identity.
68+
69+
1. Navigate to your Azure function app.
70+
1. On the left menu, select **Authentication**, and then select **Add identity provider**.
71+
72+
:::image type="content" source="./media/authenticate-with-namespaces-using-webhook-authentication/function-add-identity-provider-button.png" alt-text="Screenshot showing the Authentication page." lightbox="./media/authenticate-with-namespaces-using-webhook-authentication/function-add-identity-provider-button.png":::
73+
1. On the **Add an identity provider** page, for **Identity Provider**, select **Microsoft** from the drop-down list.
74+
1. In the **App registration**, do these steps:
75+
1. For **Client ID**, enter the client ID of Microsoft Entra app you noted earlier.
76+
1. For **Issuer URL**, add the issuer URL in the form: `https://login.microsoftonline.com/<tenantid>/v2.0`.
77+
78+
:::image type="content" source="./media/authenticate-with-namespaces-using-webhook-authentication/identity-provider-first-settings.png" alt-text="Screenshot showing the Add an identity provider with Microsoft as an identity provider." lightbox="./media/authenticate-with-namespaces-using-webhook-authentication/identity-provider-first-settings.png":::
79+
1. In the **Allowed token audiences**, add the **application UD URI** of the Microsoft Entra app you noted earlier.
80+
1. In the **Additional checks** section, do these steps:
81+
1. For **Client application development**, select **Allow requests from specific client applications**.
82+
1. On the **Allowed client applications** page, enter the **client ID** of the system-assigned managed identity used to generate the token. You can find this ID in the **enterprise app** of the Microsoft Entra ID resource.
83+
1. Choose additional settings based on specific requirements, and then select **Add**.
84+
85+
Now, generate and use the Microsoft Entra ID token.
86+
1. Generate a Microsoft Entra ID token using the **managed identity** with the **application ID URI** as the resources.
87+
1. Use this token to invoke the Azure function by including it in the request header.
88+
89+
90+
91+
## Configure custom webhook authentication settings on your Event Grid namespace
9792
In this step, you configure custom webhook authentication settings on your Event Grid namespace using Azure portal and Azure CLI. You need to create the namespace first and then update it using the following steps.
9893

9994
### Use Azure portal
@@ -136,7 +131,7 @@ Replace <NAMESPACE_NAME> and <RESOURCE_GROUP_NAME> with your actual values, and
136131
### Request Headers
137132

138133
- Authorization: Bearer token
139-
- token is an Entra ID token for the managed identity configured to call the webhook.
134+
- token is a Microsoft Entra token for the managed identity configured to call the webhook.
140135

141136
### Request payload
142137

43.5 KB
Loading
93.4 KB
Loading
Loading
Loading

0 commit comments

Comments
 (0)