title: Azure ARM Deployment what is the hostingEnvironment?
body: <p>I'm attempting to deploy to a new resource group containing an existing app service plan in Azure using an ARM script. If I run the deployment through the Azure Portal UI, it is successful. The issue happens when I try to download the template ARM script for the deployment and use that. </p>
  
  <p>I'm attempting to create a Web app and associated application insights instance. </p>
  
  <p>Here is my template.json</p>
  
  <pre><code>{
      "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
          "subscriptionId": {
              "type": "string"
          },
          "name": {
              "type": "string"
          },
          "location": {
              "type": "string"
          },
          "hostingEnvironment": {
              "type": "string"
          },
          "hostingPlanName": {
              "type": "string"
          },
          "serverFarmResourceGroup": {
              "type": "string"
          },
          "alwaysOn": {
              "type": "bool"
          },
          "currentStack": {
              "type": "string"
          }
      },
      "resources": [
          {
              "apiVersion": "2018-02-01",
              "name": "[parameters('name')]",
              "type": "Microsoft.Web/sites",
              "location": "[parameters('location')]",
              "tags": {},
              "dependsOn": [
                  "microsoft.insights/components/LicensingService-API"
              ],
              "properties": {
                  "name": "[parameters('name')]",
                  "siteConfig": {
                      "appSettings": [
                          {
                              "name": "APPINSIGHTS_INSTRUMENTATIONKEY",
                              "value": "[reference('microsoft.insights/components/LicensingService-API', '2015-05-01').InstrumentationKey]"
                          },
                          {
                              "name": "ApplicationInsightsAgent_EXTENSION_VERSION",
                              "value": "~2"
                          },
                          {
                              "name": "XDT_MicrosoftApplicationInsights_Mode",
                              "value": "default"
                          },
                          {
                              "name": "DiagnosticServices_EXTENSION_VERSION",
                              "value": "disabled"
                          },
                          {
                              "name": "APPINSIGHTS_PROFILERFEATURE_VERSION",
                              "value": "disabled"
                          },
                          {
                              "name": "APPINSIGHTS_SNAPSHOTFEATURE_VERSION",
                              "value": "disabled"
                          },
                          {
                              "name": "InstrumentationEngine_EXTENSION_VERSION",
                              "value": "disabled"
                          },
                          {
                              "name": "SnapshotDebugger_EXTENSION_VERSION",
                              "value": "disabled"
                          },
                          {
                              "name": "XDT_MicrosoftApplicationInsights_BaseExtensions",
                              "value": "disabled"
                          }
                      ],
                      "metadata": [
                          {
                              "name": "CURRENT_STACK",
                              "value": "[parameters('currentStack')]"
                          }
                      ],
                      "alwaysOn": "[parameters('alwaysOn')]"
                  },
                  "serverFarmId": "[concat('/subscriptions/', parameters('subscriptionId'),'/resourcegroups/', parameters('serverFarmResourceGroup'), '/providers/Microsoft.Web/serverfarms/', parameters('hostingPlanName'))]",
                  "hostingEnvironment": "[parameters('hostingEnvironment')]",
                  "clientAffinityEnabled": true
              }
          },
          {
              "apiVersion": "2015-05-01",
              "name": "LicensingService-API",
              "type": "microsoft.insights/components",
              "location": "westus2",
              "tags": {},
              "properties": {
                  "ApplicationId": "[parameters('name')]",
                  "Request_Source": "IbizaWebAppExtensionCreate"
              }
          }
      ]
  }
  </code></pre>
  
  <p>And my parameters.json</p>
  
  <pre><code>{
      "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
      "contentVersion": "1.0.0.0",
      "parameters": {
          "subscriptionId": {
              "value": "REMOVED"
          },
          "name": {
              "value": "LicensingService-API"
          },
          "location": {
              "value": "West US 2"
          },
          "hostingEnvironment": {
              "value": ""
          },
          "hostingPlanName": {
              "value": "LicensingServiceProductionAppServicePlan"
          },
          "serverFarmResourceGroup": {
              "value": "LicensingServicePROD"
          },
          "alwaysOn": {
              "value": true
          },
          "currentStack": {
              "value": "dotnetcore"
          }
      }
  }
  </code></pre>
  
  <p>There is one particular parameter that I'm having issues with. It is the "hostingEnvironment" parameter. I am unable to determine what should be placed in that field, as the default template provided by Azure leaves this blank. If I enter a value here (LicensingServiceProductionAppServicePlan for example), I get an error on the deployment of the web app that reads:</p>
  
  <pre><code>{
    "Code": "NotFound",
    "Message": "Cannot find Stamp with name LicensingServiceProductionAppServicePlan.",
    "Target": null,
    "Details": [
      {
        "Message": "Cannot find Stamp with name LicensingServiceProductionAppServicePlan."
      },
      {
        "Code": "NotFound"
      },
      {
        "ErrorEntity": {
          "ExtendedCode": "51004",
          "MessageTemplate": "Cannot find {0} with name {1}.",
          "Parameters": [
            "Stamp",
            "LicensingServiceProductionAppServicePlan"
          ],
          "Code": "NotFound",
          "Message": "Cannot find Stamp with name LicensingServiceProductionAppServicePlan."
        }
      }
    ],
    "Innererror": null
  }
  </code></pre>
  
  <p>If I instead remove the parameter from both the template and the parameters files, as suggested in <a href="https://stackoverflow.com/questions/40019741/azure-resource-manager-template-hostingenvironment">this answer</a>, I get a BadRequest error that reads: </p>
  
  <pre><code>{
    "error": {
      "code": "InvalidTemplate",
      "message": "Unable to process template language expressions for resource '/subscriptions/REMOVED/resourceGroups/LicensingServicePROD/providers/Microsoft.Web/serverfarms/LicensingServicePROD' at line '151' and column '9'. 'The template parameter 'hostingEnvironment' is not found. Please see https://aka.ms/arm-template/#parameters for usage details.'",
      "additionalInfo": [
        {
          "type": "TemplateViolation",
          "info": {
            "lineNumber": 151,
            "linePosition": 9,
            "path": ""
          }
        }
      ]
    }
  }
  </code></pre>
  
  <p>Likely this is because I can see that the "hostingEnvironment" parameter is used in the template script. 
  So I'm left wondering why this works when done through the Azure UI but not from the script generated from the UI. My final question that I'm looking to solve is what is the value that should be provided for the "hostingEnvironment" parameter?</p>