Azure ARM Deployment - Resource location didn't match configuration assignment location

I'm trying to deploy a Microsoft.Maintenance/configurationAssignments using a bicep template.

My deployment of my Microsoft.Maintenance/maintenanceConfigurations works well, but then I want to do a deployment of the Microsoft.Maintenance/configurationAssignments, that is a resource that attached to the parent resource, my deployment fails with error:

Resource location didn't match configuration assignment location.

My location is set to westeurope for both deployments. I suspect an error in Azure, since this deployment have worked multiple times then I wrote the code, but now then I want to do a new deployment today, it stopped working.

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
          ]
        }
      }
    }
  }
}

My deployment script for calling the bicep template with parameters:

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

I have tried to change westeurope to northeurope, only to get the same error. If I change to some region name that is not valid, I get an error about that. So it seems like my input is ok.

Upvotes: 0

Views: 200

Answers (1)

I tried to switch to subscription deployment, and it works. My bicep file now looks like this:

targetScope = 'subscription'

param maintenanceConfigurationId string
param AUMMachineConfigAssignmentsName string
param UpdateManagementSchedule string

param subscriptionId string = subscription().id

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

Credits to this article for pointing me in the right direction: enter link description here

Upvotes: 0

Related Questions