Azure SQL Creating Database Scoped Credential
Running the exactly T-SQL you posted against Microsoft SQL Azure (RTM) - 12.0.2000.8 May 4 2018 13:05:56 version leads to the following error:
Msg 102, Level 15, State 1, Line 1
Incorrect syntax near 'db-user'.
Replacing the identity name brackets for single quotes leads to the error below:
Msg 15581, Level 16, State 6, Line 1
Please create a master key in the database or open the master key in the session before performing this operation.
Creating the master key with following T-SQL allows me to create the credential successfully:
CREATE MASTER KEY ENCRYPTION BY PASSWORD='MyPassw0rdIsComplex.'
GO
CREATE DATABASE SCOPED CREDENTIAL [cred-name] WITH IDENTITY = 'db-user' , SECRET = 'password'
GO
Also, you can check if the scoped credential using the following query:
SELECT * FROM sys.database_scoped_credentials WHERE credential_identity='db-user'
I'm using SSMS version 17.2, but I'm not sure if this matters since errors would come from the SQL Server engine itself.