我有一个Powershell脚本,用于部署 Azure云服务(经典)。直到今天,已为应用程序用户分配了Contributor
角色。加强安全性的一部分是,我们撤消了此Contributor
角色,因为它作用范围太广。
部署过程的一部分是使用Add-AzureRmAutoscaleSetting
更新生产位置的AutoScaling设置:
Add-AzureRmAutoscaleSetting -Location "East US" -Name $scalingName -ResourceGroupName $resourceGroup -TargetResourceId $targetResourceId -AutoscaleProfile $autoscaleProfile
由于不再为Azure用户分配Contributor
的角色,因此此命令现在失败,说明它是“禁止的”:
Add-AzureRmAutoscaleSetting : Exception type: ErrorResponseException, Message: Null/Empty, Code: Null, Status code:Forbidden, Reason phrase: Forbidden
At C:\Path\AzureRMTools.psm1:131 char:5
+ Add-AzureRmAutoscaleSetting -Location "East US" -Name $scalingNam ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : CloseError: (:) [Add-AzureRmAutoscaleSetting], PSInvalidOperationException
+ FullyQualifiedErrorId : Microsoft.Azure.Commands.Insights.Autoscale.AddAzureRmAutoscaleSettingCommand
我尝试为用户分配许多不同的角色(我认为角色将具有此权限)-但是似乎没有一个角色允许我执行此角色。
我想知道哪个角色将包含此权限?如果没有,则可以创建一个新角色以允许执行命令。
谢谢
答案 0 :(得分:2)
任何允许Microsoft.insights/autoscalesettings/write
在您感兴趣的范围内的角色都可以正常工作。
以及您尝试将自动缩放与之相关的资源的权限(写入)
答案 1 :(得分:2)
感谢@4c74356b41向正确的方向移动。
似乎没有包含Microsoft.insights/autoscalesettings/write
权限的Roles中的任何内部版本,因此在this tutorial之后,我创建了一个新Role。
这是我创建的json
文件:
{
"Name": "Microsoft Insights Contributor",
"IsCustom": true,
"Description": "Allows the creation, edition, and deletion of AutoScaling rules from Microsoft.Insights",
"Actions": [
"Microsoft.Insights/*",
"Microsoft.ClassicCompute/*"
],
"NotActions": [],
"DataActions": [],
"NotDataActions": [],
"AssignableScopes": [
"/subscriptions/00000000-0000-0000-0000-000000000000"
]
}
然后执行以下命令,将其添加到您的Azure订阅中:
New-AzureRmRoleDefinition -InputFile '.\Microsoft Insights Contributor.json'
希望这对其他人有帮助
注意:在使用Azure云服务(经典)时,我还需要对某些Microsoft.ClassicCompute
资源的权限
答案 2 :(得分:0)
要扩展先前的答案,以下是将AutoScale绑定到Classic Cloud Service时所需的特定角色:
"Microsoft.Insights/AutoscaleSettings/Read",
"Microsoft.Insights/AutoscaleSettings/Write",
"Microsoft.ClassicCompute/domainNames/slots/roles/write",
"Microsoft.ClassicCompute/domainNames/slots/roles/read"