Skip to content

Commit ef0e06e

Browse files
committed
try out a new doc for identity
Signed-off-by: Hannah Hunter <[email protected]>
1 parent ba53f58 commit ef0e06e

File tree

2 files changed

+275
-37
lines changed

2 files changed

+275
-37
lines changed
Lines changed: 275 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,275 @@
1+
---
2+
title: Configuring managed identity for Azure Functions Durable Task Scheduler (preview)
3+
description: Learn about the roles available for managed identity in Durable Task Scheduler and how to configure them.
4+
ms.topic: how-to
5+
ms.date: 05/05/2025
6+
zone_pivot_groups: dts-devexp
7+
---
8+
9+
## Configuring managed identity for Durable Task Scheduler (preview)
10+
11+
Durable Task Scheduler **only** supports either *user-assigned* or *system-assigned* managed identity authentication. **User-assigned identities are recommended,** as they aren't tied to the lifecycle of the app and can be reused after the app is deprovisioned.
12+
13+
You can grant the following Durable Task Scheduler related roles to an identity:
14+
15+
| Role | Description |
16+
| ---- | ----------- |
17+
| **Durable Task Data Contributor** | Role for all data access operations. This role is a superset of all other roles. |
18+
| **Durable Task Worker** | Role used by worker applications to interact with the Durable Task Scheduler. Assign this role if your app is used *only* for processing orchestrations, activities, and entities. |
19+
| **Durable Task Data Reader** | Role to read all Durable Task Scheduler data. Assign this role if you only need a list of orchestrations and entities payloads. |
20+
21+
> [!NOTE]
22+
> Most Durable Functions apps require the *Durable Task Data Contributor* role.
23+
24+
In this article, you learn how to grant permissions to an identity resource and configure your compute app to use the identity for access to schedulers and task hubs.
25+
26+
### Assign role-based access control (RBAC) to a managed identity resource
27+
28+
::: zone pivot="az-cli"
29+
30+
1. Create a user-assigned managed identity
31+
32+
```azurecli
33+
az identity create -g RESOURCE_GROUP_NAME -n IDENTITY_NAME
34+
```
35+
36+
1. Set the assignee to identity resource created
37+
38+
```azurecli
39+
assignee=$(az identity show --name IDENTITY_NAME --resource-group RESOURCE_GROUP_NAME --query 'clientId' --output tsv)
40+
```
41+
42+
1. Set the scope. Granting access on the scheduler scope gives access to *all* task hubs in that scheduler.
43+
44+
**Task Hub**
45+
46+
```bash
47+
scope="/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP_NAME/providers/Microsoft.DurableTask/schedulers/SCHEDULER_NAME/taskHubs/TASKHUB_NAME"
48+
```
49+
50+
**Scheduler**
51+
52+
```bash
53+
scope="/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP_NAME/providers/Microsoft.DurableTask/schedulers/SCHEDULER_NAME"
54+
```
55+
56+
1. Grant access. Run the following command to create the role assignment and grant access.
57+
58+
```azurecli
59+
az role assignment create \
60+
--assignee "$assignee" \
61+
--role "Durable Task Data Contributor" \
62+
--scope "$scope"
63+
```
64+
65+
*Expected output*
66+
67+
The following output example shows a developer identity assigned with the Durable Task Data Contributor role on the *scheduler* level:
68+
69+
```json
70+
{
71+
"condition": null,
72+
"conditionVersion": null,
73+
"createdBy": "YOUR_DEVELOPER_CREDENTIAL_ID",
74+
"createdOn": "2024-12-20T01:36:45.022356+00:00",
75+
"delegatedManagedIdentityResourceId": null,
76+
"description": null,
77+
"id": "/subscriptions/YOUR_SUBSCRIPTION_ID/resourceGroups/YOUR_RESOURCE_GROUP/providers/Microsoft.DurableTask/schedulers/YOUR_DTS_NAME/providers/Microsoft.Authorization/roleAssignments/ROLE_ASSIGNMENT_ID",
78+
"name": "ROLE_ASSIGNMENT_ID",
79+
"principalId": "YOUR_DEVELOPER_CREDENTIAL_ID",
80+
"principalName": "YOUR_EMAIL",
81+
"principalType": "User",
82+
"resourceGroup": "YOUR_RESOURCE_GROUP",
83+
"roleDefinitionId": "/subscriptions/YOUR_SUBSCRIPTION/providers/Microsoft.Authorization/roleDefinitions/ROLE_DEFINITION_ID",
84+
"roleDefinitionName": "Durable Task Data Contributor",
85+
"scope": "/subscriptions/YOUR_SUBSCRIPTION/resourceGroups/YOUR_RESOURCE_GROUP/providers/Microsoft.DurableTask/schedulers/YOUR_DTS_NAME",
86+
"type": "Microsoft.Authorization/roleAssignments",
87+
"updatedBy": "YOUR_DEVELOPER_CREDENTIAL_ID",
88+
"updatedOn": "2024-12-20T01:36:45.022356+00:00"
89+
}
90+
```
91+
92+
::: zone-end
93+
94+
::: zone pivot="az-portal"
95+
96+
> [!NOTE]
97+
> The following instruction shows a role assignment scoped to a specific task hub. If you need access to *all* task hubs in a scheduler, perform the assignment on the scheduler level.
98+
99+
1. [Create a user-assigned managed identity](/entra/identity/managed-identities-azure-resources/how-manage-user-assigned-managed-identities#create-a-user-assigned-managed-identity).
100+
101+
1. Navigate to the durable task scheduler resource on the portal.
102+
103+
1. Click on a task hub name.
104+
105+
1. In the left menu, select **Access control (IAM)**.
106+
107+
1. Click **Add** to add a role assignment.
108+
109+
:::image type="content" source="../media/configure-durable-task-scheduler/add-assignment.png" alt-text="Screenshot of the adding the role assignment on the Access Control pane in the portal.":::
110+
111+
1. Search for and select **Durable Task Data Contributor**. Click **Next**.
112+
113+
:::image type="content" source="../media/configure-durable-task-scheduler/data-contributor-role.png" alt-text="Screenshot of selecting the Durable Task Data Contributor role assignment in the portal.":::
114+
115+
1. On the **Members** tab, for **Assign access to**, select **Managed identity**.
116+
117+
1. For **Members**, click **+ Select members**.
118+
119+
1. In the **Select managed identities** pane, expand the **Managed identity** drop-down and select **User-assigned managed identity**.
120+
121+
:::image type="content" source="../media/configure-durable-task-scheduler/members-tab.png" alt-text="Screenshot of selecting the user-assigned managed identity type you're going to use in the portal.":::
122+
123+
1. Pick the user-managed identity previously created and click the **Select** button.
124+
125+
1. Click **Review + assign** to finish assigning the role.
126+
127+
::: zone-end
128+
129+
### Assign managed identity to your app
130+
131+
Now that the identity has the required RBAC to access Durable Task Scheduler, you need to assign it to your function app.
132+
133+
::: zone pivot="az-cli"
134+
135+
1. Get resource ID of manage identity.
136+
```azurecli
137+
resource_id=$(az resource show --resource-group RESOURCE_GROUP --name MANAGED_IDENTITY_NAME --resource-type Microsoft.ManagedIdentity/userAssignedIdentities --query id --output tsv)
138+
```
139+
140+
1. Assign the identity to app.
141+
```azurecli
142+
az functionapp identity assign --resource-group RESOURCE_GROUP_NAME --name FUNCTION_APP_NAME --identities "$resource_id"
143+
```
144+
145+
::: zone-end
146+
147+
::: zone pivot="az-portal"
148+
149+
1. From your app in the portal, select **Settings** > **Identity**.
150+
151+
1. Click the **User assigned** tab.
152+
153+
1. Click **+ Add**, then pick the identity created in the last section. Click the **Add** button.
154+
155+
:::image type="content" source="media/configure-durable-task-scheduler/assign-identity.png" alt-text="Screenshot of adding the user-assigned managed identity to your app in the portal.":::
156+
157+
::: zone-end
158+
159+
### Add environment variables to app
160+
161+
Add these two environment variables to app setting:
162+
- `TASKHUB_NAME`: name of task hub
163+
- `DURABLE_TASK_SCHEDULER_CONNECTION_STRING`: the format of the string is `"Endpoint={scheduler point};Authentication=ManagedIdentity;ClientID={client id}"`, where `Endpoint` is the scheduler endpoint and `client id` is the identity's client ID.
164+
165+
::: zone pivot="az-cli"
166+
167+
1. Get the required information for the Durable Task Scheduler connection string.
168+
169+
To get the scheduler endpoint.
170+
```azurecli
171+
az durabletask scheduler show --resource-group RESOURCE_GROUP_NAME --name DTS_NAME --query 'properties.endpoint' --output tsv
172+
```
173+
174+
To get the client ID of managed identity.
175+
```azurecli
176+
az identity show --name MANAGED_IDENTITY_NAME --resource-group RESOURCE_GROUP_NAME --query 'clientId' --output tsv
177+
```
178+
179+
1. Use the following command to add environment variable for the scheduler connection string to app.
180+
```azurecli
181+
az functionapp config appsettings set --resource-group RESOURCE_GROUP_NAME --name FUNCTION_APP_NAME --settings KEY_NAME=KEY_VALUE
182+
```
183+
184+
1. Repeat previous step to add environment variable for task hub name.
185+
186+
::: zone-end
187+
188+
::: zone pivot="az-portal"
189+
190+
1. Get the required information for the Durable Task Scheduler connection string.
191+
192+
To get your scheduler endpoint, navigate to the **Overview** tab of your scheduler resource and find "Endpoint" in the top *Essentials* section.
193+
194+
To get your managed identity client ID, navigate to the **Overview** tab of your resource and find "Client ID" in the top *Essentials* section.
195+
196+
1. Navigate to your app on the portal.
197+
198+
1. In the left menu, click **Settings** > **Environment variables**.
199+
200+
1. Add environment variable for Durable Task Scheduler connection string.
201+
202+
1. Add environment variable for task hub name.
203+
204+
1. Click **Apply** then **Confirm** to add the variables.
205+
206+
::: zone-end
207+
208+
> [!NOTE]
209+
> If you use system-assigned identity, your connection string would *not* need the client ID of the identity resource: `"Endpoint={scheduler endpoint};Authentication=ManagedIdentity"`.
210+
211+
## Accessing Durable Task Scheduler dashboard
212+
213+
Assign the required role to your *developer identity (email)* to gain access to the [Durable Task Scheduler dashboard](./durable-task-scheduler-dashboard.md).
214+
215+
::: zone pivot="az-cli"
216+
217+
1. Set the assignee to your developer identity.
218+
219+
```azurecli
220+
assignee=$(az ad user show --id "[email protected]" --query "id" --output tsv)
221+
```
222+
223+
1. Set the scope. Granting access on the scheduler scope gives access to *all* task hubs in that scheduler.
224+
225+
**Task Hub**
226+
227+
```bash
228+
scope="/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP/providers/Microsoft.DurableTask/schedulers/SCHEDULER_NAME/taskHubs/TASK_HUB_NAME"
229+
```
230+
231+
**Scheduler**
232+
```bash
233+
scope="/subscriptions/SUBSCRIPTION_ID/resourceGroups/RESOURCE_GROUP/providers/Microsoft.DurableTask/schedulers/SCHEDULER_NAME"
234+
```
235+
236+
1. Grant access. Run the following command to create the role assignment and grant access.
237+
238+
```azurecli
239+
az role assignment create \
240+
--assignee "$assignee" \
241+
--role "Durable Task Data Contributor" \
242+
--scope "$scope"
243+
```
244+
245+
*Expected output*
246+
247+
The following output example shows a developer identity assigned with the Durable Task Data Contributor role on the *scheduler* level:
248+
249+
```json
250+
{
251+
"condition": null,
252+
"conditionVersion": null,
253+
"createdBy": "YOUR_DEVELOPER_CREDENTIAL_ID",
254+
"createdOn": "2024-12-20T01:36:45.022356+00:00",
255+
"delegatedManagedIdentityResourceId": null,
256+
"description": null,
257+
"id": "/subscriptions/YOUR_SUBSCRIPTION_ID/resourceGroups/YOUR_RESOURCE_GROUP/providers/Microsoft.DurableTask/schedulers/YOUR_DTS_NAME/providers/Microsoft.Authorization/roleAssignments/ROLE_ASSIGNMENT_ID",
258+
"name": "ROLE_ASSIGNMENT_ID",
259+
"principalId": "YOUR_DEVELOPER_CREDENTIAL_ID",
260+
"principalName": "YOUR_EMAIL",
261+
"principalType": "User",
262+
"resourceGroup": "YOUR_RESOURCE_GROUP",
263+
"roleDefinitionId": "/subscriptions/YOUR_SUBSCRIPTION/providers/Microsoft.Authorization/roleDefinitions/ROLE_DEFINITION_ID",
264+
"roleDefinitionName": "Durable Task Data Contributor",
265+
"scope": "/subscriptions/YOUR_SUBSCRIPTION/resourceGroups/YOUR_RESOURCE_GROUP/providers/Microsoft.DurableTask/schedulers/YOUR_DTS_NAME",
266+
"type": "Microsoft.Authorization/roleAssignments",
267+
"updatedBy": "YOUR_DEVELOPER_CREDENTIAL_ID",
268+
"updatedOn": "2024-12-20T01:36:45.022356+00:00"
269+
}
270+
```
271+
272+
## Next steps
273+
274+
> [!div class="nextstepaction"]
275+
> [Debug and monitor your orchestrations via the Durable Task Scheduler dashboard](./durable-task-scheduler-dashboard.md)

articles/azure-functions/durable/durable-task-scheduler/includes/assign-role-based-access-control-portal.md

Lines changed: 0 additions & 37 deletions
This file was deleted.

0 commit comments

Comments
 (0)