此浏览器不再受支持。
请升级到 Microsoft Edge 以使用最新的功能、安全更新和技术支持。
你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
备注
访问此页面需要授权。 可以尝试登录或更改目录。
访问此页面需要授权。 可以尝试更改目录。
本文提供了为 Azure Database for PostgreSQL 灵活服务器实例启用或禁用系统分配的托管标识的分步说明。
使用 Azure 门户:
在门户中找到自己的服务器(如果尚未将其打开)。 实现此目的的一种方法是在搜索栏中键入服务器的名称。 当显示具有匹配名称的资源时,选择该资源。
在资源菜单上的“安全性”下,选择“标识”。
在“系统分配的托管标识”部分,选择“启用”。
选择“保存”。
如果服务器的数据加密配置为使用客户管理的密钥,则在启用服务器的系统分配托管标识后,不支持禁用该托管标识。 因此,如果检测到这种情况,将要求你确认是否要启用服务器的系统分配托管标识。
该过程完成后,一个通知会通知你系统分配的托管标识已启用。
az postgres flexible-server update 命令尚不提供启用和禁用系统分配的托管标识的内置支持。 作为一种解决方法,你可以使用 az rest 命令直接调用服务器 - 更新 REST API。
# Enable system assigned managed identity subscriptionId=<subscription-id> resourceGroup=<resource-group> server=<server> result=$(az postgres flexible-server show --resource-group $resourceGroup --name $server --query "identity.type" --output tsv) if [ -z "$result" ]; then az rest --method patch --url https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/$server?api-version=2024-08-01 --body '{"identity":{"type":"SystemAssigned"}}' elif [ "$result" == "UserAssigned" ]; then az rest --method patch --url https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/$server?api-version=2024-08-01 --body '{"identity":{"type":"SystemAssigned,UserAssigned"}}' else echo "System Assigned Managed identity is already enabled." fi
在“系统分配的托管标识”部分,选择“禁用”。
该过程完成后,一个通知会通知你系统分配的托管标识已禁用。
# Disable system assigned managed identity subscriptionId=<subscription-id> resourceGroup=<resource-group> server=<server> result=$(az postgres flexible-server show --resource-group $resourceGroup --name $server --query "identity.type" --output tsv) if [ "$result" == "SystemAssigned" ]; then az rest --method patch --url https://management.azure.com/subscriptions/$subscriptionId/resourceGroups/$resourceGroup/providers/Microsoft.DBforPostgreSQL/flexibleServers/$server?api-version=2024-08-01 --body '{"identity":{"type":"None"}}' elif [ "$result" == "SystemAssigned,UserAssigned" ]; then echo "System Assigned Managed identity cannot be disabled as the instance has User Assigned Managed identities assigned." else echo "System Assigned Managed identity is already disabled." fi
在资源菜单中,选择“概述”
选择“JSON 视图”。
在打开的“资源 JSON”面板中,找到“标识”属性,在其中可以找到系统分配的托管标识的 principalId 和 tenantId。
# Show the system assigned managed identity resourceGroup=<resource-group> server=<server> az postgres flexible-server identity list \ --resource-group $resourceGroup \ --server-name $server \ --query "{principalId:principalId, tenantId:tenantId}" \ --output table
在门户中找到“企业应用程序”服务(如果它尚未打开)。 实现此目的的一种方法是在搜索栏中输入其名称。 当显示具有匹配名称的服务时,选择该服务。
选择“应用程序类型 == 托管标识”。
在 按应用程序名称或对象 ID 搜索 文本框中提供您的 Azure Database for PostgreSQL 灵活服务器实例的名称。
# Verify the system assigned managed identity server=<server> az ad sp list --display-name $server
此页面是否有帮助?
Need help with this topic?
Want to try using Ask Learn to clarify or guide you through this topic?