แก้ไข

แชร์ผ่าน


Configure data encryption

APPLIES TO: Azure Database for PostgreSQL - Flexible Server

This article provides step-by-step instructions to configure data encryption for an Azure Database for PostgreSQL flexible server.

Important

Selection of system or customer managed encryption key for data encryption of an Azure Database for PostgreSQL flexible server, can only be made when the server is deployed.

In this article, you learn how to create a new server and configure its data encryption options. For existing servers, whose data encryption is configured to use customer managed encryption key, you learn:

  • How to select a different user assigned managed identity with which the service accesses the encryption key.
  • How to specify a different encryption key or how to rotate the encryption key currently used for data encryption.

To learn about data encryption in the context of Azure Database for PostgreSQL - Flexible Server, see the data encryption.

Configure data encryption with system managed key during server provisioning

Using the Azure portal:

  1. During provisioning of a new instance of Azure Database for PostgreSQL Flexible Server, in the Security tab.

    Screenshot showing how to get to the Security tab, from where you can configure data encryption settings.

  2. In the Data encryption key, select the Service-managed key radio button.

    Screenshot showing how to select the system managed encryption key during server provisioning.

  3. If you enable geo-redundant backup storage to be provisioned together with the server, the aspect of the Security tab changes slightly because the server uses two separate encryption keys. One for the primary region in which you're deploying your server, and one for the paired region to which the server backups are asynchronously replicated.

    Screenshot showing how to select the system managed encryption key during server provisioning, when the server is enabled for geo-redundant backup storage.

Configure data encryption with customer managed key during server provisioning

Using the Azure portal:

  1. Create one user assigned managed identity, if you don't have one yet. If your server has geo-redundant backups enabled, you need to create to different identities. Each of those identities is used to access each of the two data encryption keys.

    Note

    Although it isn't required, to maintain regional resiliency, we recommend that you create the user managed identity in the same region as your server. And if your server has geo-backup redundancy enabled, we recommend that the second user managed identity, used to access the data encryption key for geo-redundant backups, is created in the paired region of the server.

  2. Create one Azure Key Vault or create one Managed HSM, if you don't have one key store created yet. Make sure that you meet the requirements. Also, follow the recommendations before you configure the key store, and before you create the key and assign the required permissions to the user assigned managed identity. If your server has geo-redundant backups enabled, you need to create a second key store. That second key store is used to keep the data encryption key with which your backups copied to the paired region of the server are encrypted.

    Note

    The key store used to keep the data encryption key must be deployed in the same region as your server. And if your server has geo-backup redundancy enabled, the key store that keeps the data encryption key for geo-redundant backups must be created in the paired region of the server.

  3. Create one key in your key store. If your server has geo-redundant backups enabled, you need one key on each of the key stores. With one of these keys, we encrypt all your server's data (including all system and user databases, temporary files, server logs, write-ahead log segments, and backups). With the second key, we encrypt the copies of the backups which are asynchronously copied over the paired region of your server.

  4. During provisioning of a new instance of Azure Database for PostgreSQL Flexible Server, in the Security tab.

    Screenshot showing how to get to the Security tab, from where you can configure data encryption settings.

  5. In the Data encryption key, select the Service-managed key radio button.

    Screenshot showing how to select the customer managed encryption key during server provisioning.

  6. If you enable geo-redundant backup storage to be provisioned together with the server, the aspect of the Security tab changes slightly because the server uses two separate encryption keys. One for the primary region in which you're deploying your server, and one for the paired region to which the server backups are asynchronously replicated.

    Screenshot showing how to select the customer managed encryption key during server provisioning, when the server is enabled for geo-redundant backup storage.

  7. In User assigned managed identity, select Change identity.

    Screenshot showing how to select the user assigned managed identity to access the data encryption key for the data of the server location.

  8. Among the list of user assigned managed identities, select the one you want your server to use to access the data encryption key stored in an Azure Key Vault.

    Screenshot showing how to select the user assigned managed identity with which the server accesses the data encryption key.

  9. Select Add.

    Screenshot showing the location of the Add button to assign the identity with which the server accesses the data encryption key.

  10. Select Select a key.

    Screenshot showing how to select a data encryption key.

  11. Subscription is automatically populated with the name of the subscription on which your server is about to be created. The key store that keeps the data encryption key must exist in the same subscription as the server.

    Screenshot showing how to select the subscription in which the key store should exist.

  12. In Key store type, select the radio button corresponding to the type of key store in which you plan to store the data encryption key. In this example, we choose Key vault, but the experience is similar if you choose Managed HSM.

    Screenshot showing how to select the type of store that keeps the data encryption key.

  13. Expand Key vault (or Managed HSM, if you selected that storage type), and select the instance where the data encryption key exists.

    Screenshot showing how to select the key store that keeps the data encryption key.

    Note

    When you expand the drop-down box, it shows No available items. It takes a few seconds until it lists all the instances of key vault which are deployed in the same region as the server.

  14. Expand Key, and select the name of the key that you want to use for data encryption.

    Screenshot showing how to select the data encryption key.

  15. Expand Version, and select the identifier of the version of the key that you want to use for data encryption.

    Screenshot showing how to select the version to use of the data encryption key.

  16. Select Select.

    Screenshot showing how to select the chose key.

  17. Configure all other settings of the new server and select Review + create.

    Screenshot showing how to complete creation of server.

Configure data encryption with customer managed key on existing servers

The only point at which you can decide if you want to use a system managed key or a customer managed key for data encryption, is at server creation. Once you make that decision and create the server, you can't switch between the two options. The only alternative, if you want to change from one to the other, requires restoring any of the backups available of server onto a new server. While configuring the restore, you're allowed to change the data encryption configuration of the new server.

For existing servers that were deployed with data encryption using a customer managed key, you're allowed to do several configuration changes. Things that can be changed are the references to the keys used for encryption, and references to the user assigned managed identities used by the service to access the keys kept in the key stores.

You must update references that your Azure Database for PostgreSQL flexible server has to a key:

  • When the key stored in the key store is rotated, either manually or automatically.
  • When you want to use the same or a different key stored in a different key store.

You must update the user assigned managed identities which are used by your Azure Database for PostgreSQL flexible server to access the encryption keys:

  • Whenever you want to use a different identity

Using the Azure portal:

  1. Select your Azure Database for PostgreSQL flexible server.

  2. In the resource menu, under the Security section, select Data encryption.

    Screenshot showing how to get to the Data encryption for an existing server.

  3. To change the user assigned managed identity with which the server accesses the key store in which the key is kept, expand the User assigned managed identity drop-down, and select any of the identities available.

    Screenshot showing how to select one of the user assigned managed identities associated to the server.

    Note

    Identities shown in the combo-box are only the ones that your Azure Database for PostgreSQL flexible server was assigned. Although it isn't required, to maintain regional resiliency, we recommend that you select user managed identities in the same region as your server. And if your server has geo-backup redundancy enabled, we recommend that the second user managed identity, used to access the data encryption key for geo-redundant backups, exists in the paired region of the server.

  4. If the user assigned managed identity that you want to use to access the data encryption key isn't assigned to your Azure Database for PostgreSQL flexible server, and it doesn't even exist as an Azure resource with its corresponding object in Microsoft Entra ID, you can create it by selecting Create.

    Screenshot showing how to create a new user assigned managed identities in Azure and Microsoft Entra ID, automatically assign it to your Azure Database for PostgreSQL flexible server, and use it to access the data encryption key.

  5. In the Create User Assigned Managed Identity panel, complete the details of the user assigned managed identity that you want to create, and automatically assign to your Azure Database for PostgreSQL flexible server to access the data encryption key.

    Screenshot showing how to provide the details for the new user assigned managed identity.

  6. If the user assigned managed identity that you want to use to access the data encryption key isn't assigned to your Azure Database for PostgreSQL flexible server, but it does exist as an Azure resource with its corresponding object in Microsoft Entra ID, you can assign it by selecting Select.

    Screenshot showing how to select an existing user assigned managed identity in Azure and Microsoft Entra ID, automatically assign it to your Azure Database for PostgreSQL flexible server, and use it to access the data encryption key.

  7. Among the list of user assigned managed identities, select the one you want your server to use to access the data encryption key stored in an Azure Key Vault.

    Screenshot showing how to select an existing user assigned managed identity to assign it to your Azure Database for PostgreSQL flexible server, and use it to access the data encryption key.

  8. Select Add.

    Screenshot showing how to add the selected user assigned managed identity.

  9. If you rotate the key, or you want to use a different key, you must update your Azure Database for PostgreSQL flexible server so that it points to the new key version or new key. To do that, you can copy the resource identifier of the key, and paste it in the Key identifier box.

    Screenshot showing where to paste the resource identifier of the new key or ne key version that the server must use for data encryption.

  10. If the user accessing Azure portal has permissions to access the key stored in the key store, you can use an alternative approach to choose the new key or new key version. To do that, in Key selection method, select the Select a key radio button.

    Screenshot showing how to enable the user friendlier method to choose the data encryption key to use for data encryption.

  11. Select Select key.

    Screenshot showing how to select a data encryption key.

  12. Subscription is automatically populated with the name of the subscription on which your server is about to be created. The key store that keeps the data encryption key must exist in the same subscription as the server.

    Screenshot showing how to select the subscription in which the key store should exist.

  13. In Key store type, select the radio button corresponding to the type of key store in which you plan to store the data encryption key. In this example, we choose Key vault, but the experience is similar if you choose Managed HSM.

    Screenshot showing how to select the type of store that keeps the data encryption key.

  14. Expand Key vault (or Managed HSM, if you selected that storage type), and select the instance where the data encryption key exists.

    Screenshot showing how to select the key store that keeps the data encryption key.

    Note

    When you expand the drop-down box, it shows No available items. It takes a few seconds until it lists all the instances of key vault which are deployed in the same region as the server.

  15. Expand Key, and select the name of the key that you want to use for data encryption.

    Screenshot showing how to select the data encryption key.

  16. Expand Version, and select the identifier of the version of the key that you want to use for data encryption.

    Screenshot showing how to select the version to use of the data encryption key.

  17. Select Select.

    Screenshot showing how to select the chose key.

  18. Once satisfied with the changes made, select Save.

    Screenshot showing how to save the changes made to data encryption configuration.