SQL SERVER – Msg 3225: Use of WITH CREDENTIAL Syntax is Not Valid for Credentials Containing a Shared Access Signature

SQL
4 Comments

One of my blog readers was having trouble with backup to URL using SAS token. He followed my below blog to fix his issue. SQL SERVER – Backup to URL error: Operating system error 50(The request is not supported.) Now let us look in this blog post how we can fix errors related to credentials.

So far, so good! Later he was unable to take a backup using maintenance plan. He contacted me, and it was sounding very interesting to me. He informed that he is getting below errors when he configures backup to URL using maintenance plan.

Executing the query “BACKUP DATABASE [master] TO URL = N’https://sqlau…” failed with the following error: “Use of WITH CREDENTIAL syntax is not valid for credentials containing a Shared Access Signature.

BACKUP DATABASE is terminating abnormally.”. Possible failure reasons: Problems with the query, “ResultSet” property not set correctly, parameters not set correctly, or connection not established correctly.

So, I decided to reproduce the issue and created a maintenance plan.

SQL SERVER - Msg 3225: Use of WITH CREDENTIAL Syntax is Not Valid for Credentials Containing a Shared Access Signature bkp2url-err-01

As he explained me, the backup failed! Looked into history

SQL SERVER - Msg 3225: Use of WITH CREDENTIAL Syntax is Not Valid for Credentials Containing a Shared Access Signature bkp2url-err-02

Use “View T-SQL” hyperlink and found below query.

BACKUP DATABASE [master] TO URL = N'LONG_URL_HERE_'
WITH CREDENTIAL = N'https://sqlauthsqlbackups.blob.core.windows.net/sqlauthcontainer',
NOFORMAT, NOINIT, NAME = N'master_backup_2017_12_07_222756_5893177',
SKIP, REWIND, NOUNLOAD, STATS = 10
GO

When I ran above in SSMS, it failed with error

Msg 3225, Level 16, State 1, Line 1
Use of WITH CREDENTIAL syntax is not valid for credentials containing a Shared Access Signature.
Msg 3013, Level 16, State 1, Line 1
BACKUP DATABASE is terminating abnormally.

WORKAROUND/SOLUTION

I looked around in the documentation and found this document.

To create a striped backup set, a SQL Server file-snapshot backup, or a SQL credential using Shared Access token, you must use Transact-SQL, Powershell or C# rather than the Backup task in Maintenance Plan Wizard.

This confirms that Microsoft doesn’t support taking backup to URL using SAS token via maintenance plan. Now, the only option left is to use T-SQL and schedule that as a job. Painful!

Well, not to worry! You can use below script to generate backup file name with date time and schedule it in the job. How to Add Date to Database Backup Filename? – Interview Question of the Week #109

Please comment if you have encountered a similar error and found some other solution.

Reference: Pinal Dave (https://blog.sqlauthority.com)

, , , ,
Previous Post
SQL SERVER – Always On Availability Group Error 35250: The Connection to the Primary Replica is Not Active
Next Post
SQL SERVER – FIX: Msg 15150 – Cannot Alter The User ‘dbo’.

Related Posts

4 Comments. Leave new

Leave a Reply

Menu