You can configure the maintenance window for an Azure SQL Managed Instance during resource creation, or anytime after a resource is created.
The System default maintenance window is 5PM to 8AM daily (local time of the Azure region the resource is located) to avoid peak business hours interruptions.
If the System default maintenance window is not the best time, select one of the other available maintenance windows.
Configuring maintenance window is a long running asynchronous operation, similar to changing the service tier of the Azure SQL resource. The resource is available during the operation, except a short reconfiguration that happens at the end of the operation and typically lasts up to 8 seconds even in case of interrupted long-running transactions. To minimize the impact of the reconfiguration you should perform the operation outside of the peak hours.
The following examples show how to configure the maintenance window using Azure PowerShell. You can install Azure PowerShell.
Discover available maintenance windows
When setting the maintenance window, each region has its own maintenance window options that correspond to the timezone for the region.
Discover SQL Managed Instance maintenance windows
The following example returns the available maintenance windows for the chinaeast2 region using the Get-AzMaintenancePublicConfiguration cmdlet. For managed instances, set MaintenanceScope to SQLManagedInstance.
Set the maintenance window while creating a SQL managed instance
The following example creates a new managed instance and sets the maintenance window using the New-AzSqlInstance cmdlet. The maintenance window is set on the instance, so all databases in the instance have the same maintenance window schedule. For -MaintenanceConfigurationId, the MaintenanceConfigName must be a valid value for your instance's region. To get valid values for your region, see Discover available maintenance windows.
The following examples show how to configure the maintenance window using Azure CLI. You can install Azure CLI.
Sign in to Azure
Use the following script to sign in using a different subscription, replacing <Subscription ID> with your Azure Subscription ID. If you don't have an Azure trail subscription, create a trial subscription before you begin.
subscription="<subscriptionId>" # add subscription here
az account set -s $subscription # ...or use 'az login'
When setting the maintenance window, each region has its own maintenance window options that correspond to the timezone for the region.
Discover SQL Managed Instance maintenance windows
The following example returns the available maintenance windows for the chinaeast2 region using the az maintenance public-configuration list command. For managed instances, set maintenanceScope to SQLManagedInstance.
az maintenance public-configuration list --query "[?location=='chinaeast2'&&contains(maintenanceScope,'SQLManagedInstance')]"
Set the maintenance window while creating a SQL managed instance
The following example creates a new managed instance and sets the maintenance window using az sql mi create. The maintenance window is set on the instance, so all databases in the instance have the same maintenance window schedule. MaintenanceConfigName must be a valid value for your instance's region. To get valid values for your region, see Discover available maintenance windows.
az sql mi create -g mygroup -n myinstance -l mylocation -i -u myusername -p mypassword --subnet /subscriptions/{SubID}/resourceGroups/{ResourceGroup}/providers/Microsoft.Network/virtualNetworks/{VNETName}/subnets/{SubnetName} -m /subscriptions/{SubID}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_{Region}_{MaintenanceConfigName}
Configure maintenance window for existing SQL managed instances
When applying a maintenance window selection to a SQL managed instance, a brief reconfiguration (several seconds) might be experienced in some cases as Azure applies the required changes.
The following steps set the maintenance window on an existing SQL managed instance using the Azure portal:
Set the maintenance window for an existing managed instance
Navigate to the SQL managed instance you want to set the maintenance window for.
In the Settings menu select Maintenance, then select the desired maintenance window.
Set the maintenance window on an existing managed instance
The following example sets the maintenance window on an existing managed instance using the Set-AzSqlInstance cmdlet.
It's important to make sure that the $maintenanceConfig value must be a valid value for your instance's region. To get valid values for a region, see Discover available maintenance windows.
The following examples show how to configure the maintenance window using Azure CLI. You can install Azure CLI.
Set the maintenance window on an existing managed instance
The following example sets the maintenance window using az sql mi update. The maintenance window is set on the instance, so all databases in the instance have the same maintenance window schedule. For -MaintenanceConfigurationId, the MaintenanceConfigName must be a valid value for your instance's region. To get valid values for your region, see Discover available maintenance windows.
az sql mi update -g mygroup -n myinstance -m /subscriptions/{SubID}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/SQL_{Region}_{MaintenanceConfigName}
Note
For displaying user friendly names in Azure portal, Azure SQL Managed Instance relies on maintenance configurations as a resource. Maintenance definitions for Azure SQL Managed Instance are part of public maintenance configurations. There might be the situation for newly added Azure regions in which SQL Managed Instance can be used in the region, while public maintenance configurations are still being created. In that case, Azure portal will not display the user friendly names in the dropdown and instead users will see the system names:
MI_1 which is equivalent for Weekday window: 10:00 PM to 6:00 AM local time, Monday - Thursday
MI_2 which is equivalent for Weekend window: 10:00 PM to 6:00 AM local time, Friday - Sunday