az sql db export not working
See original GitHub issueDescribe 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:
- Created 4 years ago
- Comments:6 (4 by maintainers)
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.If the sas token is being omitted due to the shell, it might explain why you get 404 for the blobs.