You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

咨询:Azure虚拟机添加/移除维护配置的非订阅参与者角色权限

问题

我们将维护配置作为Azure Update Manager配置的一部分使用,想知道除了给Azure订阅授予参与者角色权限外,是否存在其他角色允许将Azure虚拟机添加到维护配置或从中移除?

对于启用Arc的服务器,可将参与者角色分配至其所属资源组,因此不存在此问题;但Azure虚拟机无法通过这种方式分配权限,我们对维护配置本身的权限没有问题,问题集中在Azure虚拟机所需的权限上。

我们尝试通过以下脚本创建自定义角色,但仍无法完成Azure虚拟机的添加或移除操作:

$customRole = @{
    Name        = "Maintenance Config VM Updater"
    Description = "Role with permissions to update maintenance configurations and associate VMs with them."
    Actions     = @(
        "Microsoft.Maintenance/configurations/write",
        "Microsoft.Maintenance/configurations/read",
        "Microsoft.Compute/virtualMachines/write",
        "Microsoft.Compute/virtualMachines/read"
    )
    NotActions  = @()
    DataActions = @()
    NotDataActions = @()
    AssignableScopes = @(
        "/subscriptions/<your-subscription-id>"
    )
}

# Convert the properties to JSON
$customRoleJson = ConvertTo-Json -InputObject $customRole -Depth 10
 
# Create the custom role in Azure
New-AzRoleDefinition -InputFile (New-TemporaryFile -Value $customRoleJson)
解决方案

要实现将Azure虚拟机添加/移除到维护配置的细粒度权限,需调整自定义角色的权限配置并确保分配范围正确:

  • 补充核心关联权限:原自定义角色缺少维护配置与VM关联操作的关键权限,需添加以下Actions:

    • Microsoft.Maintenance/configurationAssignments/write:用于创建或更新VM与维护配置的关联关系
    • Microsoft.Maintenance/configurationAssignments/delete:用于移除VM与维护配置的关联关系
    • Microsoft.Maintenance/configurationAssignments/read:用于查看现有关联配置
  • 优化后的自定义角色脚本:

$customRole = @{
    Name        = "Maintenance Config VM Updater"
    Description = "Role with permissions to associate/dissociate VMs with maintenance configurations."
    Actions     = @(
        "Microsoft.Maintenance/configurations/read",
        "Microsoft.Maintenance/configurationAssignments/read",
        "Microsoft.Maintenance/configurationAssignments/write",
        "Microsoft.Maintenance/configurationAssignments/delete",
        "Microsoft.Compute/virtualMachines/read"
    )
    NotActions  = @()
    DataActions = @()
    NotDataActions = @()
    AssignableScopes = @(
        "/subscriptions/<your-subscription-id>"
    )
}

# Convert the properties to JSON
$customRoleJson = ConvertTo-Json -InputObject $customRole -Depth 10
 
# Create the custom role in Azure
New-AzRoleDefinition -InputFile (New-TemporaryFile -Value $customRoleJson)

说明:移除了不必要的Microsoft.Maintenance/configurations/write(若无需修改维护配置本身)和权限过大的Microsoft.Compute/virtualMachines/write,仅保留关联操作必需的核心权限与只读权限。

  • 正确分配角色范围:可将该自定义角色分配至订阅级别或目标VM所在的资源组级别(Azure虚拟机实际隶属于资源组,资源组级别的分配能实现更细粒度的权限管控),确保操作主体拥有对应范围的角色权限。

内容的提问来源于stack exchange,提问作者Danny Coyles

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.15 16:40:10