jsonsql-serverazure-bicepazure-elasticpool

How to set the maintenance window for elastic pool in Bicep script?


I had no luck figuring out what to pass for "maintenanceConfigurationId" to set the maintenance window.

Here's the bicep:

resource sqlServer 'Microsoft.Sql/servers@2021-11-01' existing = {
  name: sqlServerName
}

resource sqlElasticPool 'Microsoft.Sql/servers/elasticPools@2021-11-01' = {
  name: name
  location: location
  parent: sqlServer
  properties: {
    //maintenanceConfigurationId: maintenanceConfigurationId
  }
}

I tried both "System default" and "System default (5pm to 8am)". Both aren't recognized/accepted values for maintenanceConfigurationId.

Here's the parameter value:

    "sql_elastic_pools": [
      {
        "name": "sqlep-<redact>",
        "subscription": "sub-<redact>",
        "resource_group": "rg-<redact>",
        "location": "usgovvirginia",
        "server": "sql-<redact>",
        "compute_and_storage": "Standard-series Gen5 4 vCores 500 GB",
        "maintenance_window": "System default (5pm to 8am)",
        "tags": {
          "app": "Data Migration",
          "environment": "Non-Production",
          "description": "None"
        }
      }
    ],

Solution

  • I tried both "System default" and "System default (5pm to 8am)". Both aren't recognized/accepted values for maintenanceConfigurationId.

    Provide them in a Subscription-ResourceId format. Eg;

    maintenanceConfigurationId: '/subscriptions/your-subscription-id/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_Default'
    
    maintenanceConfigurationId: '/subscriptions/your-subscription-id/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_EastUS_DB_1'
    

    You could also declare them as an existing resource and then reference them. https://learn.microsoft.com/en-us/azure/templates/microsoft.maintenance/2021-09-01-preview/publicmaintenanceconfigurations?pivots=deployment-language-bicep