Azure App Service deploy Failed to get resource ID for resource type 'Microsoft.Web/Sites'

Ruy Ruiz picture Ruy Ruiz · Sep 25, 2019 · Viewed 8k times · Source

In the last 6 months I have been releasing with a pipeline in Azure DevOps, but today I receive the following error:

2019-09-25T14:24:38.4296875Z ##[section]Starting: Azure App Service Deploy: AS-ServiciosNegocio-API-UAT
2019-09-25T14:24:38.4419797Z ==============================================================================
2019-09-25T14:24:38.4419900Z Task         : Azure App Service deploy
2019-09-25T14:24:38.4419986Z Description  : Deploy to Azure App Service a web, mobile, or API app using Docker, Java, .NET, .NET Core, Node.js, PHP, Python, or Ruby
2019-09-25T14:24:38.4420053Z Version      : 3.4.31
2019-09-25T14:24:38.4420117Z Author       : Microsoft Corporation
2019-09-25T14:24:38.4420182Z Help         : https://docs.microsoft.com/azure/devops/pipelines/tasks/deploy/azure-rm-web-app-deployment
2019-09-25T14:24:38.4420291Z ==============================================================================
2019-09-25T14:24:39.1630446Z Got connection details for Azure App Service:'AS-ServiciosNegocio-API-UAT'
2019-09-25T14:24:39.3091141Z ##[error]Error: Failed to get resource ID for resource type 'Microsoft.Web/Sites' and resource name 'AS-ServiciosNegocio-API-UAT'. Error: Could not fetch access token for Azure. Verify if the Service Principal used is valid and not expired.
2019-09-25T14:24:39.3140156Z ##[section]Finishing: Azure App Service Deploy: AS-ServiciosNegocio-API-UAT

Answer

ecraig12345 picture ecraig12345 · Jul 17, 2020

If your existing service connection is the "Azure Resource Manager using service principal (automatic)" type (not manual), there's a simple but non-obvious way to renew the token.

Go to the service connection's settings page in Azure Devops as described in the other answers. Click Edit and then Save without making any other changes. Assuming you have the right permissions, it will automatically get a new token.

(Figured this out from this forum comment.)