6

I am trying to deploy my ARM template and t failing on serverfarms creation step. I took example from Microsoft site Microsoft docks. I can't understand why it happens

Here is an error code, I change location fro North to West Europe,I try with variable incited of parameter. Nothing helps.

    Resource Microsoft.Web/serverfarms 'ASE-APP-SERVICE-PLAN' failed with message '{
  "Code": "NotFound",
  "Message": "Server farm with name ASE-APP-SERVICE-PLAN not found.",
  "Target": null,
  "Details": [
    {
      "Message": "Server farm with name ASE-APP-SERVICE-PLAN not found."
    },
    {
      "Code": "NotFound"
    },
    {
      "ErrorEntity": {
        "ExtendedCode": "11001",
        "MessageTemplate": "Server farm with name {0} not found.",
        "Parameters": [
          "ASE-APP-SERVICE-PLAN"
        ],
        "Code": "NotFound",
        "Message": "Server farm with name ASE-APP-SERVICE-PLAN not found."
      }
    }
  ],
  "Innererror": null
}'

Here is my simple arm template

{
"$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
"contentVersion": "1.0.0.0",
"parameters": {
    "aseName": {
        "type": "string",
        "defaultValue": "ASE-TEST",
        "metadata": {
            "description": "Name of the App Service Environment"
        }
    },
    "aseLocation": {
        "type": "string",
        "defaultValue": "West Europe",
        "metadata": {
            "description": "Location of the App Service Environment"
        }
    },
    "APP-SPLANName": {
        "type": "string",
        "defaultValue": "ASE-APP-SERVICE-PLAN",
        "metadata": {
            "description": "App service plan name"
        }
    }
},
"variables": {
  "ASE-VNetPrefix": "10.0.0.0/16",
  "ASE-VNetSubnet1Name": "Subnet-1",
  "ASE-VNetSubnet1Prefix": "10.0.0.0/24",
  "ASE-VNET-Name": "[concat('ASE-VNET', uniqueString(resourceGroup().id))]",
  "WEB-APP-ASEv2Name": "[concat('WEB-APP-ASEv2', uniqueString(resourceGroup().id))]"

},
"resources": [
    {
        "name": "[variables('ASE-VNET-Name')]",
        "type": "Microsoft.Network/virtualNetworks",
        "location": "[resourceGroup().location]",
        "apiVersion": "2016-03-30",
        "dependsOn": [],
        "tags": {
            "displayName": "ASE-VNET"
        },
        "properties": {
            "addressSpace": {
                "addressPrefixes": [
                    "[variables('ASE-VNetPrefix')]"
                ]
            },
            "subnets": [
                {
                    "name": "[variables('ASE-VNetSubnet1Name')]",
                    "properties": {
                        "addressPrefix": "[variables('ASE-VNetSubnet1Prefix')]"
                    }
                }
            ]
        }
    },
    {
        "apiVersion": "2015-08-01",
        "type": "Microsoft.Web/hostingEnvironments",
        "name": "[parameters('aseName')]",
        "kind": "ASEV2",
        "location": "[parameters('aseLocation')]",
        "dependsOn": [
            "[resourceId('Microsoft.Network/virtualNetworks', variables('ASE-VNET-Name'))]"
        ],
        "properties": {
            "name": "[parameters('aseName')]",
            "location": "[parameters('aseLocation')]",
            "virtualNetwork": {
                "Id": "[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',resourceGroup().name,'/providers/Microsoft.Network/virtualNetworks/', variables('ASE-VNET-Name'))]",
                "Subnet": "[variables('ASE-VNETSubnet1Name')]"
            }
        }
    },
    {
        "name": "[parameters('APP-SPLANName')]",
        "type": "Microsoft.Web/serverfarms",
        "location": "[parameters('aseLocation')]",
        "apiVersion": "2016-09-01",
        "tags": {},
        "properties": {
            "name": "[parameters('APP-SPLANName')]",
            "hostingEnvironmentProfile": {
                "id": "[resourceId('Microsoft.Web/hostingEnvironments', parameters('aseName'))]"
            }
        },
        "sku": {
            "name": "I1",
            "tier": "Isolated",
            "size": "I1",
            "family": "I",
            "capacity": 0
        },
        "dependsOn": [
            "[resourceId('Microsoft.Web/hostingEnvironments', parameters('aseName'))]"
        ]
    },
  {
    "name": "[variables('WEB-APP-ASEv2Name')]",
    "type": "Microsoft.Web/sites",
    "location": "[resourceGroup().location]",
    "apiVersion": "2016-08-01",
    "tags": {},
    "properties": {
        "name": "[variables('WEB-APP-ASEv2Name')]",
        "hostingEnvironmentProfile": {
            "id": "[resourceId('Microsoft.Web/hostingEnvironments', parameters('aseName'))]"
        },
        "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('APP-SPLANName'))]"
    },
    "dependsOn": [
        "[resourceId('Microsoft.Web/serverfarms', parameters('APP-SPLANName'))]",
        "[resourceId('Microsoft.Web/hostingEnvironments', parameters('aseName'))]"
    ]
  }
]

}

user6329667
  • 447
  • 1
  • 5
  • 16
  • I try to repro the issue with Visual Stduio 2017 to deploy the ASE, then I got `The access token expiry UTC time xxxx is earlier than current UTC time xxxx`. – Tom Sun - MSFT Aug 14 '17 at 09:58
  • @TomSun because VS is not updating access token. Look in Azure portal you will see that it still deploying basically I lunch twice VS first time it create empty ASE and failing then I lunch again and see the issue. – user6329667 Aug 14 '17 at 11:05

5 Answers5

8

I ran into this same message but for a slightly different reason.

Based on the wording of the message, I thought I had goofed the serverFarmId property on the function app. Kept making sure that my resourceId function was correct :

"serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('appServicePlan').name)]"

It was correct. Issue was that I accidentally had the Function App in a different Azure Region than the App Service Plan it was referencing. Worth noting that this error can be caused by that.

Dharman
  • 30,962
  • 25
  • 85
  • 135
Ryan D
  • 1,023
  • 11
  • 16
3

I also can reproduce the issue that you mentioned with you mentioned template. I try to use Azure portal to create the service plan then I get ARM template as following

 "resources": [
        {
            "apiVersion": "2016-03-01",
            "name": "[parameters('name')]",
            "type": "Microsoft.Web/serverfarms",
            "location": "[parameters('location')]",
            "kind": "",
            "properties": {
                "name": "[parameters('name')]",
                "workerSize": "[parameters('workerSize')]",
                "workerSizeId": "[parameters('workerSizeId')]",
                "numberOfWorkers": "[parameters('numberOfWorkers')]",
                "reserved": false,
                "hostingEnvironment": "[parameters('hostingEnvironment')]"
            },
            "sku": {
                "Tier": "[parameters('sku')]",
                "Name": "[parameters('skuCode')]"
            }
        }
    ]

enter image description here

So I change the creating service farm with following code, it works correctly on my side.

        {
                "type": "Microsoft.Web/serverfarms",
                "sku": {
                    "Tier": "Isolated",
                    "Name": "I1"
                },
                "kind": "",
                "name": "[parameters('APP-SPLANName')]",
                "apiVersion": "2016-03-01",
                "location": "[parameters('aseLocation')]",
                "properties": {
                    "name": "[parameters('APP-SPLANName')]",
                    "workerSize": "Small",
                    "workerSizeId": 0,
                    "numberOfWorkers": 1,
                    "reserved": false,
                    "hostingEnvironment": "[parameters('aseName')]"
                },
                "dependsOn": [
                    "[resourceId('Microsoft.Web/hostingEnvironments', parameters('aseName'))]"
                ]
            }

enter image description here

The Whole template I used:

{
    "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "aseName": {
            "defaultValue": "ASE-TEST",
            "type": "String",
            "metadata": {
                "description": "Name of the App Service Environment"
            }
        },
        "aseLocation": {
            "defaultValue": "West Europe",
            "type": "String",
            "metadata": {
                "description": "Location of the App Service Environment"
            }
        },
        "APP-SPLANName": {
            "defaultValue": "ASE-APP-SERVICE-PLAN",
            "type": "String",
            "metadata": {
                "description": "App service plan name"
            }
        }
    },
    "variables": {
        "ASE-VNetPrefix": "10.0.0.0/16",
        "ASE-VNetSubnet1Name": "Subnet-1",
        "ASE-VNetSubnet1Prefix": "10.0.0.0/24",
        "ASE-VNET-Name": "[concat('ASE-VNET', uniqueString(resourceGroup().id))]",
        "WEB-APP-ASEv2Name": "[concat('WEB-APP-ASEv2', uniqueString(resourceGroup().id))]"
    },
    "resources": [
        {
            "type": "Microsoft.Network/virtualNetworks",
            "name": "[variables('ASE-VNET-Name')]",
            "apiVersion": "2016-03-30",
            "location": "[resourceGroup().location]",
            "tags": {
                "displayName": "ASE-VNET"
            },
            "properties": {
                "addressSpace": {
                    "addressPrefixes": [
                        "[variables('ASE-VNetPrefix')]"
                    ]
                },
                "subnets": [
                    {
                        "name": "[variables('ASE-VNetSubnet1Name')]",
                        "properties": {
                            "addressPrefix": "[variables('ASE-VNetSubnet1Prefix')]"
                        }
                    }
                ]
            },
            "dependsOn": []
        },
        {
            "type": "Microsoft.Web/hostingEnvironments",
            "kind": "ASEV2",
            "name": "[parameters('aseName')]",
            "apiVersion": "2015-08-01",
            "location": "[parameters('aseLocation')]",
            "properties": {
                "name": "[parameters('aseName')]",
                "location": "[parameters('aseLocation')]",
                "virtualNetwork": {
                    "Id": "[concat('/subscriptions/',subscription().subscriptionId,'/resourceGroups/',resourceGroup().name,'/providers/Microsoft.Network/virtualNetworks/', variables('ASE-VNET-Name'))]",
                    "Subnet": "[variables('ASE-VNETSubnet1Name')]"
                }
            },
            "dependsOn": [
                "[resourceId('Microsoft.Network/virtualNetworks', variables('ASE-VNET-Name'))]"
            ]
        },
        {
            "type": "Microsoft.Web/serverfarms",
            "sku": {
                "Tier": "Isolated",
                "Name": "I1"
            },
            "kind": "",
            "name": "[parameters('APP-SPLANName')]",
            "apiVersion": "2016-03-01",
            "location": "[parameters('aseLocation')]",
            "properties": {
                "name": "[parameters('APP-SPLANName')]",
                "workerSize": "Small",
                "workerSizeId": 0,
                "numberOfWorkers": 1,
                "reserved": false,
                "hostingEnvironment": "[parameters('aseName')]"
            },
            "dependsOn": [
                "[resourceId('Microsoft.Web/hostingEnvironments', parameters('aseName'))]"
            ]
        },
        {
            "type": "Microsoft.Web/sites",
            "name": "[variables('WEB-APP-ASEv2Name')]",
            "apiVersion": "2016-08-01",
            "location": "[resourceGroup().location]",
            "tags": {},
            "properties": {
                "name": "[variables('WEB-APP-ASEv2Name')]",
                "hostingEnvironmentProfile": {
                    "id": "[resourceId('Microsoft.Web/hostingEnvironments', parameters('aseName'))]"
                },
                "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('APP-SPLANName'))]"
            },
            "dependsOn": [
                "[resourceId('Microsoft.Web/serverfarms', parameters('APP-SPLANName'))]",
                "[resourceId('Microsoft.Web/hostingEnvironments', parameters('aseName'))]"
            ]
        }
    ]
}
Tom Sun - MSFT
  • 24,161
  • 3
  • 30
  • 47
  • I try your solution and basically I got 2 types of errors. First if I deploy on West Europe I got same error as I got previously and if I deploy on north Europe I got conflict the pricing tier 'Isolated' is not allowed in this resource group. Could you tell me what location did you use for deployment? – user6329667 Aug 17 '17 at 07:31
  • I used the West Europe location for test, you could get it from the screenshot. – Tom Sun - MSFT Aug 17 '17 at 07:48
  • Based on my experience, if you have created the host enviroment in the azure portal. Please have a try to create the service farm from Azure portal, before creating that we could get the creating azure server farm ARM template and the paramter value. And then try to deploy it with whole ARM template to another resource group to check. It works correctly on my side. It will take long time to test it. – Tom Sun - MSFT Aug 17 '17 at 07:58
1

In my situation, I had the wrong location for the server farm so the deployment process was looking at the wrong location for the service plan. Once I fixed it, the error went away.

Karr
  • 395
  • 5
  • 9
0

For me, I wasn't using an ARM template but I was getting this error message because I picked a linux-based resource group, but had picked a Windows operating system for my web app deployment. Once I switched my OS to Linux, it worked just fine.

SauerTrout
  • 471
  • 1
  • 8
  • 13
0

I add the same issue when working with Pulumi and configuring an AppServicePlan for an application. The issues was that my new WebApp was located in West Europe, while AppServicePlan was located in the North Europe. I solved the issue by making both WebApp and AppServicePlan use location location of the resource group.

senja20
  • 1
  • 1