【发布时间】:2021-07-16 21:16:04
【问题描述】:
我正在尝试通过 Az Powershell module 将用户分配的身份设置为 azure Web 应用程序
这是我对 Set-AzResource 的尝试,它不起作用
$webApp = Get-AzWebApp -Name "somewebapp" -ResourceGroupName $ResourceGroupName
$site = Get-AzResource -Id $webApp.Id
$appIdentity = Get-AzUserAssignedIdentity -ResourceGroupName $ResourceGroupName -Name "someid"
$appIdentity2 = Get-AzUserAssignedIdentity -ResourceGroupName $ResourceGroupName -Name "someotherid"
$site.Identity.Type = "UserAssigned"
$site.Identity.UserAssignedIdentities = New-Object "System.Collections.Generic.Dictionary[System.String,Microsoft.Azure.Management.ResourceManager.Models.IdentityUserAssignedIdentitiesValue]"
$site.Identity.UserAssignedIdentities[$appIdentity.Id] = New-Object "Microsoft.Azure.Management.ResourceManager.Models.IdentityUserAssignedIdentitiesValue" -ArgumentList $appIdentity.ClientId, $appIdentity.PrincipalId
$site.Identity.UserAssignedIdentities[$appIdentity2.Id] = New-Object "Microsoft.Azure.Management.ResourceManager.Models.IdentityUserAssignedIdentitiesValue" -ArgumentList $appIdentity2.ClientId, $appIdentity2.PrincipalId
$site | Set-AzResource -Force
我看到的问题是Set-AzResource 只在 HTTP 请求的正文中发送“properties”属性,而忽略了“identity”属性:
{
"properties": {
"name": "somewebapp",
"state": "Running",
...
}
}
如何通过 Az powershell 模块在 Web 应用程序上设置用户分配的身份? Set-AzWebApp 也没有任何参数(-AssignIdentity 参数用于系统分配的标识)。
作为参考,使用 azure cli 执行此操作确实工作:
az webapp identity assign --resource-group "rg-someresourcegroup" --name "somewebapp" --identities @($appIdentity.Id, $appIdentity2.Id)
编辑:我找到了this issue,这似乎证实了我的怀疑,确实不支持。
【问题讨论】:
标签: azure powershell