question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

az sql db export not working

See original GitHub issue

Describe the bug az sql db export does not work. It fails with the error

Deployment failed. Correlation ID: 11c66e3d-ac64-4a67-88c4-61934905898b. Operation failed with status: ‘Bad Request’. Details: The ImportExport operation with Request Id ‘acbe5755-7eb4-4022-b021-5fab9c61a2c8’ failed due to 'Error encountered during the service operation. Blob https://account.blob.core.windows.net/container is not writeable. The remote server returned an error: (404) Not Found. The remote server returned an error: (404) Not Found. '. ‘sp’ is not recognized as an internal or external command, operable program or batch file. ‘sv’ is not recognized as an internal or external command, operable program or batch file. ‘sr’ is not recognized as an internal or external command, operable program or batch file. ‘sig’ is not recognized as an internal or external command, operable program or batch file.

Those unrecognized “commands” correspond to the query parameters in my SAS token.

To Reproduce These are the steps from the doc/ az sql db export --help

$sas = az storage blob generate-sas --account-name $StorageAccount -c $StorageContainer -n $bacpac --permissions w --expiry (Get-Date).AddDays(1).ToString("yyyy-MM-ddT00:00:00Z")

az sql db export -s $ServerName -n $baseName -g $ResourceGroupName -p "$($creds.GetNetworkCredential().Password)" -u $cred.UserName --storage-uri "$exportUri/$baseName.bacpac" --storage-key-type SharedAccessKey --storage-key "?$($sas.Trim('"'))"

I also ran an equivalent from cmd.exe but no dice.

Expected behavior bacpac file showing up in blob storage.

Environment summary Powershell 5.1 on Windows 10 azure-cli 2.0.63 - I upgraded to this version after getting this error on an older one, I believe it was 2.0.61. Installed via MSI.

Additional context I had a script like this working last week using New-AzSqlDatabaseExport but then, without any changes I am aware of (can’t speak for group policy), it started failing to request the export with weird errors that made me suspect some kind of wires got crossed between the AzureRm and Az powershell modules so I tried moving to the cli.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
ghostcommented, May 6, 2019

Thanks for that --debug flag; you both are right. The powershell issue was because of the & in the string. I’m surprised at this as I don’t think a string with a $ in it will break the shell this way. However, using --storage-key "$sas" worked e.g. --storage-key ""se=2019-05-07T00%3A00%3A00Z&sp=rw&sv=2018-03-28&sr=b&sig=AAAAAAAAAAAAAAAAAAAAAAAAAAAAA%2BXiiI%3D"". It seems silly but it’s working.

My cmd.exe example is now working also. I had to add the blob name to the end of the --storage-uri value (I had it correct in powershell and must have messed it up in translation) and I also had to have quotes around the token.

1reaction
tjprescottcommented, May 1, 2019

If the sas token is being omitted due to the shell, it might explain why you get 404 for the blobs.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Import and export of a database takes a long time - Azure SQL ...
Run the BACPAC import or export directly in your code by using the Microsoft SQL Server Data-Tier Application Framework (DacFx) API.
Read more >
How to perform Azure SQL database Import/Export operations ...
To get the status of the export operation, run the following command. ... Workaround: run the target the script with the older Az.Sql...
Read more >
Azure Sql database export to Azure blob storage failed
According to my research, when exporting a SQL database to the azure storage, the Azure Storage account behind a firewall is currently not ......
Read more >
Azure SQL Database backup fails with "The storage account ...
This could be due to a Microsoft limitation when attempting to export from SQL on Azure to an Azure Storage account which has...
Read more >
azure db export to blob storage failed - DBA Stack Exchange
The Azure SQL Server firewall did not allow the operation to connect. To resolve this, please select the "Allow All Azure"checkbox in the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found