- Go to Azure Portal:
- Find Your PostgreSQL Flexible Server:
- Locate and select the Azure Database for PostgreSQL flexible server you want to configure.
- Configure Authentication:
- In the left menu, navigate to "Settings" and then click "Authentication."
- Choose "Azure Active Directory" as the authentication method.
- Set Azure AD Admin:
- Specify an Azure AD admin for the server. This admin will have superuser privileges on the PostgreSQL server.
- You can use an existing Azure AD user or create a new one.
- Save Changes:
- Save your changes to apply the Azure AD authentication settings.
- Restart Server (if needed):
- Depending on the changes, you may need to restart the PostgreSQL server for the new settings to take effect.
- Connect Using Azure AD Credentials:
- When connecting to the PostgreSQL server, use your Azure AD credentials for authentication. This typically involves providing the Azure AD username and password.
Or if you prefer using the CLI
Log in to Azure
az login
Set your subscription
az account set --subscription <your-subscription-id>
Set the admin user for Azure AD authentication
az postgres flexible-server update --resource-group <your-resource-group> --name <your-server-name> --admin-user <azure-ad-admin-username>
Enable Azure AD authentication
az postgres flexible-server update --resource-group <your-resource-group> --name <your-server-name> --authentication-mode "AzureADOnly"
Replace placeholders like <your-subscription-id>, <your-resource-group>, <your-server-name>, and <azure-ad-admin-username> with your actual details.