|
| 1 | +--- |
| 2 | +title: Identity |
| 3 | +description: Learn about Managed Idenities in the Flexible Server deployment option for Azure Database for PostgreSQL - Flexible Server. |
| 4 | +author: kabharati |
| 5 | +ms.author: kabharati |
| 6 | +ms.reviewer: maghan |
| 7 | +ms.date: 07/09/2024 |
| 8 | +ms.service: postgresql |
| 9 | +ms.subservice: flexible-server |
| 10 | +ms.topic: conceptual |
| 11 | +ms.custom: |
| 12 | + - mvc |
| 13 | + - mode-other |
| 14 | +ms.devlang: python |
| 15 | +--- |
| 16 | + |
| 17 | +# Managed Identity in Azure Database for PostgreSQL - Flexible Server |
| 18 | + |
| 19 | +[!INCLUDE [applies-to-postgresql-flexible-server](~/reusable-content/ce-skilling/azure/includes/postgresql/includes/applies-to-postgresql-flexible-server.md)] |
| 20 | + |
| 21 | +A common challenge for developers is the management of secrets, credentials, certificates, and keys used to secure communication between services. Managed identities eliminate the need for developers to manage these credentials. |
| 22 | + |
| 23 | +While developers can securely store the secrets in Azure Key Vault, services need a way to access Azure Key Vault. Managed identities provide an automatically managed identity in Microsoft Entra ID for applications to use when connecting to resources that support Microsoft Entra authentication. Applications can use managed identities to obtain Microsoft Entra tokens without having to manage any credentials. |
| 24 | + |
| 25 | +Here are some of the benefits of using managed identities: |
| 26 | + |
| 27 | +- You don't need to manage credentials. Credentials aren’t even accessible to you. |
| 28 | +- You can use managed identities to authenticate to any resource that supports Microsoft Entra authentication including your own applications. |
| 29 | +- Managed identities can be used at no extra cost. |
| 30 | + |
| 31 | +## Managed identity types |
| 32 | + |
| 33 | +There are two types of managed identities: |
| 34 | + |
| 35 | +- **System-assigned**. Some Azure resources, such as virtual machines, Azure Database for PostgreSQL Flexible Server allows you to enable a managed identity directly on the resource. When you enable a system-assigned managed identity: |
| 36 | + - A service principal of a special type is created in Microsoft Entra ID for the identity. The service principal is tied to the lifecycle of that Azure resource. When the Azure resource is deleted, Azure automatically deletes the service principal for you. |
| 37 | + - By design, only that Azure resource can use this identity to request tokens from Microsoft Entra ID. |
| 38 | + - You authorize the managed identity to have access to one or more services. |
| 39 | + - The name of the system-assigned service principal is always the same as the name of the Azure resource it's created for. |
| 40 | + |
| 41 | + |
| 42 | +- **User-assigned**. You may also create a managed identity as a standalone Azure resource. You can create a user-assigned managed identity and assign it to one or more Azure Resources. When you enable a user-assigned managed identity: |
| 43 | + - A service principal of a special type is created in Microsoft Entra ID for the identity. The service principal is managed separately from the resources that use it. |
| 44 | + - Multiple resources can utilize user-assigned identities. |
| 45 | + - You authorize the managed identity to have access to one or more services. |
| 46 | + |
| 47 | + |
| 48 | + |
| 49 | +## How to enable System Assigned Managed Identity on your Flexible Server |
| 50 | + |
| 51 | +## Azure portal |
| 52 | + |
| 53 | +Follow these steps to enable System Assigned Managed Identity on your Azure Database for PostgreSQL flexible server instance. |
| 54 | + |
| 55 | +1. In the [Azure portal](https://portal.azure.com/), select your existing Azure Database for PostgreSQL flexible server instance for which you want to enable system assigned managed identity. |
| 56 | + |
| 57 | +2. On the Azure Database for PostgreSQL flexible server page, select **Identity** |
| 58 | + |
| 59 | +3. In the **Identity** section, select **On** radio button. |
| 60 | + |
| 61 | +4. Select **Save** to apply the changes. |
| 62 | + |
| 63 | + |
| 64 | + |
| 65 | +5. A notification confirms that system assigned managed identity is enabled. |
| 66 | + |
| 67 | +## ARM template |
| 68 | + |
| 69 | +Here is the ARM template to enable system assigned managed identity. You can use the 2023-06-01-preview or the latest available API. |
| 70 | + |
| 71 | +```json |
| 72 | +{ |
| 73 | + "resources": [ |
| 74 | + { |
| 75 | + "apiVersion": "2023-06-01-preview", |
| 76 | + "identity": { |
| 77 | + "type": "SystemAssigned" |
| 78 | + }, |
| 79 | + "location": "Region name", |
| 80 | + "name": "flexible server name", |
| 81 | + "type": "Microsoft.DBforPostgreSQL/flexibleServers" |
| 82 | + } |
| 83 | + ] |
| 84 | +} |
| 85 | + ``` |
| 86 | + |
| 87 | +To disable system assigned managed identity change the type to **None** |
| 88 | + |
| 89 | +```json |
| 90 | +{ |
| 91 | + "resources": [ |
| 92 | + { |
| 93 | + "apiVersion": "2023-06-01-preview", |
| 94 | + "identity": { |
| 95 | + "type": "None" |
| 96 | + }, |
| 97 | + "location": "Region Name", |
| 98 | + "name": "flexible server name", |
| 99 | + "type": "Microsoft.DBforPostgreSQL/flexibleServers" |
| 100 | + } |
| 101 | + ] |
| 102 | +} |
| 103 | + ``` |
| 104 | +## How to verify the newly created System Assigned Managed Identity on your Flexible Server |
| 105 | + |
| 106 | +You can verify the managed identity created by going to **Enterprise Applications** |
| 107 | + |
| 108 | +1. Choose **Application Type == Managed Identity** |
| 109 | + |
| 110 | +2. Provide your flexible server name in **Search by application name or Identity** as shown in the screenshot. |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | + |
| 116 | +## Related content |
| 117 | + |
| 118 | +- [Microsoft Entra authentication](../concepts-aad-authentication.md) |
| 119 | +- [Firewall rules for IP addresses](concepts-firewall-rules.md) |
| 120 | +- [Private access networking with Azure Database for PostgreSQL - Flexible Server](concepts-networking.md) |
0 commit comments