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.md
+25-25Lines changed: 25 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,27 +10,27 @@ ms.reviewer: sngun
10
10
11
11
---
12
12
13
-
# Use managed identities to access Azure Cosmos DB data
13
+
# Use system-assigned managed identities to access Azure Cosmos DB data
14
14
15
-
In this article you'll set up a **robust, key rotation agnostic** solution to access Azure Cosmos DB keys using [managed identities](../active-directory/managed-identities-azure-resources/services-support-managed-identities.md). The example in this article uses Azure Functions, but you can use any service that supports managed identities.
15
+
In this article, you'll set up a *robust, key rotation agnostic* solution to access Azure Cosmos DB keys by using [managed identities](../active-directory/managed-identities-azure-resources/services-support-managed-identities.md). The example in this article uses Azure Functions, but you can use any service that supports managed identities.
16
16
17
-
You'll learn how to create a function app that can access Azure Cosmos DB data without needing to copy any Azure Cosmos DB keys. The function app will wake up every minute and record the current temperature of an aquarium fish tank. To learn how to set up a timer-triggered function app see the [Create a function in Azure that is triggered by a timer](../azure-functions/functions-create-scheduled-function.md) article.
17
+
You'll learn how to create a function app that can access Azure Cosmos DB data without needing to copy any Azure Cosmos DB keys. The function app will wake up every minute and record the current temperature of an aquarium fish tank. To learn how to set up a timer-triggered function app, see the [Create a function in Azure that is triggered by a timer](../azure-functions/functions-create-scheduled-function.md) article.
18
18
19
-
To simplify the scenario, clean-up of older temperature documents is handled by a [Time To Live](./time-to-live.md) setting already configured.
19
+
To simplify the scenario, a [Time To Live](./time-to-live.md) setting is already configured to clean-up older temperature documents.
20
20
21
21
## Assign a managed identity to a function app
22
22
23
23
In this step, you'll assign a system-assigned managed identity to your function app.
24
24
25
-
1. In the [Azure portal](https://portal.azure.com/), open the **Azure Function** pane and navigate to your function app.
25
+
1. In the [Azure portal](https://portal.azure.com/), open the **Azure Function** pane and go to your function app.
26
26
27
27
1. Open the **Platform features** > **Identity** tab:

30
30
31
31
1. On the **Identity** tab, turn **On** the system identity **Status** and select **Save**. The **Identity** pane should look as follows:

34
34
35
35
## Grant access to your Azure Cosmos account
36
36
@@ -42,34 +42,34 @@ In this step, you'll assign a role to the function app's system-assigned managed
42
42
|[Cosmos DB Account Reader](../role-based-access-control/built-in-roles.md#cosmos-db-account-reader-role)|Can read Azure Cosmos DB account data. Allows retrieval of read keys. |
43
43
44
44
> [!IMPORTANT]
45
-
> Role-based access control support in Azure Cosmos DB applies to control plane operations only. Data plane operations are secured using master keys or resource tokens. To learn more, see the [Secure access to data](secure-access-to-data.md) article.
45
+
> Support for role-based access control in Azure Cosmos DB applies to control plane operations only. Data plane operations are secured through master keys or resource tokens. To learn more, see the [Secure access to data](secure-access-to-data.md) article.
46
46
47
47
> [!TIP]
48
-
> When you assign roles, assign only the access needed. If your service need only read data, then assign the **Cosmos DB Account Reader** role to the managed identity. 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.
48
+
> When you assign roles, assign only the needed access. If your service requires only reading data, then assign the **Cosmos DB Account Reader** role to the managed identity. 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.
49
49
50
50
In this scenario, the function app will read the temperature of the aquarium, then write back that data to a container in Azure Cosmos DB. Because the function app must write the data, you'll need to assign the **DocumentDB Account Contributor** role.
51
51
52
-
1. Sign in to the Azure portal and navigate to your Azure Cosmos DB account. Open the **Access control (IAM)** pane, and then the **Role assignments** tab:
52
+
1. Sign in to the Azure portal and go to your Azure Cosmos DB account. Open the **Access control (IAM)** pane, and then the **Role assignments** tab:
***Assign access to** - Under the **Select system-assigned managed identity** subsection, select **Function App**.
64
-
***Select** - The pane will be populated with all the function apps in your subscription that have a **Managed System Identity**. In this case I select the **SummaryService** function app:
***Assign access to**: Under the **Select system-assigned managed identity** subsection, select **Function App**.
64
+
***Select**: The pane will be populated with all the function apps in your subscription that have a **Managed System Identity**. In this case select the **SummaryService** function app:

67
67
68
-
1. After you have selected your function app, click**Save**.
68
+
1. After you have selected your function app, select**Save**.
69
69
70
-
## Access the Azure Cosmos DB keys from the function app
70
+
## Programmatically access the Azure Cosmos DB keys
71
71
72
-
Now we have a function app that has a system-assigned managed identity with the **DocumentDB Account Contributor** role in the Azure Cosmos DB permissions. The following function app code sample will get the Azure Cosmos DB keys, create a CosmosClient object, get the temperature of the aquarium, and then save this to Cosmos DB.
72
+
Now we have a function app that has a system-assigned managed identity with the **DocumentDB Account Contributor** role in the Azure Cosmos DB permissions. The following function app code will get the Azure Cosmos DB keys, create a CosmosClient object, get the temperature of the aquarium, and then save this to Azure Cosmos DB.
73
73
74
74
This sample uses the [List Keys API](https://docs.microsoft.com/rest/api/cosmos-db-resource-provider/DatabaseAccounts/ListKeys) to access your Azure Cosmos DB account keys.
75
75
@@ -91,7 +91,7 @@ namespace SummarizationService
91
91
}
92
92
```
93
93
94
-
The example also uses a simple document called "TemperatureRecord", which is defined as follows:
94
+
The example also uses a simple document called "TemperatureRecord," which is defined as follows:
95
95
96
96
```csharp
97
97
usingSystem;
@@ -145,20 +145,20 @@ namespace Monitor
145
145
// AzureServiceTokenProvider will help us to get the Service Managed token.
0 commit comments