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

Azure ARM部署报错:资源位置与配置分配位置不匹配

部署Microsoft.Maintenance/configurationAssignments时出现“Resource location didn't match configuration assignment location”错误

问题场景

部署Microsoft.Maintenance/configurationAssignments资源时触发错误:

Resource location didn't match configuration assignment location

此前Microsoft.Maintenance/maintenanceConfigurations部署正常,且已将两个资源的位置统一设置为westeurope,该部署流程之前多次成功,但今日执行时失效。尝试切换至northeurope仍报相同错误,输入无效区域会提示非法,说明位置格式无误。

相关代码

Bicep模板:

param maintenanceConfigurationId string
param AUMMachineConfigAssignmentsName string
param ResourceLocation string
param UpdateManagementSchedule string

resource AUMMachineConfigAssignment 'Microsoft.Maintenance/configurationAssignments@2023-04-01' = {
  name: AUMMachineConfigAssignmentsName
  location: ResourceLocation
  properties: {
    maintenanceConfigurationId: maintenanceConfigurationId
    filter: {
      resourceTypes: [
        'microsoft.compute/virtualmachines'
        'microsoft.hybridcompute/machines'
      ]
      locations: []
      resourceGroups: []
      osTypes: [
        'Linux'
        'Windows'
      ]
      tagSettings: {
        filterOperator: 'All'
        tags: {
          UpdateManagementEnabled: [
            'True'
          ]
          UpdateManagementSchedule: [
            UpdateManagementSchedule
          ]
        }
      }
    }
  }
}

PowerShell部署脚本:

New-AzResourceGroupDeployment `
-Name $AUMMachineConfigAssignmentsName `
  -resourceGroupName rg-weu-prod-updatemgmt `
  -TemplateFile dynamicScopes.bicep `
  -maintenanceConfigurationId $MachineConfigARMID `
  -AUMMachineConfigAssignmentsName "$AUMMachineConfigAssignmentsName" `
  -ResourceLocation westeurope

排查与解决方法

  1. 验证维护配置的实际位置
    确认$MachineConfigARMID指向的维护配置资源位置与配置分配的位置完全一致,执行以下命令查看:

    Get-AzResource -ResourceId $MachineConfigARMID | Select-Object Name, Location
    

    若发现位置不匹配,需修正维护配置的位置,或调整配置分配的位置参数。

  2. 为筛选器指定匹配的位置
    当前模板中filter.locations为空数组,尝试将其设置为与资源位置一致的区域:

    filter: {
      resourceTypes: [
        'microsoft.compute/virtualmachines'
        'microsoft.hybridcompute/machines'
      ]
      locations: [ResourceLocation]
      resourceGroups: []
      osTypes: [
        'Linux'
        'Windows'
      ]
      tagSettings: {
        filterOperator: 'All'
        tags: {
          UpdateManagementEnabled: [
            'True'
          ]
          UpdateManagementSchedule: [
            UpdateManagementSchedule
          ]
        }
      }
    }
    

    Azure维护服务的后端逻辑可能有更新,要求筛选器位置与资源位置对齐。

  3. 使用资源引用确保位置一致
    若维护配置与配置分配在同一模板部署,直接通过资源引用关联,避免手动传递参数可能的错误:

    // 示例:同一模板中的维护配置
    resource maintenanceConfig 'Microsoft.Maintenance/maintenanceConfigurations@2023-04-01' = {
      name: 'your-maintenance-config-name'
      location: ResourceLocation
      properties: {
        // 维护配置的具体属性
      }
    }
    
    resource AUMMachineConfigAssignment 'Microsoft.Maintenance/configurationAssignments@2023-04-01' = {
      name: AUMMachineConfigAssignmentsName
      location: maintenanceConfig.location
      properties: {
        maintenanceConfigurationId: maintenanceConfig.id
        filter: {
          locations: [maintenanceConfig.location]
          resourceTypes: [
            'microsoft.compute/virtualmachines'
            'microsoft.hybridcompute/machines'
          ]
          resourceGroups: []
          osTypes: [
            'Linux'
            'Windows'
          ]
          tagSettings: {
            filterOperator: 'All'
            tags: {
              UpdateManagementEnabled: [
                'True'
              ]
              UpdateManagementSchedule: [
                UpdateManagementSchedule
              ]
            }
          }
        }
      }
    }
    
  4. 检查资源组位置
    确认部署所在的资源组rg-weu-prod-updatemgmt位置与资源位置一致:

    Get-AzResourceGroup -Name rg-weu-prod-updatemgmt | Select-Object Location
    

    部分Azure资源的部署会受资源组位置约束,确保三者(资源组、维护配置、配置分配)位置统一。

内容的提问来源于stack exchange,提问作者Christoffer Klarskov Jakobsen

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.26 09:33:28