Azure PostgreSQL (Managed Identity)

Last modified on January 3, 2024

Overview

This guide describes how to set up managed identities in the Microsoft Azure portal and set up StrongDM to use them to connect to Azure Database for PostgreSQL. The Azure PostgreSQL (Managed Identity) datasource type supports both user-assigned and system-assigned managed identities to authenticate to Azure Database for PostgreSQL.

Prerequisites

  • Ensure that you have access to an Azure subscription with appropriate permissions to create user-assigned managed identities.
  • Have an Azure Virtual Machine (VM) with a StrongDM gateway or relay installed on it.
  • Have an Azure account with the Virtual Machine Contributor and Managed Identity Operator role assignments in order to assign managed identities to your VM. Note that no other Microsoft Entra (formerly Azure AD) directory role assignments are required.
  • Have at least one user-assigned managed identity already created, so you can assign it to the VM.
  • Meet the following requirements for adding a datasource in the StrongDM Admin UI:
    • Properly configure an account for your database resource. If you choose to store credentials for the resource with StrongDM, have those credentials ready. When not using StrongDM, set up a Secret Store integration and be able to enter the location of the secrets required to access the resource.
    • The hostname or endpoint you enter for your resource must be accessible by at least one gateway or relay.

Azure Setup

The following steps provide general instructions on what to do within Azure. For more detailed information, please consult Microsoft Azure documentation:

User-assigned managed identity

If using a user-assigned managed identity, follow these steps.

  1. Sign in to the Azure portal. You must use an account associated with the Azure subscription that contains the Azure VM that hosts your gateway or relay.
  2. Assign a user-assigned managed identity to your VM.
  3. Copy the client ID of that user-assigned managed identity for use in later steps.
  4. Create a PostgreSQL user for the user-assigned managed identity. This can be done for Azure Database for PostgreSQL Single Server or Flexible Server.
  5. Set up roles and permissions (for example, read or readwrite) on your database for the managed identity. This must be done so that the StrongDM gateway or relay can connect to it using the managed identity assigned to the gateway or relay’s VM.

System-assigned managed identity

If using a system-assigned managed identity, follow these steps.

  1. Sign in to the Azure portal using an account associated with the Azure subscription that contains the Azure VM that hosts your gateway or relay.
  2. If the VM was provisioned without a system-assigned managed identity, enable the system-assigned managed identity by changing its status to On.
  3. Find the client ID of the system-assigned managed identity and copy it for use in later steps. The client ID may be obtained by using the Azure CLI, not the Azure portal, with az ad sp list --display-name <VM_NAME> --query [*].appId --out tsv.
  4. Create a PostgreSQL user for the managed identity. This can be done for Azure Database for PostgreSQL Single Server or Azure Database for PostgreSQL Flexible Server. Note that the “managed identity name” for the system-assigned identity is the name of the VM.
  5. Set up roles and permissions (for example, read or readwrite) on your database for the managed identity. This must be done so that the StrongDM gateway or relay can connect to it using the managed identity assigned to the gateway or relay’s VM.

StrongDM Admin UI Setup

To add Azure PostgreSQL (Managed Identity) as a StrongDM datasource in the Admin UI, use the following steps.

  1. Log in to the Admin UI.

  2. Go to Infrastructure > Datasources.

  3. Click Add datasource.

  4. Select Azure PostgreSQL (Managed Identity) as the Datasource Type and set other configuration properties for your new database resource.

    Add Azure PostgreSQL Datasource (Managed Identity)
    Add Azure PostgreSQL Datasource (Managed Identity)
  5. Complete all required fields.

  6. Click Create to save the resource.

  7. Click the resource name to view status, diagnostic information, and setting details.

Resource properties

Configuration properties are visible when you add a datasource or when you click to view its settings. The following table describes the settings available for your Azure PostgreSQL (Managed Identity) resource.

PropertyRequirementDescription
Display NameRequiredMeaningful name to display the resource throughout StrongDM; exclude special characters like quotes (") or angle brackets (< or >)
Datasource TypeRequiredSelect Azure PostgreSQL (Managed Identity)
HostnameRequiredHostname for your Azure PostgreSQL database resource; must be accessible to a gateway or relay
PortRequiredPort to use when connecting to your Azure PostgreSQL database; default port value is 5432
Port OverrideRead onlyAutomatically generated with a value between 1024-59999 as long as that port is not used by another resource; preferred port can be modified later under Settings > Port Overrides
DatabaseRequiredDatabase name you would like to connect to using this datasource
Secret StoreOptionalCredential store location; defaults to Strong Vault; learn more about Secret Store options
UsernameRequiredUsername of the PostgreSQL user for your managed identity, which you created during Azure setup
Client IDRequiredClient ID of your managed identity in the Azure portal
Username (path)RequiredPath to the secret in your Secret Store location (for example, path/to/credential?key=optionalKeyName where key argument is optional); required when using a non-StrongDM Secret Store type
Client ID (path)RequiredPath to the secret in your Secret Store location (for example, path/to/credential?key=optionalKeyName where key argument is optional); required when using a non-StrongDM Secret Store type
Override DatabaseOptionalBy default, StrongDM limits all connections to the configured database. Uncheck the box to disable this option. If this option is deselected, the value entered in the Database field is only used for healthchecks, not for user connections. When accessing the database via StrongDM, users need to explicitly pass the database name they wish to connect to in the connection string. If they do not, the value of the Username field is passed in as the database name. This is the default behavior of the database type.
Use Azure Single Server UsernamesOptionalIf selected, the hostname is appended to the username when interacting with a database.azure.com address
Resource TagsOptionalResource tags consisting of key-value pairs <KEY>=<VALUE> (for example, env=dev)

Secret Store options

By default, datasource credentials are stored in StrongDM. However, these credentials can also be saved in a secrets management tool.

Non-StrongDM options appear in the Secret Store dropdown if they are created under Network > Secret Stores. When you select another Secret Store type, its unique properties display. For more details, see Configure Secret Store Integrations.

Resource status

After a resource is created, the Admin UI displays that resource as unhealthy until the health checks run successfully. When the resource is ready, the Health icon indicates a positive, green status.

Datasource Ready
Datasource Ready

When the resource does not display a positive status, click the resource name to go to the Diagnostics tab and check for errors.