Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
Azure SQL Managed Instance
This article describes how to stop and start an instance to save on billing costs when you're using Azure SQL Managed Instance in the General Purpose service tier. You can stop and start your instance by using the Azure portal, Azure PowerShell, Azure CLI, or REST API.
Note
The stop and start feature controls billing and shouldn't be used to Restart the instance as a troubleshooting step.
Overview
To save on billing costs, you can stop your General Purpose SQL managed instance when you're not using it. Stopping an instance is similar to deallocating a virtual machine. When an instance is in a stopped state, you're no longer billed for compute and licensing costs but still billed for data and backup storage.
Stopping a SQL managed instance clears all cached data.
This feature introduces three new SQL managed instance states, as the following diagram indicates:
- Stopping
- Stopped
- Starting
After the stop operation is initiated, it typically takes about 5 minutes to stop the instance. However, starting an instance takes about 20 minutes from the moment the start operation is initiated. Only SQL managed instances in a ready state can be stopped. After the instance is stopped, it stays in a stopped state until a start operation is initiated, either manually or triggered with a defined schedule. Only instances that are in a stopped state can be started.
When the following operations occur, Azure allocates compute resources to the underlying virtual cluster:
- Creating a SQL managed instance.
- Starting a stopped SQL managed instance.
- Resizing a SQL managed instance. For example, changing the service tier, storage, hardware generation, or number of vCores.
While there's continual investment in more infrastructure to support customer demand, there might be occasional resource allocation failures from unprecedented growth of demand for Azure services in specific regions. This situation might result in a prolonged operation duration, approximately 4 hours if there's a new virtual cluster buildout (in accordance with management operation durations). It can also result in a failure to start the instance, in which case you should try again later.
Important
As a platform as a service (PaaS) service, SQL Managed Instance is responsible for compliance for every part of the system components. If there's an urgent need for system maintenance, it requires the instance to be online. In this situation, Azure can initiate the start operation and keep the instance online until the maintenance operation completes, at which time Azure stops the instance. Compute and license charges are applied for the entire time the instance is in an online state.
Action types
There are two ways to stop and start an instance: either manually on demand or by creating a schedule.
Manual commands
You can use manual commands to immediately trigger a stop and start action. Manual commands are good for instances that have longer periods of inactivity without regular patterns, or for testing purposes. Alternatively, you can use Azure Automation schedules or any custom solution that creates customized and more flexible schedules that you can't set up by using the built-in stop and start scheduler in SQL Managed Instance.
Scheduled commands
You can also create a schedule with one or more multiple points of time when a stop or start action is triggered. Scheduled commands are good for instances that have regular patterns. For example, starting an instance every weekday at 8 AM, stopping it at 5 PM, and then starting it during the weekend at 7 AM and stopping it at 11 AM. Scheduling your commands eliminates the need for you to create custom solutions or to use Azure Automation to create stop and start schedules.
Scheduled items represent points in time when stop and start events are initiated, not when the instance is up and running. When you're creating a schedule, take the operation duration into account. For example, if you want to have your instance up and running at 8 AM, you can define a schedule that initiates the start operation at 7:40 AM.
Consider the following rules for a stop and start schedule:
- Each scheduled item is defined as a stop-and-start pair, and it must have both stop and start values populated. It's not possible to have a populated stop value with a missing start value, and vice versa.
- The scheduled pairs can't overlap. If there's an overlap of scheduled times, the API returns an error.
- The time span between any two successive actions (that is, a start after a stop or a stop after a start) must be at least one hour. For example, if a start is scheduled for 10 AM, the stop action can't be scheduled before 11 AM.
- If conflicting operations occur when a stop is triggered, such as a scaling vCore in progress, the mechanism retries after 10 minutes. If after 10 minutes the conflicting operation is still active, the stop operation is skipped.
Billing
Stopped instances don't get billed for vCores and the SQL license, they're charged only for data and backup storage. However, vCores and license billing is charged for every started hour. For example, at 12:01, you're charged for the entire hour, even if the instance is stopped within the hour.
Azure Hybrid Benefit
The Azure Hybrid Benefit (AHB) is applied per resource. If your instance is using the Azure Hybrid Benefit for the discount on licensing costs, you can apply the Azure Hybrid Benefit to another resource when the instance is in a stopped state. You must first disable AHB on the instance, and then stop the instance. Similarly, after you restart the instance, you have to reenable AHB on it to apply the licensing benefit.
Reservation pricing
Azure Reservation is applied for the vCores and hours emitted. When an instance that's eligible for reserved pricing is stopped, reserved pricing is automatically redirected to another instance, if one exists. You can use the stop and start feature to overprovision reserved instance pricing.
For example, let's say that you purchase a SQL managed instance with a reservation for 16 vCores. You can run two instances with 8 vCores each from 1 PM to 2 PM, stop both instances, and then run two different instances with 8 vCores each from 2 PM to 3 PM. This approach would consume your 16 vCore limit for each hour, spread among four instances in total.
Reservation discounts are offered on a "use it or lose it" basis. That is, if you don't have matching resources for a specified hour, the reservation quantity for that hour is lost. Unused reserved hours can't be carried forward.
Limitations of the stop and start feature
Consider the following limitations:
- Stop and start of an instance is currently only possible for instances in the General Purpose service tier.
- You can't stop instances that:
- Have an ongoing management operation (such as an ongoing restore, vCore scaling, and so on)
- Are part of a failover group
- Use the Managed Instance link
- have zone redundancy enabled
- are part of Instance pool
- While a SQL managed instance is in a stopped state, it's not possible to change its configuration properties. To change any properties, you must start the instance.
- While the instance is in a stopped state, it's not possible to take backups. For example, let's say that you have long-term backups configured, with yearly backups in place. If you stop the instance during the defined yearly backup period, the backup is skipped. We recommend that you keep the instance up and running during the yearly backup period.
- It's not possible to cancel a stop or start operation once you initiate it.
- If a vulnerability assessment scan is scheduled for SQL Managed Instance while the instance is stopped, the scan execution fails.
- Maintenance notifications aren't sent for instances that are in a stopped state. The result is:
- An incomplete sequence of notifications. For example, an advanced notification isn't sent, while an in progress notification is sent.
- SQL Managed Instance is missing from the list of affected resources in the notification content.
- Error logs that are available in SQL Managed Instance aren't persisted and are automatically erased when the instance is stopped.
Prerequisites
To use the instance stop and start feature, your instance must be in the General Purpose service tier.
Instances that don't meet the prerequisite have the stop and start controls disabled on the Overview page for the SQL managed instance resource in the Azure portal. Hovering over the control explains why the instance can't use the stop and start feature.
Prepare command line environment
Skip this step if you're using the Azure portal.
If you want to stop or start an instance by using PowerShell or the Azure CLI, you need to prepare your environment by configuring command line tools and defining your parameters.
Alternatively to configuring your command line tools, you can also use the Azure Cloud Shell. A free interactive shell you can use to run the steps in this article. It has common preinstalled Azure tools and is configured to use with your account. If you don't have an Azure subscription, create an Azure free account before you begin.
To open the Cloud Shell, select Try it from the upper right corner of a code block. You can also launch Cloud Shell in a separate browser tab by going to https://shell.azure.com.
To stop and start your instance with PowerShell, you can install Azure PowerShell, or use the Azure Cloud Shell.
When Cloud Shell opens, verify that PowerShell is selected for your environment. Subsequent sessions use Azure CLI in a PowerShell environment. Select Copy to copy the blocks of code, paste it into the Cloud Shell, and press Enter to run it.
Once PowerShell or Cloud Shell is launched, define the parameters:
$SubscriptionId = "<Subscription-ID>"
$SqlMIName = "<SQL-MI-name>"
$RgName = "<SQL-MI-resource-group>"
# Login-AzAccount
Select-AzSubscription -SubscriptionName $SubscriptionID
Stop the SQL managed instance
You can stop the instance by using:
- Azure portal
- PowerShell
- The Azure CLI
- The REST API call, invoked through any tool
To stop your SQL managed instance by using the Azure portal, go to the Overview page of your instance, and then select the Stop button.
If your instance is already stopped, the Stop button is unavailable.
Start the SQL managed instance
You can start the instance by using:
- Azure portal
- PowerShell
- The Azure CLI
- The REST API call, invoked through any tool
After your SQL managed instance is stopped, to start it by using the Azure portal, go to the Overview page of your instance, and then select the Start button.
If your instance is already started, the Start button is unavailable.
Manage a stop and start schedule
You can manage a stop and start schedule by using:
- Azure portal
- PowerShell
- The Azure CLI
- The REST API call, invoked through any tool
To manage a stop and start schedule by using the Azure portal, go to your instance, and then select Start/Stop Schedule in the resource menu.
On the Start/Stop Schedule pane, you can:
- View existing schedules.
- Specify the time zone of your scheduled events in the Time zone dropdown list.
- Create a new schedule by selecting Create a schedule item.
- Modify an existing schedule by selecting the pencil icon.
- Delete an existing schedule by selecting the trash can icon.
Note
Currently, the Activity Log only captures operations initiated via Azure Resource Manager (ARM). The scheduled start and stop operations aren't tracked on the Activity Log. So, at this time, it isn't possible to view the history of the scheduled start and stop operations via the Activity Log in Azure portal. Or, via any monitoring that is based on such logs.