You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/cosmos-db/managed-identity-based-authentication.yml
+28-11Lines changed: 28 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ metadata:
7
7
author: seesharprun
8
8
ms.author: sidandrews
9
9
ms.reviewer: justipat
10
-
ms.date: 10/20/2022
10
+
ms.date: 06/25/2024
11
11
ms.service: cosmos-db
12
12
ms.subservice: nosql
13
13
ms.topic: how-to
@@ -16,7 +16,7 @@ metadata:
16
16
- devx-track-azurecli
17
17
- subject-rbac-steps
18
18
- ge-structured-content-pilot
19
-
19
+
ai-usage: ai-assisted
20
20
title: |
21
21
Use system-assigned managed identities to access Azure Cosmos DB data
22
22
introduction: |
@@ -50,7 +50,7 @@ prerequisites:
50
50
```
51
51
52
52
> [!NOTE]
53
-
> These variables will be re-used in later steps. This example assumes your Azure Cosmos DB account name is ``msdocs-cosmos-app``, your function app name is ``msdocs-function-app`` and your resource group name is ``msdocs-cosmos-functions-dotnet-identity``.
53
+
> These variables are reused in later steps. This example assumes your Azure Cosmos DB account name is ``msdocs-cosmos-app``, your function app name is ``msdocs-function-app`` and your resource group name is ``msdocs-cosmos-functions-dotnet-identity``.
54
54
55
55
2. View the function app's properties using the [``az functionapp show``](/cli/azure/functionapp#az-functionapp-show) command.
56
56
@@ -79,7 +79,7 @@ procedureSection:
79
79
- title: |
80
80
Create Azure Cosmos DB API for NoSQL databases
81
81
summary: |
82
-
In this step, you'll create two databases.
82
+
In this step, you create two databases.
83
83
steps:
84
84
- |
85
85
In a terminal or command window, create a new ``products`` database using [``az cosmosdb sql database create``](/cli/azure/cosmosdb/sql/database#az-cosmosdb-sql-database-create).
@@ -102,7 +102,7 @@ procedureSection:
102
102
- title: |
103
103
Get Azure Cosmos DB API for NoSQL endpoint
104
104
summary: |
105
-
In this step, you'll query the document endpoint for the API for NoSQL account.
105
+
In this step, you query the document endpoint for the API for NoSQL account.
106
106
steps:
107
107
- |
108
108
Use ``az cosmosdb show`` with the **query** parameter set to ``documentEndpoint``. Record the result. You'll use this value in a later step.
@@ -125,11 +125,11 @@ procedureSection:
125
125
```
126
126
127
127
> [!NOTE]
128
-
> This variable will be re-used in a later step.
128
+
> This variable is reused in a later step.
129
129
- title: |
130
130
Grant access to your Azure Cosmos DB account
131
131
summary: |
132
-
In this step, you'll assign a role to the function app's system-assigned managed identity. Azure Cosmos DB has multiple built-in roles that you can assign to the managed identity for control-plane access. For data-plane access, you'll create a new custom role with access to read metadata.
132
+
In this step, you assign a role to the function app's system-assigned managed identity. Azure Cosmos DB has multiple built-in roles that you can assign to the managed identity for control-plane access. For data-plane access, you create a new custom role with access to read metadata.
133
133
134
134
> [!TIP]
135
135
> For more information about the importance of least privilege access, see the [Lower exposure of privileged accounts](../security/fundamentals/identity-management-best-practices.md#lower-exposure-of-privileged-accounts) article.
@@ -150,7 +150,7 @@ procedureSection:
150
150
```
151
151
152
152
> [!NOTE]
153
-
> This variable will be re-used in a later step.
153
+
> This variable is reused in a later step.
154
154
- |
155
155
Use ``az webapp identity show`` with the **query** parameter set to ``principalId``. Store the result in a shell variable named ``principal``.
156
156
@@ -296,8 +296,25 @@ procedureSection:
296
296
- title: |
297
297
(Optional) Run the function locally
298
298
summary: |
299
-
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:
299
+
In a local environment, the [``DefaultAzureCredential``](/dotnet/api/azure.identity.defaultazurecredential) class uses 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:
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`.
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.
303
320
@@ -322,7 +339,7 @@ procedureSection:
322
339
- title: |
323
340
Deploy to Azure
324
341
summary: |
325
-
Once published, the ``DefaultAzureCredential`` class will use credentials from the environment or a managed identity. For this guide, the system-assigned managed identity will be used as a credential for the [``CosmosClient``](/dotnet/api/microsoft.azure.cosmos.cosmosclient) constructor.
342
+
Once published, the ``DefaultAzureCredential`` class uses credentials from the environment or a managed identity. For this guide, the system-assigned managed identity will be used as a credential for the [``CosmosClient``](/dotnet/api/microsoft.azure.cosmos.cosmosclient) constructor.
326
343
steps:
327
344
- |
328
345
Set the ``COSMOS_ENDPOINT`` setting on the function app already deployed in Azure.
0 commit comments