Scaling up or down an Azure SQL Database is a very common task. Whilst common it is also very easy to do via the Azure portal or even PowerShell. When you scale a database please be aware that it creates a replica of the original database at the new performance level and then switches connections over to the replica but what do you do if you want to cancel the scale request?
I had an issue where my scale request was taking hours for a 1.5GB database, obviously something was not right so I wanted to abort the request. There is no option within the portal or TSQL code to do this. You will need to call upon the Azure CLI to complete this task (see red arrow below).
Once you have clicked Azure CLI issue the following, don’t forget the scaling request is running we just want to see it and confirm that fact.
az sql db op list -d DatabaseName -g ResourceGroup -s ServerName
Now take note of the GUID like value (e3156134-d061-47b1-9c89-8bf62fd8d04f) for “name” we will need it for the next command as -n where n is the unique name of the operation to cancel.
So the cancel looks like:
az sql db op cancel -g AKS_PROD -s smarties -d AWSDB -n e3156134-d061-47b1-9c89-8bf62fd8d04f
Once you have executed the above connect to the master database via SSMS and query sys.dm_operation_status to confirm what is actually happening.
select * from sys.dm_operation_status
You can clearly see the cancelled state for the ID that we passed in.
You might need this one day, for some reason this database has been causing me grief.