0
votes

I got an issue when I built source using Azure DevOps:

##[error]Error: Failed to get resource ID for resource type 'Microsoft.Web/Sites' and resource name 'dev-app-service'. 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 have found many solutions to fix it but it still hasn't been. Looking forward to your help!

Thanks.

2

2 Answers

0
votes

Azure App Service Deploy task uses the service principal in the service connection to authenticate with Azure. If the service principal has expired or doesn't have permissions to the App Service, the task fails with this error. You need to verify the validity of the service principal used and that it's present in the app registration.

You could check Use role-based access control to manage access to your Azure subscription resources and solution in case Azure DevOps unable to deploy to Azure Web App.

Or you can try to create a new Azure service connection in DevOps.

The following blog also contains more information about using service principal authentication:

https://devblogs.microsoft.com/devops/automating-azure-resource-group-deployment-using-a-service-principal-in-visual-studio-online-buildrelease-management/

0
votes

How are you deploying the Web App? If it's through a pipeline you have to set up an APP Service connection.

Here are three great tutorials on how to do this, once you have set up the App Service Connection then you just reference it in your YAML code under Azure Subscription. As long as your not using a Management Group, this seems buggy right now...Currently have my own post about it on here..

Links to Tutorials: https://4bes.nl/2019/07/11/step-by-step-manually-create-an-azure-devops-service-connection-to-azure/

https://social.technet.microsoft.com/wiki/contents/articles/53094.azure-devops-integrate-with-an-azure-subscription-or-management-group.aspx

Microsoft Doc: https://docs.microsoft.com/en-us/azure/devops/pipelines/library/connect-to-azure?view=azure-devops