1
votes

When I repeat steps from here: https://docs.microsoft.com/en-us/cli/azure/sql/db?view=azure-cli-latest#az-sql-db-export

StorageAccessKey works fine.

SharedAccessKey is failing with:

Operation failed with status: 'Bad Request'. Details: There was an error that occurred during this operation : 'Error encountered during the service operation. ; Exception Microsoft.SqlServer.Management.Dac.Services.ServiceException:Unexpected exception encountered while retrieving metadata for blob 'https://satest.blob.core.windows.net/backup/mydb-2019-5-13-10-1.bacpac'.; Inner exception Microsoft.WindowsAzure.Storage.StorageException:The remote server returned an error: (403) Forbidden.; Inner exception System.Net.WebException:The remote server returned an error: (403) Forbidden.; '

What am I missing?

1
how did you get the SharedAccessKey? - Joy Wang-MSFT
As documentation suggest: az storage blob generate-sas --account-name myAccountName -c myContainer -n myBacpac.bacpac \ --permissions w --expiry 2020-01-01T00:00:00Z - johnymachine
Try to generate SAS token in your storage account -> Shared access signature in the portal, will it work? - Joy Wang-MSFT

1 Answers

2
votes

Microsoft.SqlServer.Management.Dac.Services.ServiceException:Unexpected exception encountered while retrieving metadata for blob

From the error message, it looks like you need read permission as well in your Shared Access Signature (SAS). Please regenerate SAS with both read and write permission.

az storage blob generate-sas --account-name myAccountName -c myContainer -n myBacpac.bacpac \ --permissions rw --expiry 2020-01-01T00:00:00Z