az webapp Identity show
命令:https://learn.microsoft.com/en-us/cli/azure/webapp/identity?view=azure-cli-latest#az-webapp-identity-show
将返回以下结果:
{
"principalId": null,
"tenantId": null,
"type": "UserAssigned",
"userAssignedIdentities": {
"/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx": {
"clientId": "xxx",
"principalId": "xxx"
}
}
}
现在我只想返回 /subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxx
值。如何使用 --query
选项过滤此值?我已经尝试过了
--query userAssignedIdentities
"/subscriptions/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx": {
"clientId": "xxx",
"principalId": "xxx"
}
}
但是要在这里获得第一把 key 还需要一些东西。什么?
最佳答案
使用以下 Azure CLI cmdlet
az webapp identity show -name <WebAppName> -g <ResoureGroupName> --query "keys(userAssignedIdentities)" -o tsv
或者,您可以使用以下 PowerShell cmdlet 提取分配给 Azure Web 应用的 userAssignedIdentities 的资源 ID。
$identity=Get-AzWebApp -Name <WebAppName> -ResourceGroupName "<ResourceGroupName>" | select -ExpandProperty Identity
$identity.UserAssignedIdentities.Keys
关于bash - az cli 选择对象的第一个值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73936430/