How to manage Synapse Serverless SQL Pool AAD accounts using Azure DevOps pipelines

Janne Pasanen 25 Reputation points
2023-03-24T07:12:03.2766667+00:00

I'm trying to automate a Synapse deployment where the applications could connect to Synapse Serverless SQL Pool databases using managed identities. I have verified that the process works if I login to the database using an AAD account who belongs to the Synapse Administrators group. With that account, I'm able to create users using FROM EXTERNAL PROVIDER syntax. But how could I use DevOps yaml deployment tasks to achieve the same thing?

I've tried using a service principal belonging to the Synapse Administrators group, and then fetching an access token using Powershell, but to no avail.

$request = Invoke-RestMethod -Method POST -Uri $tokenUrl -Body @{ resource="https://database.windows.net"; grant_type="client_credentials"; client_id=$ClientId; client_secret=$ClientSecret } -ContentType $contentType

$access_token = $request.access_token

Invoke-Sqlcmd -ServerInstance "$synapseServerless-ondemand.sql.azuresynapse.net" -Database $Database -AccessToken $access_token -query $query

Response from Invoke-Sqlcmd command:

Invoke-Sqlcmd: Cannot open database

Azure SQL Database
Azure Synapse Analytics
Azure Synapse Analytics
An Azure analytics service that brings together data integration, enterprise data warehousing, and big data analytics. Previously known as Azure SQL Data Warehouse.
4,422 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,665 questions
{count} vote

Accepted answer
  1. Vinodh247-1375 11,301 Reputation points
    2023-03-25T10:53:55.88+00:00

    Hi

    Thanks for reaching out to Microsoft Q&A.

    Yes you will need to add the SP into the database as a user in order to access the synapse database.

    https://thomasthornton.cloud/2020/10/06/query-azure-sql-database-using-service-principal-with-powershell/

    Please Upvote and Accept as answer if the reply was helpful, this will be helpful to other community members.

    0 comments No comments

0 additional answers

Sort by: Most helpful