0

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 ?

user1037747
  • 1,307
  • 2
  • 18
  • 38
  • Could you tell us how you use the access token to connect to the SQL query or share us piece of your code? Ref this tutorial https://techcommunity.microsoft.com/t5/azure-database-support-blog/azure-sql-database-token-based-authentication-with-powershell/ba-p/369078 and may be helpful. – Leon Yue Aug 14 '20 at 01:39

2 Answers2

0

I think the token it's expired.

As per the doc az account get-access-token: The token will be valid for at least 5 minutes with the maximum at 60 minutes.

Please try to re-generate a new one, and give it a try.

Ivan Glasenberg
  • 29,865
  • 2
  • 44
  • 60
0

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

user1037747
  • 1,307
  • 2
  • 18
  • 38