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>.blob.core.windows.net/<container_name>/')
BEGIN
	DROP CREDENTIAL [https://<my_storage_account>.blob.core.windows.net/<container_name>/]
END

CREATE CREDENTIAL [https://<my_storage_account>.blob.core.windows.net/<container_name>/]
WITH	IDENTITY = '<my_storage_account>',
		SECRET = '<my_secret_key>'


BACKUP DATABASE [www.robertwray.co.uk]
TO URL = N'https://<my_storage_account>.blob.core.windows.net/<container_name>/www.robertwray.co.uk.bak'
WITH CREDENTIAL = N'https://<my_storage_account>.blob.core.windows.net/<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>.blob.core.windows.net/<container_name>/www.robertwray.co.uk.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 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!


No Comments

Add a Comment