Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to grant Database scope credentials to users in Azure SQL Database

I've Azure SQL Database, where we will bulk load the CSV files from azure blob to SQL table.

So far we can easily able to do that with the admin credentials.

The below query is working under admin credentials but not working for normal user credentials

CREATE DATABASE SCOPED CREDENTIAL MyAzureBlobStorageCredential
WITH IDENTITY = 'SHARED ACCESS SIGNATURE',
SECRET = 'WoZ0ZnpXzvdAKoCPRrsa7Rniq7SNjAcZxL..............';

I'm getting an error as

User does not have permission to perform this action.

So I've tried to grant the access for the user from here

GRANT CREATE ON DATABASE SCOPED CREDENTIAL::AZUREBLOBSTORAGECREDENTIALPERMISSION TO MYUSER

The above grant has some syntax error like below.

Incorrect syntax near DATABASE.

like image 283
Jayendran Avatar asked Sep 17 '25 01:09

Jayendran


2 Answers

Looking at the official documentation the statement GRANT permission ON DATABASE SCOPED CREDENTIAL does not support CREATE as a possible permission. The permissions this statement supports are: CONTROL, TAKE OWNERSHIP, ALTER, REFERENCES AND VIEW DEFINITION. Probably the following statement may work for you:

GRANT CONTROL ON DATABASE SCOPED CREDENTIAL::AZUREBLOBSTORAGECREDENTIALPERMISSION TO MYUSER
like image 174
Alberto Morillo Avatar answered Sep 19 '25 17:09

Alberto Morillo


From the docs, it requires CONTROL permission on the database.

USE AdventureWorks2012;  
GRANT CONTROL ON DATABASE::AdventureWorks2012 TO Sarah;  
GO 

See this link for further detail.

like image 35
Murray Foxcroft Avatar answered Sep 19 '25 16:09

Murray Foxcroft