Database scoped credential with managed identity

Pythonista 5 Reputation points
2023-08-28T13:26:38.55+00:00

Hi,

I'm trying to create scoped credentials for our SQL Serverless database, with our managed identity. I'm getting the following error when creating the credentials. Can someone help or explain how we can fix this?

Thank you in advance!

User's image

Azure SQL Database
{count} vote

1 answer

Sort by: Most helpful
  1. Oury Ba-MSFT 21,126 Reputation points Microsoft Employee Moderator
    2023-08-28T21:40:07.74+00:00

    Pythonista

    The correct syntax is

    CREATE DATABASE SCOPED CREDENTIAL credential_name
    WITH IDENTITY = 'identity_name'
        [ , SECRET = 'secret' ]
    

    Before creating a database scoped credential, the database must have a master key to protect the credential. For more information, see CREATE MASTER KEY (Transact-SQL).

    When IDENTITY is a Windows user, the secret can be the password. The secret is encrypted using the service master key. If the service master key is regenerated, the secret is re-encrypted using the new service master key.

    https://learn.microsoft.com/en-us/sql/t-sql/statements/create-database-scoped-credential-transact-sql?view=sql-server-2017

    Regards,

    Oury

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.