简体   繁体   中英

Getting Error: Could not fetch access token for Azure when deploying using Azure DEVOPS

I am trying to deploy a APP using Azure DEVOPS CI/CD Pipelines, however I am receiving the following error:

2022-01-19T19:55:37.5454688Z ##[error]Error: Failed to fetch App Service 'xxxxx' publishing credentials. Error: Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired. For more information refer https://aka.ms/azureappservicedeploytsg

I checked the Client Secret and they are expired. I asked to the admin create a new one, however still receiving the same error when deploying.

Anyone have an idea? Can be because we still have these two expired keys? Do I have to change something in appsettings? (I do not think so right?)

硒

The problem was because I had to configure the new Secret Key in AZURE DEVOPS Connection.

Thanks

I tried this first (there was an expired secret):

In my failing Azure Pipleine in the "Azure Web App Deploy" task, I selected the Manage link in the Azure subscription section. This took my to the Azure Portal project where I selected the Service connections option from the meu under Pipelines. I clicked on "Manage Service Principal" and an expired Client Secret was listed. I generated a new one and deleted the old one.

When that did not fix my issue, I then did the following:

Went to Azure Dev Ops Project Setting: Pipeline > Service connections My Production app has a Github Service connection, while all the other have an Azure Service connection.

So, I added a New service connection (Azure Resource Manager in my case). Updated my Pipeline with the new connection and it worked.

When getting this error on my build pipeline, I was able to follow the steps in this answer (copied below) to solve it. The only other thing I had to do was select a 'Resource group' before hitting Verify in step 5.

  1. Go to Project settings > Service connections , and then select the service connection you want to modify.

  2. Select Edit in the upper-right corner, and then make any change to your service connection. The easiest and recommended change is to add a description.

  3. Select Save to save the service connection. Don't try to verify the service connection at this step.

  4. Exit the service connection edit window, and then refresh the service connections page.

  5. Select Edit in the upper-right corner, and now select Verify . (You may need to select a valid Resource group first if one isn't already selected.)

  6. Select Save to save your service connection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM