|
1 | 1 | --- |
2 | 2 | title: Durable Functions publishing to Azure Event Grid |
3 | 3 | description: Learn how to configure automatic Azure Event Grid publishing for Durable Functions. |
4 | | -ms.topic: conceptual |
| 4 | +ms.topic: article |
5 | 5 | ms.date: 05/11/2020 |
6 | 6 | ms.devlang: csharp |
7 | 7 | # ms.devlang: csharp, javascript |
@@ -54,15 +54,15 @@ Get the endpoint of the topic. Replace `<topic_name>` with the name you chose. |
54 | 54 | az eventgrid topic show --name <topic_name> -g eventResourceGroup --query "endpoint" --output tsv |
55 | 55 | ``` |
56 | 56 |
|
57 | | -Get the topic key. Replace `<topic_name>` with the name you chose. |
| 57 | +Get the topic key if you're using key based authentication. Replace `<topic_name>` with the name you chose. |
58 | 58 |
|
59 | 59 | ```azurecli |
60 | 60 | az eventgrid topic key list --name <topic_name> -g eventResourceGroup --query "key1" --output tsv |
61 | 61 | ``` |
62 | 62 |
|
63 | 63 | Now you can send events to the topic. |
64 | 64 |
|
65 | | -## Configure Event Grid publishing |
| 65 | +## Configure Event Grid publishing with key based authentication |
66 | 66 |
|
67 | 67 | In your Durable Functions project, find the `host.json` file. |
68 | 68 |
|
@@ -117,6 +117,94 @@ If you're using the [Storage Emulator](../../storage/common/storage-use-emulator |
117 | 117 |
|
118 | 118 | If you're using a real Azure Storage account, replace `UseDevelopmentStorage=true` in `local.settings.json` with its connection string. |
119 | 119 |
|
| 120 | +## Configure Event Grid publishing with Managed Identity |
| 121 | + |
| 122 | +Managed identities in Azure allow resources to authenticate to Azure services without storing credentials, simplifying security and identity management. _System-assigned_ managed identity is automatically created when you enable it on an Azure resource and is tied to that resource’s lifecycle. If the resource is deleted, the identity is also removed. _User-assigned_ managed identity is created as a standalone Azure resource and can be assigned to multiple resources. It persists independently of any resource, offering flexibility for shared access and centralized identity management. It's recommended that you use user-assigned identity because it's not attached to the lifecycle of the app. |
| 123 | + |
| 124 | +For more information, visit [Use managed identities for App Service and Azure Functions](../../app-service/overview-managed-identity.md). |
| 125 | + |
| 126 | +### System Assigned Identity |
| 127 | +To configure system assigned identity follow the instructions below: |
| 128 | + |
| 129 | +#### Configuration |
| 130 | +1. Turn on system assigned identity for the function app |
| 131 | + - Go to the function app's **Identity** section and in the **System Assigned** tab, toggle the **Status** switch to on. |
| 132 | + |
| 133 | + :::image type="content" source="./media/durable-functions-event-publishing/enable-system-assigned-identity.png" alt-text="Screenshot of enabling system assigned identity in the function app." border="true"::: |
| 134 | + |
| 135 | +2. In the Event Grid topic resource, give the function app the EventGrid Data Sender role. |
| 136 | + - Go to the **Access Control (IAM)** section, click **+ Add**. |
| 137 | + |
| 138 | + :::image type="content" source="./media/durable-functions-event-publishing/add-role.png" alt-text="Screenshot of adding a role to event grid topic resource." border="true"::: |
| 139 | + |
| 140 | + - Select the **EventGrid Data Sender** role, click **Next**. |
| 141 | + |
| 142 | + :::image type="content" source="./media/durable-functions-event-publishing/event-grid-data-sender.png" alt-text="Screenshot of selecting the EventGrid Data Sender Role." border="true"::: |
| 143 | + |
| 144 | + - Choose **Managed Identity** in the **Assign access to** section, click **+ Select Members** in the **Members** section, select the managed identity, then click **Review + Assign**. |
| 145 | + |
| 146 | + :::image type="content" source="./media/durable-functions-event-publishing/select-managed-identity.png" alt-text="Screenshot of selecting a managed identity." border="true"::: |
| 147 | + |
| 148 | + |
| 149 | +#### App Settings |
| 150 | +Add an `EventGrid__topicEndpoint` app setting with the value as the Event Grid topic endpoint. |
| 151 | + |
| 152 | +You can use the following command: |
| 153 | +`az functionapp config appsettings set --name <function app name> --resource-group <resource group name> --settings EventGrid__topicEndpoint="<topic endpoint>"` |
| 154 | + |
| 155 | +### User Assigned Identity |
| 156 | +To configure user assigned managed identity follow the instructions below: |
| 157 | + |
| 158 | +#### Configuration |
| 159 | +1. Create a user assigned managed identity. |
| 160 | + - In the Azure portal, search for _Managed Identities_ in the global search bar. |
| 161 | + |
| 162 | + - Create a user assigned managed identity (UAMI) and select **Review + create**. |
| 163 | + |
| 164 | + :::image type="content" source="./media/durable-functions-event-publishing/create-user-assigned-managed-identity.png" alt-text="Screenshot of creating user assigned managed identity." border="true"::: |
| 165 | + |
| 166 | +2. Attach the UAMI to the function app resource |
| 167 | + - Go to the function app, **Identity** section, click **Add +**. |
| 168 | + |
| 169 | + :::image type="content" source="./media/durable-functions-event-publishing/function-app-add-user-assigned-managed-identity.png" alt-text="Screenshot of the function app identity section for user assigned managed identity." border="true"::: |
| 170 | + |
| 171 | + - Choose the UAMI created above, then click **Add**. |
| 172 | + |
| 173 | + :::image type="content" source="./media/durable-functions-event-publishing/function-app-add-specific-user-assigned-managed-identity.png" alt-text="Screenshot of selecting specific user assigned managed identity." border="true"::: |
| 174 | + |
| 175 | +3. Attach the UAMI to the event grid topic resource. |
| 176 | + - Go to the event grid topic resource, **Identity** section, choose the **User assigned** tab, then click **Add +**. Choose the user assigned managed identity, then click **Add**. |
| 177 | + |
| 178 | + :::image type="content" source="./media/durable-functions-event-publishing/add-user-assigned-managed-identity-to-event-grid-topic.png" alt-text="Screenshot of adding a user assigned managed identity to event grid topic." border="true"::: |
| 179 | + |
| 180 | +4. Create an Event Grid subscription and select an endpoint. |
| 181 | + - In the **Overview** tab of the Event Grid Topic resource, select **+ Event Subscription**, and create the event subscription. |
| 182 | + |
| 183 | + :::image type="content" source="./media/durable-functions-event-publishing/event-subscription.png" alt-text="Screenshot of the + Event Subscription button." border="true"::: |
| 184 | + |
| 185 | + - Based on the endpoint you choose in **Endpoint Details**, you will see a **Managed Identity for Delivery** section. Choose **User Assigned** for the **Managed Identity** type and select the UAMI. |
| 186 | + |
| 187 | + :::image type="content" source="./media/durable-functions-event-publishing/event-subscription-managed-identity.png" alt-text="Screenshot of adding a user assigned managed identity to event grid subscription." border="true"::: |
| 188 | + |
| 189 | +6. In the Event Grid topic resource, assign the **EventGrid Data Sender** role to the UAMI. |
| 190 | + |
| 191 | + - Go to the **Access Control (IAM)** section, click **+ Add**. |
| 192 | + |
| 193 | + :::image type="content" source="./media/durable-functions-event-publishing/add-role.png" alt-text="Screenshot of adding a role to an event grid topic resource." border="true"::: |
| 194 | + |
| 195 | + - Select the **EventGrid Data Sender** role, click **Next**. |
| 196 | + |
| 197 | + :::image type="content" source="./media/durable-functions-event-publishing/event-grid-data-sender.png" alt-text="Screenshot of selecting the EventGrid Data Sender Role." border="true"::: |
| 198 | + |
| 199 | + - Choose **Managed Identity** in the **Assign access to** section, click **+ Select Members** in the **Members** section, select the UAMI, then click **Review + Assign**. |
| 200 | + |
| 201 | + :::image type="content" source="./media/durable-functions-event-publishing/select-managed-identity.png" alt-text="Screenshot of selecting a managed identity." border="true"::: |
| 202 | + |
| 203 | +#### App Settings |
| 204 | +- Add an `EventGrid__topicEndpoint` app setting with the value as the Event Grid topic endpoint. |
| 205 | +- Add an `EventGrid__credential` app setting with the value `managedidentity`. |
| 206 | +- Add an `EventGrid__clientId` app setting with the value of the user assigned managed identity client ID. |
| 207 | + |
120 | 208 | ## Create functions that listen for events |
121 | 209 |
|
122 | 210 | Using the Azure portal, create another function app to listen for events published by your Durable Functions app. It's best to locate it in the same region as the Event Grid topic. |
|
0 commit comments