How to fix SQL backup to URL error: The remote server returned an error: (400) bad request

Posted in: Cloud, Microsoft SQL Server, Technical Track
Problem:

You are trying to take a native SQL Backup to URL and you receive the error below:

Msg 3271, Level 16, State 1, Line 1
A nonrecoverable I/O error occurred on file “https://MyStorageAccount.file.core.windows.net/MyContainer/Adventureworks_full_20190420.bak:”
Backup to URL received an exception from the remote endpoint. Exception Message: The remote server returned an error: (400) Bad Request..
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.

 

Cause:

You are trying to save a blob file using to non-blob storage or not using the Blob storage endpoint. Check your URL to see if you are pointing to the correct one. SQL Server backups can only be saved to Blob storage. If you are using general purpose storage, you will have multiple endpoints for different usage. You should be using the Blob url for SQL backups – see from the picture below. The one in the green box is the Blob storage endpoint. Using any other endpoints would result in a Bad Request Error. The same is true when using the other endpoints. You should be using it for the correct file types.

 

Fix:

Review the url path you are trying to restore to and make sure you are using the correct endpoint for Blob Storage.

email

Author

Want to talk with an expert? Schedule a call with our team to get the conversation started.

About the Author

Lead Microsoft Data Platform Consultant
Pio Balistoy is a Microsoft MVP for Data Platform from Singapore. He has been a Database professional for more than 17 years. He brings his passion for SQL to the community by being one of the Community leads for both Philippine Data Platform Forums (formerly Philippine SQL Server User Group) and Singapore SQL PASS.

2 Comments. Leave new

Hi ,

Iam uasing coorect end point but still face the same

Reply
Beverley Brindle
November 14, 2020 10:13 am

I works if you use shared secret rather than the access key directly.

1) get access key:
To get he Shared Access Key, click on the storage account
on the menu select Shared Access Signature
Fill in the details, including IP Range and dates (watch default dates don’t expire immediately)
Then Press [Generate SAS and Connection String] button at the bottom

2) create certificate
CREATE CREDENTIAL [https://{Storage Account}.blob.core.windows.net/cont000002]
WITH IDENTITY = N’SHARED ACCESS SIGNATURE’,
SECRET = N'{Shared Secret}’
GO

3) backup
backup database Test
to url = N’https://{StorageAccount}.blob.core.windows.net/c{Container}/{filename}’
go

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *