Stop / Cancel ongoing Azure SQL DB scale operation

Published 03-13-2019 06:57 PM 2,939 Views
Microsoft

First published on MSDN on Mar 21, 2018
Scenario:

if you want to cancel updating database pricing tier. this can be due to mistake, or long running scale operation.

Resolution:



    1. open Azure cloud shell or use your local Azure CLI installation.

 

    1. edit the following command with your database details and execute the script

 

$ResourceGroupName = ""
$ServerName = ""
$DatabaseName = ""
#----------------------------------------
$OperationName = (az sql db op list --resource-group $ResourceGroupName --server $ServerName --database $DatabaseName --query "[?state=='InProgress'].name" --out tsv)
if(-not [string]::IsNullOrEmpty($OperationName))
{
(az sql db op cancel --resource-group $ResourceGroupName --server $ServerName --database $DatabaseName --name $OperationName)
"Operation " + $OperationName + " has been canceled"
}
else
{
"No in progress operation found"
}

 



    1. review the output to confirm operation has been canceled.

 

1 Comment
Occasional Visitor

The script runs fine but returns a misleading message at the end that wasted some time since it wasn't an actual issue:

[

ERROR: Resource group 'RGXXX' could not be found.
No in progress operation found

]

%3CLINGO-SUB%20id%3D%22lingo-sub-369015%22%20slang%3D%22en-US%22%3EStop%20%2F%20Cancel%20ongoing%20Azure%20SQL%20DB%20scale%20operation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-369015%22%20slang%3D%22en-US%22%3E%3CP%3E%3CSTRONG%3E%20First%20published%20on%20MSDN%20on%20Mar%2021%2C%202018%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CSTRONG%3E%20Scenario%3A%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3Eif%20you%20want%20to%20cancel%20updating%20database%20pricing%20tier.%20this%20can%20be%20due%20to%20mistake%2C%20or%20long%20running%20scale%20operation.%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3CSTRONG%3E%20Resolution%3A%20%3CBR%20%2F%3E%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3COL%3E%0A%3COL%3E%0A%3CLI%3E%3CBR%20%2F%3E%3CDIV%3Eopen%20Azure%20%3CA%20href%3D%22https%3A%2F%2Fshell.azure.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3E%20cloud%20shell%20%3C%2FA%3E%20or%20use%20your%20local%20Azure%20CLI%20installation.%3C%2FDIV%3E%3CBR%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20138px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F89012i9A27E890F0C34A56%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20role%3D%22button%22%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%3E%0A%3COL%3E%0A%3CLI%3Eedit%20the%20following%20command%20with%20your%20database%20details%20and%20execute%20the%20script%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-powershell%22%3E%3CCODE%3E%24ResourceGroupName%20%3D%20%22%22%0A%24ServerName%20%3D%20%22%22%0A%24DatabaseName%20%3D%20%22%22%0A%23----------------------------------------%0A%24OperationName%20%3D%20(az%20sql%20db%20op%20list%20--resource-group%20%24ResourceGroupName%20--server%20%24ServerName%20--database%20%24DatabaseName%20--query%20%22%5B%3Fstate%3D%3D'InProgress'%5D.name%22%20--out%20tsv)%0Aif(-not%20%5Bstring%5D%3A%3AIsNullOrEmpty(%24OperationName))%0A%7B%0A(az%20sql%20db%20op%20cancel%20--resource-group%20%24ResourceGroupName%20--server%20%24ServerName%20--database%20%24DatabaseName%20--name%20%24OperationName)%0A%22Operation%20%22%20%2B%20%24OperationName%20%2B%20%22%20has%20been%20canceled%22%0A%7D%0Aelse%0A%7B%0A%22No%20in%20progress%20operation%20found%22%0A%7D%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CBR%20%2F%3E%3CBR%20%2F%3E%3C%2FP%3E%0A%3COL%3E%0A%3COL%3E%0A%3CLI%3Ereview%20the%20output%20to%20confirm%20operation%20has%20been%20canceled.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-369015%22%20slang%3D%22en-US%22%3E%3CP%3EFirst%20published%20on%20MSDN%20on%20Mar%2021%2C%202018%20Scenario%3Aif%20you%20want%20to%20cancel%20updating%20database%20pricing%20tier.%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-SUB%20id%3D%22lingo-sub-2177550%22%20slang%3D%22en-US%22%3ERe%3A%20Stop%20%2F%20Cancel%20ongoing%20Azure%20SQL%20DB%20scale%20operation%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-2177550%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20script%20runs%20fine%20but%20returns%20a%20misleading%20message%20at%20the%20end%20that%20wasted%20some%20time%20since%20it%20wasn't%20an%20actual%20issue%3A%3C%2FP%3E%3CP%3E%5B%3C%2FP%3E%3CP%3EERROR%3A%20Resource%20group%20'RGXXX'%20could%20not%20be%20found.%3CBR%20%2F%3ENo%20in%20progress%20operation%20found%3C%2FP%3E%3CP%3E%5D%3C%2FP%3E%3C%2FLINGO-BODY%3E
Version history
Last update:
‎Nov 26 2020 01:56 AM
Updated by: