Skip to content

Commit 0386f73

Browse files
committed
Add steps for RBAC tutorial for local access
1 parent e08dfa8 commit 0386f73

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

articles/cosmos-db/managed-identity-based-authentication.yml

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ metadata:
77
author: seesharprun
88
ms.author: sidandrews
99
ms.reviewer: justipat
10-
ms.date: 10/20/2022
10+
ms.date: 06/25/2024
1111
ms.service: cosmos-db
1212
ms.subservice: nosql
1313
ms.topic: how-to
@@ -16,7 +16,7 @@ metadata:
1616
- devx-track-azurecli
1717
- subject-rbac-steps
1818
- ge-structured-content-pilot
19-
19+
ai-usage: ai-assisted
2020
title: |
2121
Use system-assigned managed identities to access Azure Cosmos DB data
2222
introduction: |
@@ -297,7 +297,24 @@ procedureSection:
297297
(Optional) Run the function locally
298298
summary: |
299299
In a local environment, the [``DefaultAzureCredential``](/dotnet/api/azure.identity.defaultazurecredential) class will use various local credentials to determine the current identity. While running locally isn't required for the how-to, you can develop locally using your own identity or a service principal.
300-
steps:
300+
steps:
301+
- |
302+
Get your local account's principal identifier using [`az ad signed-in-user show`](/cli/azure/ad/signed-in-user#az-ad-signed-in-user-show).
303+
304+
```azurecli-interactive
305+
az ad signed-in-user show --query "id"
306+
```
307+
- |
308+
Assign your local account role-based access control access to the Azure Cosmos DB account using [`az cosmosdb sql role assignment create`](/cli/azure/cosmosdb/sql/role/assignment#az-cosmosdb-sql-role-assignment-create) command. Use the built-in "Cosmos DB Data Contributor" role with an id of `00000000-0000-0000-0000-000000000002`.
309+
310+
```azurecli-interactive
311+
az cosmosdb sql role assignment create \
312+
--resource-group $resourceGroupName \
313+
--account-name $cosmosName \
314+
--role-definition-id "00000000-0000-0000-0000-000000000002" \
315+
--principal-id "<your-principal-id>" \
316+
--scope "/"
317+
```
301318
- |
302319
In the **local.settings.json** file, add a new setting named ``COSMOS_ENDPOINT`` in the **Values** object. The value of the setting should be the document endpoint you recorded earlier in this how-to guide.
303320

0 commit comments

Comments
 (0)