Exporting SQL Database using Poswershell is failing

GeethaThatipatri-MSFT 29,477 Reputation points Microsoft Employee
2024-07-18T13:32:24.9266667+00:00

Exporting SQL Database using Poswershell is failing and getting below Error “The resource operation completed with terminal provisioning state failed”. Please help with PowerShell script.

PS - Based on common issues that we have seen from customers and other sources, we are posting these questions to help the Azure community.

Azure SQL Database
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RahulRandive 9,901 Reputation points
    2024-07-18T13:43:12.1833333+00:00

    Greetings!

    Welcome to Microsoft Q&A forum.

    Please make sure to pass correct username and password in the powershll script

     You can use below powershell script to export the database

     $exportRequest = New-AzSqlDatabaseExport -ResourceGroupName $ResourceGroupName -ServerName $ServerName -DatabaseName $DatabaseName -StorageKeytype $StorageKeytype -StorageKey $StorageKey -StorageUri $BacpacUri -AdministratorLogin $creds.UserName -AdministratorLoginPassword $creds.Password

    To check the status of the export request, use the Get-AzSqlDatabaseImportExportStatus cmdlet. Running this cmdlet immediately after the request usually returns Status: InProgress. When you see Status: Succeeded the export is complete.

     

    Sample script:

    $exportStatus = Get-AzSqlDatabaseImportExportStatus -OperationStatusLink $exportRequest.OperationStatusLink

    [Console]::Write("Exporting")

    while ($exportStatus.Status -eq "InProgress")

    {

     ``   Start-Sleep -s 10

     ``   $exportStatus = Get-AzSqlDatabaseImportExportStatus -OperationStatusLink $exportRequest.OperationStatusLink

     ``   [Console]::Write(".")

    }

    [Console]::WriteLine("")

    $exportStatus

     

    Here are certain limitations while exporting the db:

    • Exporting a BACPAC file to Azure premium storage using the methods discussed in this article isn't supported.
    • Storage behind a firewall is currently not supported.Immutable storage is currently not supported.
    • Currently, the Import/Export service does not support Microsoft Entra ID authentication when MFA is required.
    • Import\Export services only support SQL authentication and Microsoft Entra ID.
    • Import\Export is not compatible with Microsoft Identity application registration.

    Thank You!

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.