是否有任何标准角色可以授予在 Azure 资源组中启动/停止虚拟机的权限,而不授予创建权限或修改现有资源的权限?我在文档中没有找到,唯一的解决方案是创建自定义角色?
问问题
1532 次
1 回答
4
是的,唯一的解决方案是创建自定义角色,示例 powershell:
$subs = Get-AzureRmSubscription
# Resource start\stop role
$role = Get-AzureRmRoleDefinition "Virtual Machine Contributor"
$role.Id = $null
$role.Name = "Resource Start/Stop (Scheduled)"
$role.Description = "Can read\start\stop VMs"
$role.Actions.Clear()
$role.Actions.Add("Microsoft.Compute/virtualMachines/deallocate/action")
$role.Actions.Add("Microsoft.Compute/virtualMachines/read")
$role.Actions.Add("Microsoft.Compute/virtualMachines/restart/action")
$role.Actions.Add("Microsoft.Compute/virtualMachines/start/action")
$role.AssignableScopes.Clear()
$subs | ForEach-Object {
$scope = "/subscriptions/{0}" -f $_.Id
$role.AssignableScopes.Add($scope)
}
$def = New-AzureRmRoleDefinition -Role $role
如果您不需要重新启动 vms,则可以删除重新启动操作
于 2019-01-27T09:26:31.377 回答