This article is contributed. See the original author and article here.


This article help you cancel ongoing import or export operation on Azure SQL Database. 


Step by Step guidance: 

  1. Open new PowerShell window, you may use cloud shell on Azure portal as well by clicking the cloud shell button

  2. Yochanan_MSFT_1-1606432077431.png

  3. Copy and paste the following PowerShell code and execute it – it will create a function for the current PowerShell session

  4. function Cancel-AzSQLImportExportOperation
        $Operation = Get-AzSqlDatabaseActivity -ResourceGroupName $ResourceGroupName -ServerName $ServerName -DatabaseName $DatabaseName | Where-Object {($_.Operation -eq "ExportDatabase" -or $_.Operation -eq "ImportDatabase") -and $_.State -eq "InProgress"}
        if(-not [string]::IsNullOrEmpty($Operation))
                Write-Host -ForegroundColor Cyan ("Operation " + $Operation.Operation + " with OperationID: " + $Operation.OperationId + " is now " + $Operation.State)
                $UserInput = Read-Host -Prompt "Should I cancel this operation? (Y/N)"
            } while($UserInput -ne "Y" -and $UserInput -ne "N")
            if($UserInput -eq "Y")
                "Canceling operation"
                Stop-AzSqlDatabaseActivity -ResourceGroupName $ResourceGroupName -ServerName $ServerName -DatabaseName $DatabaseName -OperationId $Operation.OperationId
            {"Exiting without cenceling the operation"}
            "No import or export operation is now running"

  5. use the function 


    to cancel an Import or Export operation

  6. you need to provide the Resource Group name, Server name and Database name where the operation is currently running. 


I hope you find it useful. 

Thank you Roshna Nazir for pointing out this functionality.

if you have any feedback please do not hesitate to share it with me at






Brought to you by Dr. Ware, Microsoft Office 365 Silver Partner, Charleston SC.

%d bloggers like this: