Resolve resource not plant errors

This article describes the fault yous run into when a resources can't be found during an functioning. Typically, yous see this fault when deploying resources with a Bicep file or Azure Resource Manager template (ARM template). You also run into this error when doing direction tasks and Azure Resources Managing director can't find the required resources. For example, if yous attempt to add tags to a resource that doesn't exist, you receive this mistake.

Symptom

There are ii error codes that betoken the resource can't be found. The NotFound error returns a issue like to:

              Code=NotFound; Message=Cannot find ServerFarm with name exampleplan.                          

The ResourceNotFound error returns a outcome similar to:

              Code=ResourceNotFound; Bulletin=The Resource 'Microsoft.Storage/storageAccounts/{storage name}' under resource group {resource group name} was non found.                          

Cause

Resources Manager needs to retrieve the properties for a resources, simply tin can't detect the resources in your subscription.

Solution 1 - check resources backdrop

When you receive this error while doing a management task, check the values y'all provided for the resource. The iii values to check are:

  • Resources name
  • Resource grouping name
  • Subscription

If you're using PowerShell or Azure CLI, cheque that you lot're running commands in the subscription that contains the resource. You can alter the subscription with Prepare-AzContext or az account set. Many commands provide a subscription parameter that lets you specify a different subscription than the current context.

If you tin't verify the properties, sign in to the Microsoft Azure portal. Notice the resources y'all're trying to use and examine the resource name, resource grouping, and subscription.

Solution 2 - prepare dependencies

If yous get this error when deploying a template, you may demand to add a dependency. Resource Manager optimizes deployments by creating resource in parallel, when possible.

For example, when y'all deploy a web app, the App Service plan must exist. If you oasis't specified that the web app depends on the App Service plan, Resource Manager creates both resource at the same time. The web app fails with an error that the App Service plan resources can't be plant because it doesn't exist all the same. You prevent this error by setting a dependency in the web app.

  • Bicep
  • JSON

Use an implicit dependency rather than the resourceId office. The dependency is created using a resources'due south symbolic name and ID property.

For example, the web app's serverFarmId property uses servicePlan.id to create a dependency on the App Service plan.

                  resource webApp 'Microsoft.Spider web/sites@2021-02-01' = {   properties: {     serverFarmId: servicePlan.id   } }  resource servicePlan 'Microsoft.Web/serverfarms@2021-02-01' = {   name: hostingPlanName   ...                                  

For well-nigh deployments, it's not necessary to use dependsOn to create an explicit dependency.

Avert setting dependencies that aren't needed. Unnecessary dependencies prolong the deployment's elapsing because resources aren't deployed in parallel. Also, you might create circular dependencies that block the deployment.

Deployment order

When you lot see dependency bug, you lot need to gain insight into the society of resource deployment. You lot can use the portal to view the order of deployment operations:

  1. Sign in to the portal.

  2. From the resource group's Overview, select the link for the deployment history.

    Screenshot that highlights the link to a resource group's deployment history.

  3. For the Deployment name you desire to review, select Related events.

    Screenshot that highlights the link to a deployment's related events.

  4. Examine the sequence of events for each resource. Pay attention to the status of each operation and it'due south time postage. For example, the following prototype shows three storage accounts that deployed in parallel. Notice that the three storage accounts are started at the same time.

    Screenshot of activity log for resources deployed in parallel.

    The next image shows three storage accounts that aren't deployed in parallel. The second storage business relationship depends on the first storage account, and the third storage account depends on the second storage account. The outset storage account is labeled Started, Accepted, and Succeeded earlier the next is started.

    Screenshot of activity log for resources deployed in sequential order.

Solution iii - get external resource

  • Bicep
  • JSON

Bicep uses the symbolic proper noun to create an implicit dependency on another resource. The existing keyword references a deployed resource. If an existing resources is in a different resource grouping than the resource you want to deploy, include scope and use the resourceGroup function.

In this example, a web app is deployed that uses an existing App Service plan from another resource group.

                  resource servicePlan 'Microsoft.Web/serverfarms@2021-02-01' existing = {   proper noun: hostingPlanName   telescopic: resourceGroup(rgname) }  resource webApp 'Microsoft.Web/sites@2021-02-01' = {   proper noun: siteName   backdrop: {     serverFarmId: servicePlan.id   } }                                  

Solution 4 - get managed identity from resource

  • Bicep
  • JSON

If y'all're deploying a resource with a managed identity, you must look until that resource is deployed before retrieving values on the managed identity. Use an implicit dependency for the resources that the identity is applied to. This arroyo ensures the resource and the managed identity are deployed before Resource Manager uses the dependency.

You can get the principal ID and tenant ID for a managed identity that'south applied to a virtual auto. For example, if a virtual machine resource has a symbolic name of vm, use the following syntax:

                  vm.identity.principalId  vm.identity.tenantId                                  

Solution 5 - check functions

  • Bicep
  • JSON

Y'all can employ a resource's symbolic name to get values from a resource. You tin can reference a storage account in the aforementioned resource group or some other resource group using a symbolic name. To get a value from a deployed resource, apply the existing keyword. If a resource is in a unlike resources group, use scope with the resourceGroup function. For almost cases, the reference role isn't needed.

The following example references an existing storage account in a different resource group.

                  resources stgAcct 'Microsoft.Storage/storageAccounts@2021-06-01' existing = {   name: stgname   scope: resourceGroup(rgname) }                                  

Solution 6 - after deleting resource

When you delete a resource, there might exist a brusk corporeality of time when the resource appears in the portal but isn't available. If you select the resource, you'll go an error that the resource is Non institute.

Screenshot of deleted resource in portal that shows resource not found.

Refresh the portal and the deleted resource should exist removed from your list of bachelor resource. If a deleted resources continues to be shown every bit available for more than a few minutes, contact support.