CUiD8pdQJh
CUiD8pdQJh

Reputation: 55

Is there a way to use New-AzMaintenanceConfiguration to also create a dynamic scope?

I want to programmatically create Maintenance Configurations using the new Azure Update Manager. To do this, I am utilizing the Az.Maintenance module, and specifically the New-AzMaintenanceConfiguration cmdlet. However, in the official documentation, I can't find any switch used to create a dynamic scope for assigning machines to the maintenance configuration.

I currently have no approach to this problem and would appreciate any ideas or help.

Upvotes: 1

Views: 712

Answers (2)

Jayendran
Jayendran

Reputation: 10940

The design of dynamic scope assignment is a little different as it creates resources at the subscription level and not at any RG level. So the resource id will look like

subscriptions/xxxxx/providers/Microsoft.Maintenance/configurationAssignments/DynamicAssignment1

Currently, the only way to create this using REST API (management)

Lets assume the maintaince configuration is at SubA, and you have to create the dynamic assignment by including SubB and SubC, then you have to follow below


PUT https://management.azure.com/subscriptions/xxxxx/providers/Microsoft.Maintenance/configurationAssignments/DynamicAssignment_SubB?api-version=2023-04-01"


{
    "location": "",
    "properties": {
        "maintenanceConfigurationId": "/subscriptions/yyyy/resourceGroups/maintenance-config-rg/providers/Microsoft.Maintenance/maintenanceConfigurations/mgconfig01_SubA"
    }
}

PUT https://management.azure.com/subscriptions/zzzz/providers/Microsoft.Maintenance/configurationAssignments/DynamicAssignment_SubC?api-version=2023-04-01"


{
    "location": "",
    "properties": {
        "maintenanceConfigurationId": "/subscriptions/yyyy/resourceGroups/maintenance-config-rg/providers/Microsoft.Maintenance/maintenanceConfigurations/mgconfig01_SubA"
    }
}



If you are comfortable with powershell, here its a good script that can help you to understand the flow


I also raised a feature request on azure-powershell github

Upvotes: 0

CUiD8pdQJh
CUiD8pdQJh

Reputation: 55

Okay, I found the solution: The New-AzConfigurationAssignment cmdlet fits perfectly.

Upvotes: 1

Related Questions