##[error]ResourceNotFound: The Resource 'Microsoft.Web/sites/xx' under resource group 'yy' was not found in deploying ARM template

Viewed 628

I am getting resource not found in resource group error while deploying arm template.Could someone help please .Below is the sample template used:

{
      "name": "[variables('AppName')]",
      "type": "Microsoft.Web/sites",
      "apiVersion": "2016-08-01",
      "kind": "app",
      "location": "xx",
      "identity": {
        "type": "SystemAssigned"
      },
      "properties": {
        "httpsOnly": true,
        "clientAffinityEnabled": false,
        "serverFarmId": "xx"
      },
      "resources": [
        {
          "name": "appsettings",
          "type": "config",
          "apiVersion": "2016-08-01",
          "properties": {
       xx:xx
          },
          "dependsOn": [
            "[resourceId('Microsoft.Web/sites', variables('AppName'))]",
            "[resourceId('Microsoft.KeyVault/vaults/secrets', variables('keyVaultName'),'xx')]",
            "[resourceId('Microsoft.KeyVault/vaults/secrets', variables('keyVaultName'),'xx')]",
            "[resourceId('Microsoft.KeyVault/vaults/secrets', variables('keyVaultName'),'xx')]"
          ]
        }
      ]
    },
   {
      "type": "Microsoft.Web/sites/config",
      "apiVersion": "2016-08-01",
      "name": "[concat(variables('AppName'), '/web')]",
      "location": "xx",
      "dependsOn": [
        "[resourceId('Microsoft.Web/sites', variables('AppName'))]"
      ],
}

Let me know is this the right way to do

2 Answers

its hard to tell without having the exact template and all the variables\parameters, but generally it means one of the following:

  1. wrong name used for the resources that depend on the webapp somewhere
  2. wrong location used for the resources that depend on the webapp somewhere
  3. dependsOn isn't setup properly and it doesnt wait for the webapp and attempts to create a resource in parallel with the web app

Have you ever use the same ARM template to deploy succeed? Also kindly check if you could directly use script to deploy locally successful without using Azure DevOps. This will help to narrow down the issue.

##[error]ResourceNotFound: The Resource 'Microsoft.Web/sites/xx' under resource group 'yy' was not found in deploying ARM template

This error indicate Resource Manager needs to retrieve the properties for a resource, but can't find the resource in your subscriptions.

You could give a try with below solution:

  • Solution 1 - check resource properties
  • Solution 2 - set dependencies
  • Solution 3 - get external resource
  • Solution 4 - get managed identity from resource
  • Solution 5 - check functions

More details please take a look at our official doc here-- Resolve resource not found errors

Related