%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%0A%20%26lt%3Bmeta%20http-equiv%3D%22Content-Type%22%20content%3D%22text%2Fhtml%3B%20charset%3DUTF-8%22%20%2F%26gt%3B%3CSTRONG%3EFirst%20published%20on%20MSDN%20on%20Mar%2021%2C%202018%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20%3CSTRONG%3E%20Scenario%3A%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%20if%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%20%3CBR%20%2F%3E%20%3CSTRONG%3E%20Resolution%3A%20%3CBR%20%2F%3E%20%3C%2FSTRONG%3E%20%3CBR%20%2F%3E%3COL%3E%3CBR%20%2F%3E%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%22nofollow%20noopener%20noreferrer%20noopener%20noreferrer%22%3E%20cloud%20shell%20%3C%2FA%3E%20or%20use%20your%20local%20Azure%20CLI%20installation.%3C%2FDIV%3E%3CBR%20%2F%3E%20%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F89012i9A27E890F0C34A56%22%20%2F%3E%3C%2FLI%3E%3CBR%20%2F%3E%3CLI%3Eedit%20the%20following%20command%20with%20your%20database%20details%20and%20execute%20the%20script%3C%2FLI%3E%3CBR%20%2F%3E%20%5Bcode%20language%3D%22PowerShell%22%5D%24ResourceGroupName%20%3D%20%22%22%20%3CBR%20%2F%3E%20%24ServerName%20%3D%20%22%22%20%3CBR%20%2F%3E%20%24DatabaseName%20%3D%20%22%22%20%3CBR%20%2F%3E%20%23----------------------------------------%20%3CBR%20%2F%3E%20%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)%20%3CBR%20%2F%3E%20if(-not%20%5Bstring%5D%3A%3AIsNullOrEmpty(%24OperationName))%20%3CBR%20%2F%3E%20%7B%20%3CBR%20%2F%3E%20(az%20sql%20db%20op%20cancel%20--resource-group%20%24ResourceGroupName%20--server%20%24ServerName%20--database%20%24DatabaseName%20--name%20%24OperationName)%20%3CBR%20%2F%3E%20%22Operation%20%22%20%2B%20%24OperationName%20%2B%20%22%20has%20been%20canceled%22%20%3CBR%20%2F%3E%20%7D%20%3CBR%20%2F%3E%20else%20%3CBR%20%2F%3E%20%7B%20%3CBR%20%2F%3E%20%22No%20in%20progress%20operation%20found%22%20%3CBR%20%2F%3E%20%7D%20%3CBR%20%2F%3E%20%5B%2Fcode%5D%20%3CBR%20%2F%3E%20%3CBR%20%2F%3E%3CLI%3Ereview%20the%20output%20to%20confirm%20operation%20has%20been%20canceled.%3C%2FLI%3E%3CBR%20%2F%3E%3C%2FOL%3E%0A%20%0A%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-369015%22%20slang%3D%22en-US%22%3EFirst%20published%20on%20MSDN%20on%20Mar%2021%2C%202018%20Scenario%3Aif%20you%20want%20to%20cancel%20updating%20database%20pricing%20tier.%3C%2FLINGO-TEASER%3E
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.


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

  3. [code language="PowerShell"]$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"
    }
    [/code]

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