johnymachine
johnymachine

Reputation: 826

What is the proper way to export Azure SQL DB to Blob using SAS?

When I repeat steps from here: https://learn.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?

Upvotes: 1

Views: 790

Answers (1)

Gaurav Mantri
Gaurav Mantri

Reputation: 136196

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

Upvotes: 2

Related Questions