Search code examples
azureazure-sql-databaseazure-sql-server

Unable to connect SQL Azure through Access Token generated through bearer token


I was trying to connect my SQL Azure Queries through Bearer token which is generated through this query

$token= & az account get-access-token --resource=https://database.windows.net/ --query accessToken

Since today it says "Login failed for user ''"

I have not done any major changes in my environment, as even locally the script does not work

Once i get the access token then I Connect SQL server, Firewall settings are all fine. I am the server Admin of my DB, Is there something which i check further ?


Solution

  • I was executing the script from DevOps pipeline as a Task of Azure CLI.. So i had used service principal (connection string) as an Admin in SQL Server from Azure Portal manually. It was working fine

    When i tried to Automate the same by adding Service Principal as an administrator through ARM template, it showed it had applied the same in Azure portal, but when executing the pipeline it said login failed

    So to resolve the issue I had to manually apply service principal as an Admin in Azure portal