Error: Failed to get resource ID for resource type Microsoft.Web/Sites

24 June 2023 | Viewed 3363 times

Error: Failed to get resource ID for resource type 'Microsoft.Web/Sites' and resource name 'AppService-Name'.
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

You might face this exception when you try to deploy an App Service using Azure Pipelines, if the access token is expired.

If the Service Connection is the Azure Resource Manager using Service Principal - Automatic, we can renew the access token.

Follow below steps to renew the access token.

  1. Goto your project in Azure DevOps Portal
  2. Click on Project Settings (bottom left)
  3. Click on Service Connections under Pipelines section
  4. Locate your Service Connection and open it.
  5. Edit and Save (without making any changes)

Access Toke will be renewed automatically. Then navigate to your pipeline and Run It and deployment will be successful.