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
+16-16Lines changed: 16 additions & 16 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
---
2
-
title: Managed Identity based authentication and authorization with Azure Cosmos DB and Azure Active Directory
3
-
description: Learn how to configure an Azure AD identity to access keys from Azure Cosmos DB.
2
+
title: System-Assigned Managed Identity based key access using Azure Active Directory
3
+
description: Learn how to configure an Azure AD system-assigned managed identity to access keys from Azure Cosmos DB.
4
4
author: j-patrick
5
5
ms.service: cosmos-db
6
6
ms.topic: conceptual
@@ -10,33 +10,33 @@ ms.reviewer: sngun
10
10
11
11
---
12
12
13
-
# Managed Identity based authentication and authorization with Azure Cosmos DB and Azure Active Directory
13
+
# System-Assigned Managed Identity based key access using Azure Active Directory
14
14
15
15
In this article we'll setup a **robust, key rotation agnostic,** solution for Cosmos DB key management by leveraging [Managed Service Identities](../active-directory/managed-identities-azure-resources/services-support-managed-identities.md). Though we're using an Azure Function for this example, this solution can be used with any service that [supports managed service identities](../active-directory/managed-identities-azure-resources/services-support-managed-identities.md).
16
16
17
17
You'll learn how to:
18
18
19
-
* Assign a System Identity
20
-
* Grant the System Identity access to your Cosmos DB
19
+
* Assign a System-Assigned Managed Identity
20
+
* Grant the System-Assigned Managed Identity access to your Cosmos DB
21
21
* Write the code for robust Cosmos DB key management
22
22
23
23
In the solution below, we'll be building an Azure Function that will handle summarizing the last hour of sales. The function will wake up every hour, and will read a set of sale receipts from Cosmos DB. Then the function will create an hourly summary of sales and store it back in the container. To simplify the scenario, cleanup of the already processed receipts will be handled by an already configured [TTL](./time-to-live.md) setting.
24
24
25
-
## Assign a System Identity to an Azure Function
25
+
## Assign a System-Assigned Managed Identity to an Azure Function
26
26
27
-
In this step, you'll assign a managed system identity to your Azure Function.
27
+
In this step, you'll assign a system-assigned managed identity to your Azure Function.
28
28
29
29
1. Sign into the [Azure portal](https://portal.azure.com/)
30
30
31
31
1. Open the Azure Function pane, and for your function app select the **Identity tab**:
1. On the **Identity tab** switch **System Identity** to the "On" position. Be sure to click **Save**, and confirm you want to turn on System Identity. In the end the **System Identity** pane should look like this:
35
-

## Grant the System Identity Access to your Cosmos DB
37
+
## Grant the System-Assigned Managed Identity Access to your Cosmos DB
38
38
39
-
In this step, you'll assign a role to the Azure Function's System Identity. Cosmos DB has multiple built-in roles you can assign the System Identity too. For this exercise we'll just focus on two:
39
+
In this step, you'll assign a role to the Azure Function's System-Assigned Managed Identity. Cosmos DB has multiple built-in roles you can assign the System Identity too. For this exercise we'll just focus on two:
40
40
41
41
|**Built-in role**|**Description**|
42
42
|---------|---------|
@@ -47,7 +47,7 @@ In this step, you'll assign a role to the Azure Function's System Identity. Cosm
47
47
> RBAC 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 [Secure access to data in Azure Cosmos DB](secure-access-to-data.md)
48
48
49
49
> [!TIP]
50
-
> When assigning roles, only assign the needed access. So if your service only need to read, then only assign the Service Identity to **Cosmos DB Account Reader**. For more information about the importance of **least privilege access,** see [lower exposure of privileged accounts](../security/fundamentals/identity-management-best-practices.md#lower-exposure-of-privileged-accounts).
50
+
> When assigning roles, only assign the needed access. So if your service only need to read, then only assign the Service Managed Identity to **Cosmos DB Account Reader**. For more information about the importance of **least privilege access,** see [lower exposure of privileged accounts](../security/fundamentals/identity-management-best-practices.md#lower-exposure-of-privileged-accounts).
51
51
52
52
For our scenario, we'll read the sale receipt documents, summarize them, and then write back that summary to Cosmos DB. Since we need write access, we'll use the **DocumentDB Account Contributor** role.
53
53
@@ -61,15 +61,15 @@ For our scenario, we'll read the sale receipt documents, summarize them, and the
61
61

* **Assign access to** - Under the Select **Systemassigned managed identity** subsection, select **Function App**.
65
-
* **Select** - The pane will be populated with all the function apps, in your subscription, that have a **System Managed Identity**. In our case I select the **SummaryService** function app:
64
+
* **Assign access to** - Under the Select **System-assigned managed identity** subsection, select **Function App**.
65
+
* **Select** - The pane will be populated with all the function apps, in your subscription, that have a **Managed System Identity**. In our case I select the **SummaryService** function app:
66
66

67
67
68
68
1. Select the function app and click **Save**.
69
69
70
70
## Programmatically access the Cosmos DB keys from the Azure Function
71
71
72
-
Now we have a function app that has a system managed identity. That identity is given the **DocumentDB Account Contributor** role in the Cosmos DB permissions. The **Function App** code below will get the needed Cosmos DB Keys, create a CosmosClient, and run the summarization business logic.
72
+
Now we have a function app that has a system-assigned managed identity. That identity is given the **DocumentDB Account Contributor** role in the Cosmos DB permissions. The **Function App** code below will get the needed Cosmos DB Keys, create a CosmosClient, and run the summarization business logic.
73
73
74
74
We'll be using to get the Cosmos DB Keys is the [List Keys API](https://docs.microsoft.com/rest/api/cosmos-db-resource-provider/DatabaseAccounts/ListKeys).
75
75
@@ -88,7 +88,7 @@ namespace SummarizationService
88
88
}
89
89
```
90
90
91
-
The library we'll use to get our Service Managed token is [Microsoft.Azure.Services.AppAuthentication](https://www.nuget.org/packages/Microsoft.Azure.Services.AppAuthentication). You can find other ways to get the token and more information about the Microsoft.Azure.Service.AppAuthentication library by reading up on [Service To Service Authentication](../key-vault/service-to-service-authentication.md).
91
+
The library we'll use to get our System-Assigned Managed Identity token is [Microsoft.Azure.Services.AppAuthentication](https://www.nuget.org/packages/Microsoft.Azure.Services.AppAuthentication). You can find other ways to get the token and more information about the Microsoft.Azure.Service.AppAuthentication library by reading up on [Service To Service Authentication](../key-vault/service-to-service-authentication.md).
You are now ready to [deploy your Azure Function.](../azure-functions/functions-create-first-function-vs-code.md)
187
187
188
188
> [!IMPORTANT]
189
-
> If you want to [assign the **Cosmos DB Account Reader**](#grant-the-system-identity-access-to-your-cosmos-db) role, you will need to use the read only [List Keys api](https://docs.microsoft.com/rest/api/cosmos-db-resource-provider/DatabaseAccounts/ListReadOnlyKeys). This would only populate the read only keys on the DatabaseAccountListKeysResult class.
189
+
> If you want to [assign the **Cosmos DB Account Reader**](#grant-the-system-assigned-managed-identity-access-to-your-cosmos-db) role, you will need to use the read only [List Keys api](https://docs.microsoft.com/rest/api/cosmos-db-resource-provider/DatabaseAccounts/ListReadOnlyKeys). This would only populate the read only keys on the DatabaseAccountListKeysResult class.
0 commit comments