I keep getting the following error in trying to backup local database to Azure blob storage.
Msg 3271, Level 16, State 1, Line 8
A nonrecoverable I/O error occurred on file
"https://mystorageaccount.blob.core.windows.net/mycontainer/AdventureWorks2016.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 8
BACKUP DATABASE is terminating abnormally.
I followed the prescribed approach of [1] Create credential:
CREATE CREDENTIAL [testcred] WITH IDENTITY = 'mystorageaccount'
,SECRET = 'storage account key';
[2] Create the backup to the url of storage account
BACKUP DATABASE AdventureWorks2014
TO URL = 'https://mystorageaccount.blob.core.windows.net/mycontainer/AdventureWorks2016.bak'
WITH CREDENTIAL = 'testcred'
,COMPRESSION
,STATS = 5;
GO
I have tried with general purpose storage v2 and v1 yet the error persists. I have tried using a SAS token too but it gave same error I tried on SQL Server 2014 Express and 2017 Express. Same error
CodePudding user response:
In trying to connect directly to the Azure storage account from the "Connect" option in SQL Server Management Studio I finally saw a clue to the problem as shown below:
I kept changing the TLS version in the Storage Account settings until I found the correct option that tallies with the version of SQL am running (2017 Express). For me it is "version 1.0". Be careful with this though since it manages how your data is encrypted as it moves between Azure and your machine. See the Microsoft docs on this:
Come on Microsoft, simply sending "The remote server returned an error (400) Bad Request" hardly helps anyone. Especially averagely technical people.