Backing up SQL Server to Azure storage

I've been looking at using the baked-in backup SQL to Azure blob storage feature to, well, backup some databases and have been thoroughly stumped! :( The SQL I've put together is:

IF EXISTS (SELECT 1 FROM sys.credentials WHERE name = 'https://<my_storage_account><container_name>/')
	DROP CREDENTIAL [https://<my_storage_account><container_name>/]

CREATE CREDENTIAL [https://<my_storage_account><container_name>/]
WITH	IDENTITY = '<my_storage_account>',
		SECRET = '<my_secret_key>'

TO URL = N'https://<my_storage_account><container_name>/'
WITH CREDENTIAL = N'https://<my_storage_account><container_name>/'

But I'm getting the error:

Msg 3271, Level 16, State 1, Line 11
A nonrecoverable I/O error occurred on file "https://<my_storage_account><container_name>/" 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 11
BACKUP DATABASE is terminating abnormally.

I've made sure the "Account kind" is "General purpose", that didn't work, and I'm now at a bit of a loss as to where to go next. This is with SQL Server 2016, and I get the same error if I try and execute this via PowerShell and Backup-SqlDatabase (hint: I'm trying to write a PowerShell script so that I can schedule backups to Azure). Any suggestions are welcome!

About Rob

I've been interested in computing since the day my Dad purchased his first business PC (an Amstrad PC 1640 for anyone interested) which introduced me to MS-DOS batch programming and BASIC.

My skillset has matured somewhat since then, which you'll probably see from the posts here. You can read a bit more about me on the about page of the site, or check out some of the other posts on my areas of interest.

No Comments

Add a Comment