Skip to content

Commit 28add04

Browse files
Merge pull request #263654 from niklarin/aad5
Managed identities for Azure Cosmos DB for PostgreSQL
2 parents 573a754 + bc6f062 commit 28add04

File tree

2 files changed

+19
-29
lines changed

2 files changed

+19
-29
lines changed

articles/cosmos-db/postgresql/concepts-authentication.md

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,13 @@ ms.author: nlarin
66
ms.service: cosmos-db
77
ms.subservice: postgresql
88
ms.topic: conceptual
9-
ms.date: 11/07/2023
9+
ms.date: 02/06/2024
1010
---
1111

1212
# Microsoft Entra ID and PostgreSQL authentication with Azure Cosmos DB for PostgreSQL
1313

1414
[!INCLUDE [PostgreSQL](../includes/appliesto-postgresql.md)]
1515

16-
> [!IMPORTANT]
17-
> Microsoft Entra ID (formerly Azure Active Directory) authentication in Azure Cosmos DB for PostgreSQL is currently in preview.
18-
> This preview version is provided without a service level agreement, and it's not recommended
19-
> for production workloads. Certain features might not be supported or might have constrained
20-
> capabilities.
21-
>
22-
> You can see a complete list of other new features in [preview features](product-updates.md#features-in-preview).
23-
2416
Azure Cosmos DB for PostgreSQL supports PostgreSQL authentication and integration with Microsoft Entra ID. Each Azure Cosmos DB for PostgreSQL cluster is created with native PostgreSQL authentication enabled and one built-in PostgreSQL role named `citus`. You can add more native PostgreSQL roles after cluster provisioning is completed.
2517

2618
You can also enable Microsoft Entra ID (formerly Azure Active Directory) authentication on a cluster in addition to the PostgreSQL authentication method or instead of it. You can configure authentication methods on each Azure Cosmos DB for PostgreSQL cluster independently. If you need to change authentication method, you can do it at any time after cluster provisioning is completed. Changing authentication methods doesn't require cluster restart.
@@ -62,8 +54,9 @@ Notably, the `citus` role has some restrictions:
6254
`citus` role can't be deleted but would be disabled if 'Microsoft Entra ID authentication only' authentication method is selected on cluster.
6355

6456
<a name='azure-active-directory-authentication-preview'></a>
57+
<a name='microsoft-entra-id-authentication-preview'></a>
6558

66-
## Microsoft Entra ID authentication (preview)
59+
## Microsoft Entra ID authentication
6760

6861
[Microsoft Entra ID](/entra/fundamentals/whatis) (formerly Azure Active Directory) authentication is a mechanism of connecting to Azure Cosmos DB for PostgreSQL using identities defined in Microsoft Entra ID. With Microsoft Entra ID authentication, you can manage database user identities and other Microsoft services in a central location, which simplifies permission management.
6962

@@ -79,9 +72,9 @@ Benefits of using Microsoft Entra ID include:
7972

8073
### Manage PostgreSQL access for Microsoft Entra ID principals
8174

82-
When Microsoft Entra ID authentication is enabled and Microsoft Entra ID principal is added as a Microsoft Entra ID administrator, the account gets the same privileges as [the `citus` role](#the-citus-role). The Microsoft Entra ID administrator sign-in can be a Microsoft Entra ID user, Service Principal or Managed Identity. Multiple Microsoft Entra ID administrators can be configured at any time and you can optionally disable PostgreSQL (password) authentication to the Azure Cosmos DB for PostgreSQL cluster for better auditing and compliance needs.
75+
When Microsoft Entra ID authentication is enabled and Microsoft Entra ID principal is added as a Microsoft Entra ID administrator, the account gets the same privileges as [the `citus` role](#the-citus-role). The Microsoft Entra ID administrator sign-in can be a Microsoft Entra ID user, Service Principal, or Managed Identity. Multiple Microsoft Entra ID administrators can be configured at any time and you can optionally disable PostgreSQL (password) authentication to the Azure Cosmos DB for PostgreSQL cluster for better auditing and compliance needs.
8376

84-
Additionally, any number of non-admin Microsoft Entra ID roles can be added to a cluster at any time once Microsoft Entra ID authentication is enabled. Database permissions for non-admin Microsoft Entra ID roles are managed similar to regular roles.
77+
Additionally, any number of nonadmin Microsoft Entra ID roles can be added to a cluster at any time once Microsoft Entra ID authentication is enabled. Database permissions for nonadmin Microsoft Entra ID roles are managed similar to regular roles.
8578

8679
<a name='connect-using-azure-ad-identities'></a>
8780

@@ -109,7 +102,7 @@ Once you've authenticated against the Microsoft Entra ID, you then retrieve a to
109102

110103
## Next steps
111104

112-
- Check out [Microsoft Entra ID limits and limitations in Azure Cosmos DB for PostgreSQL](./reference-limits.md#azure-active-directory-authentication)
105+
- Check out [Microsoft Entra ID limits and limitations in Azure Cosmos DB for PostgreSQL](./reference-limits.md#microsoft-entra-id-authentication)
113106
- [Learn how to configure authentication for Azure Cosmos DB for PostgreSQL clusters](./how-to-configure-authentication.md)
114107
- Set up private network access to the cluster nodes, see [Manage private access](./howto-private-access.md)
115108
- Set up public network access to the cluster nodes, see [Manage public access](./howto-manage-firewall-using-portal.md)

articles/cosmos-db/postgresql/how-to-configure-authentication.md

Lines changed: 13 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,21 +6,13 @@ ms.author: nlarin
66
ms.service: cosmos-db
77
ms.subservice: postgresql
88
ms.topic: how-to
9-
ms.date: 11/06/2023
9+
ms.date: 02/06/2024
1010
---
1111

1212
# Use Microsoft Entra ID and native PostgreSQL roles for authentication with Azure Cosmos DB for PostgreSQL
1313

1414
[!INCLUDE [PostgreSQL](../includes/appliesto-postgresql.md)]
1515

16-
> [!IMPORTANT]
17-
> Microsoft Entra ID (formerly Azure Active Directory) authentication in Azure Cosmos DB for PostgreSQL is currently in preview.
18-
> This preview version is provided without a service level agreement, and it's not recommended
19-
> for production workloads. Certain features might not be supported or might have constrained
20-
> capabilities.
21-
>
22-
> You can see a complete list of other new features in [preview features](product-updates.md#features-in-preview).
23-
2416
In this article, you configure authentication methods for Azure Cosmos DB for PostgreSQL. You manage Microsoft Entra ID admin users and native PostgreSQL roles for authentication with Azure Cosmos DB for PostgreSQL. You also learn how to use a Microsoft Entra ID token with Azure Cosmos DB for PostgreSQL.
2517

2618
An Azure Cosmos DB for PostgreSQL cluster is created with one built-in native PostgreSQL role named 'citus'. You can add more native PostgreSQL roles after cluster provisioning is completed.
@@ -33,9 +25,9 @@ You need to use Azure portal to configure authentication methods on an Azure Cos
3325
Complete the following items on your Azure Cosmos DB for PostgreSQL cluster to enable or disable Microsoft Entra ID authentication and native PostgreSQL authentication.
3426

3527
1. On the cluster page, under the **Cluster management** heading, choose **Authentication** to open authentication management options.
36-
1. In **Authentication methods** section, choose **PostgreSQL authentication only**, **Microsoft Entra ID authentication (preview)**, or **PostgreSQL and Microsoft Entra ID authentication (preview)** as the authentication method based on your requirements.
28+
1. In **Authentication methods** section, choose **PostgreSQL authentication only**, **Microsoft Entra ID authentication**, or **PostgreSQL and Microsoft Entra ID authentication** as the authentication method based on your requirements.
3729

38-
Once done proceed with [configuring Microsoft Entra ID authentication](#configure-azure-active-directory-authentication) or [adding native PostgreSQL roles](#configure-native-postgresql-authentication) on **Authentication** page.
30+
Once done proceed with [configuring Microsoft Entra ID authentication](#configure-azure-active-directory-authentication) or [adding native PostgreSQL roles](#configure-native-postgresql-authentication) on the same **Authentication** page.
3931

4032
<a name='configure-azure-active-directory-authentication'></a>
4133

@@ -54,7 +46,7 @@ Users need to be allowed to sign in to Azure Cosmos DB for PostgreSQL in the Mic
5446
1. Open 'Microsoft Entra ID' service.
5547
1. On the **Overview** page of Microsoft Entra ID service in the **Overview** section, search for 'b4fa09d8-5da5-4352-83d9-05c2a44cf431' application ID.
5648
1. Choose 'Azure Cosmos DB for PostgreSQL AAD Authentication' enterprise application in the search results.
57-
1. In the Azure Cosmos DB for PostgreSQL AAD Authentication enterprise application, choose **Properties** page.
49+
1. In the **Azure Cosmos DB for PostgreSQL AAD Authentication** enterprise application, choose **Properties** page.
5850
1. Set **Enabled for users to sign-in?** to **Yes** and save the change.
5951

6052
# [Azure CLI](#tab/cli)
@@ -64,11 +56,14 @@ az ad sp update --id b4fa09d8-5da5-4352-83d9-05c2a44cf431 --set accountEnabled=t
6456
```
6557
---
6658

59+
> [!NOTE]
60+
> Editing enterprise application's properties such as 'Enabled for users to sign-in' requires permissions granted to the Global Administrator, Cloud Application Administrator, or Application Administrator roles. See [the list of built-in Microsoft Entra roles](/entra/identity/role-based-access-control/permissions-reference).
61+
6762
### Add Microsoft Entra ID admins to Azure Cosmos DB for PostgreSQL cluster
6863

6964
To add or remove Microsoft Entra ID roles on cluster, follow these steps on **Authentication** page:
7065

71-
1. In **Microsoft Entra ID authentication (preview)** section, select **Add Microsoft Entra ID admins**.
66+
1. In **Microsoft Entra ID authentication** section, select **Add Microsoft Entra ID admins**.
7267
1. In **Select Microsoft Entra ID Admins** panel, select one or more valid Microsoft Entra ID user or enterprise application in the current AD tenant to be a Microsoft Entra ID administrator on your Azure Cosmos DB for PostgreSQL cluster.
7368
1. Use **Select** to confirm your choice.
7469
1. In the **Authentication** page, select **Save** in the toolbar to save changes or proceed with adding native PostgreSQL roles.
@@ -107,14 +102,16 @@ az login
107102

108103
The command opens a browser window to the Microsoft Entra ID authentication page. It requires you to give your Microsoft Entra ID user name and password.
109104

105+
The user account name you use to authenticate (for example, [email protected]) is the one the access token will be generated for in the next step.
106+
110107
<a name='retrieve-the-azure-ad-access-token'></a>
111108

112109
### Retrieve the Microsoft Entra ID access token
113110

114111
Use the Azure CLI to acquire an access token for the Microsoft Entra ID authenticated user to access Azure Cosmos for PostgreSQL. Here's an example:
115112

116113
```azurecli-interactive
117-
az account get-access-token --resource https://postgres.cosmos.azure.com
114+
az account get-access-token --resource https://token.postgres.cosmos.azure.com
118115
```
119116

120117
After authentication is successful, Microsoft Entra ID returns an access token for current Azure subscription:
@@ -129,7 +126,7 @@ After authentication is successful, Microsoft Entra ID returns an access token f
129126
}
130127
```
131128

132-
The TOKEN is a Base64 string. It encodes all the information about the authenticated user and is targeted to the Azure Cosmos DB for PostgreSQL service. The token is valid for at least 5 minutes with the maximum of 90 minutes. The expiresOn defines actual token expiration time.
129+
The TOKEN is a Base64 string. It encodes all the information about the authenticated user and is associated with the Azure Cosmos DB for PostgreSQL service. The token is valid for at least 5 minutes with the maximum of 90 minutes. The **expiresOn** defines actual token expiration time.
133130

134131
### Use a token as a password for signing in with client psql
135132

@@ -167,7 +164,7 @@ export PGPASSWORD=$(az account get-access-token --resource-type oss-rdbms --quer
167164
> or clear the PGPASSWORD variable value to enter the password interactively.
168165
> Authentication would fail with the wrong value in PGPASSWORD.
169166
170-
Now you can initiate a connection with Azure Cosmos DB for PostgreSQL as you usually would (without 'password' parameter in the command line):
167+
Now you can initiate a connection with Azure Cosmos DB for PostgreSQL using the Microsoft Entra ID user account that the access token was generated for. You would do it as you usually would with the user account as the user and without 'password' parameter in the command line:
171168

172169
```sql
173170
psql "host=mycluster.[uniqueID].postgres.cosmos.azure.com [email protected] dbname=[db_name] sslmode=require"

0 commit comments

Comments
 (0)