Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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 
like image 657
Ruy Ruiz Avatar asked Sep 25 '19 21:09

Ruy Ruiz


People also ask

How does Azure Resource Manager enable control over access to specific actions to resources?

A resource group can be used to scope access control for administrative actions. To manage a resource group, you can assign Azure Policies, Azure roles, or resource locks. You can apply tags to a resource group. The resources in the resource group don't inherit those tags.

How do I create a service connection in Azure DevOps?

In Azure DevOps, open the Service connections page from the project settings page. In TFS, open the Services page from the "settings" icon in the top menu bar. Choose + New service connection and select Azure Resource Manager. Choose Service Principal (manual) option and enter the Service Principal details.


2 Answers

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. (<YourDevAzureProject> Bottom Left → ⚙️ Project Settings → Pipelines subhead → Service Connections)

Click Edit and then Save without making any other changes. Assuming you have the right permissions, it will automatically get a new token.

NB: for some browsers you must enable pop-ups on dev.azure.com as it attempts to login to your azure account to get a list of resource groups.

(Figured this out from this forum comment.)

like image 105
ecraig12345 Avatar answered Sep 22 '22 15:09

ecraig12345


From reading others' comments/posts on this thread, the Azure UI might have changed so I'm posting the steps here for the later comers. I did what ecraig12345 suggested and it worked great!

  1. Go to the deployment pipeline where the error occurs and click on Edit
  2. Go to "Run on agent" task > Deploy Azure App Service
  3. Click on the Manage hyperlink next to Azure Subscription label (see screenshot below)
  4. Click on Edit
  5. Click Save

Steps 1 - 3 enter image description here

Step 4 enter image description here

Step 5

enter image description here

like image 20
NKD Avatar answered Sep 21 '22 15:09

NKD