title: Setting Azure App Service server stack on a Bicep template
body: <p>I'm trying to deploy a .NET Core 3.1 Azure App Service on Linux using a Bicep template from Azure CLI. The app service and corresponding app service plan are deployed correctly but the app service stack settings are empty on the Azure portal and I have to set these manually. I tried setting the metadata property on the 'Microsoft.Web/sites' resource and also on the 'Microsoft.Web/sites/config' resource, but the result was the same.</p>
  <p>This is my app service plan:</p>
  <pre><code>resource appServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = {
    name: 'MyAppService'
    location: resourceGroup().location
    properties: {
      reserved: true
    }
    sku: {
      name: 'P1v2'
    }
    kind: 'linux'
  }
  </code></pre>
  <p>Here is my first attempt to set the stack using 'Microsoft.Web/sites' as suggested here:</p>
  <p><a href="https://github.com/Azure/bicep/issues/3314" rel="nofollow noreferrer">https://github.com/Azure/bicep/issues/3314</a></p>
  <pre><code>resource appService 'Microsoft.Web/sites@2021-02-01' = {
    name: 'MyApp'
    location: resourceGroup().location
    identity: {
      type: 'SystemAssigned'
    }
    kind: 'app'
    properties: {
      enabled: true
      serverFarmId: appServicePlan.id
      siteConfig: {
        linuxFxVersion: 'dotnet|3.1'
        appCommandLine: 'dotnet MyApp.dll'
        metadata: [
          {
            name: 'CURRENT_STACK'
            value: 'dotnetcore'
          }
        ]
      }
    }
  }
  </code></pre>
  <p>Here is my second attempt to set the stack using 'Microsoft.Web/sites/config' as suggested here:</p>
  <p><a href="https://stackoverflow.com/questions/67823980/bicep-how-to-config-runtime-stack-to-azure-app-service-bicep-version-0-4">Bicep - How to config Runtime Stack to Azure App Service (Bicep version 0.4)</a></p>
  <pre><code>resource appService 'Microsoft.Web/sites@2021-02-01' = {
    name: 'MyApp'
    location: resourceGroup().location
    identity: {
      type: 'SystemAssigned'
    }
    kind: 'app'
    properties: {
      enabled: true
      serverFarmId: appServicePlan.id
      siteConfig: {
        linuxFxVersion: 'dotnet|3.1'
        appCommandLine: 'dotnet MyApp.dll'
      }
    }
    resource webConfig 'config' = {
      name: 'web'
      properties: {
        metadata: [
          {
            name: 'CURRENT_STACK'
            value: 'dotnetcore'
          }
        ]
      }
    }
  }
  </code></pre>
  <p>The result is the same. The deployment is completed with the following warning:</p>
  <blockquote>
  <p>Warning BCP037: The property &quot;metadata&quot; is not allowed on objects of
  type &quot;SiteConfig&quot;. Permissible properties include
  &quot;acrUseManagedIdentityCreds&quot;, &quot;acrUserManagedIdentityID&quot;, &quot;alwaysOn&quot;,
  &quot;apiDefinition&quot;, &quot;apiManagementConfig&quot;, &quot;autoHealEnabled&quot;,
  &quot;autoHealRules&quot;, &quot;autoSwapSlotName&quot;, &quot;azureStorageAccounts&quot;,
  &quot;connectionStrings&quot;, &quot;cors&quot;, &quot;defaultDocuments&quot;,
  &quot;detailedErrorLoggingEnabled&quot;, &quot;documentRoot&quot;, &quot;experiments&quot;,
  &quot;ftpsState&quot;, &quot;functionAppScaleLimit&quot;,
  &quot;functionsRuntimeScaleMonitoringEnabled&quot;, &quot;handlerMappings&quot;,
  &quot;healthCheckPath&quot;, &quot;http20Enabled&quot;, &quot;httpLoggingEnabled&quot;,
  &quot;ipSecurityRestrictions&quot;, &quot;javaContainer&quot;, &quot;javaContainerVersion&quot;,
  &quot;javaVersion&quot;, &quot;keyVaultReferenceIdentity&quot;, &quot;limits&quot;, &quot;loadBalancing&quot;,
  &quot;localMySqlEnabled&quot;, &quot;logsDirectorySizeLimit&quot;, &quot;managedPipelineMode&quot;,
  &quot;managedServiceIdentityId&quot;, &quot;minimumElasticInstanceCount&quot;,
  &quot;minTlsVersion&quot;, &quot;netFrameworkVersion&quot;, &quot;nodeVersion&quot;,
  &quot;numberOfWorkers&quot;, &quot;phpVersion&quot;, &quot;powerShellVersion&quot;,
  &quot;preWarmedInstanceCount&quot;, &quot;publicNetworkAccess&quot;, &quot;publishingUsername&quot;,
  &quot;push&quot;, &quot;pythonVersion&quot;, &quot;remoteDebuggingEnabled&quot;,
  &quot;remoteDebuggingVersion&quot;, &quot;requestTracingEnabled&quot;,
  &quot;requestTracingExpirationTime&quot;, &quot;scmIpSecurityRestrictions&quot;,
  &quot;scmIpSecurityRestrictionsUseMain&quot;, &quot;scmMinTlsVersion&quot;, &quot;scmType&quot;,
  &quot;tracingOptions&quot;, &quot;use32BitWorkerProcess&quot;, &quot;virtualApplications&quot;,
  &quot;vnetName&quot;, &quot;vnetPrivatePortsCount&quot;, &quot;vnetRouteAllEnabled&quot;,
  &quot;websiteTimeZone&quot;, &quot;webSocketsEnabled&quot;, &quot;windowsFxVersion&quot;,
  &quot;xManagedServiceIdentityId&quot;. If this is an inaccuracy in the
  documentation, please report it to the Bicep Team.
  [https://aka.ms/bicep-type-issues]</p>
  </blockquote>
  <p>The resources are deployed, but the app service stack setting is blank and I have to set it manually to make it work.</p>
  <p><a href="https://i.stack.imgur.com/vHnOU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vHnOU.png" alt="App service stack settings" /></a></p>
  <p>I know that in the ARM template this is set on the CURRENT_STACK property of the Microsoft.Web/sites/config metadata (as suggested here <a href="https://cloudstep.io/2020/11/18/undocumented-arm-oddities-net-core-app-services/" rel="nofollow noreferrer">https://cloudstep.io/2020/11/18/undocumented-arm-oddities-net-core-app-services/</a>). However, this doesn't seem to be supported (yet) in Bicep. If anyone has found a working solution, please post it here.
  Thanks.</p>