skip to Main Content

I’ve created a Bicep to deploy Service Plan and App Service with linux/windows selection and .net 6 stack. Both deployments successful, Linux App is totally fine, .net 6 stack is present on Portal. However, Windows stack is empty on Portal screen.

I am using the following parameters:

Bicep linux parameter:

  linuxFxVersion: 'DOTNETCORE|6.0'

Bicep Windows parameters:

  windowsFxVersion: 'dotnet:6'
  netFrameworkVersion: 'v6.0'

With this command I get allowed windows stacks, so dotnet:6 should be ok

[ ~ ]$ az webapp list-runtimes --os windows --os-type windows
[
  "dotnet:7",
  "dotnet:6",
  "ASPNET:V4.8",
  "ASPNET:V3.5",
  "NODE:18LTS",
...

I can see with Powershell, that my settings are applied to the Web App.

I’ve tried different options like dotnet|6, dotnetcore|6 or without netFrameworkVersion and didn’t find the right set. Is it Azure interface bug or am I missing something?
Thanks in advance, attaching whole Bicep below.

@description('Generate unique String for resource names')
param uniqueFullRGString string = uniqueString(resourceGroup().id)

@description('Short unique name based on RG name')
param uniqueRGString string = take(uniqueFullRGString, 4)

@description('Resource group location')
param location string = resourceGroup().location

@description('Azure Tenant Id')
var azureTenantId = tenant().tenantId

@description('App Service Plan OS')
@allowed([
  'linux'
  'windows'
])
param appServicePlanOS string

var linuxOffer = 'linux'
var windowsOffer = 'windows'

@description('App Service Plan SKU')
param appServicePlanSku string = 'F0'

var configReferenceLinux = {
  linuxFxVersion: 'DOTNETCORE|6.0'
  appSettings: [
    {
      name: 'TenantId'
      value: azureTenantId
    }
  ]
}

var configReferenceWindows = {
  windowsFxVersion: 'dotnet:6'
  netFrameworkVersion: 'v6.0'
  appSettings: [
    {
      name: 'TenantId'
      value: azureTenantId
    }
  ]
}

@description('App Service Plan name')
var appServicePlanName = 'App-${uniqueRGString}'

resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
  name: appServicePlanName
  location: location
  sku: {
    name: appServicePlanSku
  }
  properties: {
      reserved: ((appServicePlanOS == 'linux') ? true : false)
  }
  kind: ((appServicePlanOS == 'linux') ? linuxOffer : windowsOffer)
}

resource appService 'Microsoft.Web/sites@2020-06-01' = {
  name: appServicePlanName
  location: location
  properties: {
    serverFarmId: appServicePlan.id
    siteConfig: ((appServicePlanOS == 'linux') ? configReferenceLinux : configReferenceWindows)
  }
  identity: {
    type: 'SystemAssigned'
  }
}

2

Answers


  1. I ran your code in my environment and got the same results (Empty runtime stack). Then I changed the provider "Microsoft. Web/sites" version to "2021-03-01" and it worked successfully as few deployment versions are throwing these kinds of errors.

    I made a few changes to your code and find the below snippet.

    resource  appService  'Microsoft.Web/sites@2021-03-01' = {
    name: appServicePlanName 
    location: "EastUS" //location
    properties: {
    serverFarmId: appServicePlan.id
    siteConfig: ((appServicePlanOS  ==  'windows') ?  configReferenceLinux  :  configReferenceWindows)
    }
    identity: {
    type: 'SystemAssigned'
    }
    }
    

    Deployment succeeded:

    enter image description here

    enter image description here

    App service -> configuration -> General settings -> Stack settings set to the given runtime stack & version:

    enter image description here

    Login or Signup to reply.
  2. If you are trying to deploy .NET stack webapp on windows app service plan then you need to add the metadata block which is to define the runtime of your webapp as mentioned in this sample ARM template to create .NET App on windows app service plan.

    I have modified the above shared sample bicep and tested it able to deploy windows app service plan with webapp running on .NET stack.

    @description('Generate unique String for resource names')
    param uniqueFullRGString string = uniqueString(resourceGroup().id)
    
    @description('Short unique name based on RG name')
    param uniqueRGString string = take(uniqueFullRGString, 4)
    
    @description('Resource group location')
    param location string = resourceGroup().location
    
    @description('Azure Tenant Id')
    var azureTenantId = tenant().tenantId
    
    @description('App Service Plan OS')
    @allowed([
      'linux'
      'windows'
    ])
    param appServicePlanOS string
    
    var linuxOffer = 'linux'
    var windowsOffer = 'windows'
    
    @description('App Service Plan SKU')
    param appServicePlanSku string = 'F0'
    
    var configReferenceLinux = {
      linuxFxVersion: 'DOTNETCORE|6.0'
      appSettings: [
        {
          name: 'TenantId'
          value: azureTenantId
        }
      ]
    }
    
    var configReferenceWindows = {
      metadata :[
        {
          name:'CURRENT_STACK'
          value:'dotnet'
        }
      ]
      netFrameworkVersion:'v7.0'
      appSettings: [
        {
          name: 'TenantId'
          value: azureTenantId
        }
      ]
    }
    
    @description('App Service Plan name')
    var appServicePlanName = 'App-${uniqueRGString}'
    
    resource appServicePlan 'Microsoft.Web/serverfarms@2022-03-01' = {
      name: appServicePlanName
      location: location
      sku: {
        name: appServicePlanSku
      }
      properties: {
          reserved: ((appServicePlanOS == 'linux') ? true : false)
      }
      kind: ((appServicePlanOS == 'linux') ? linuxOffer : windowsOffer)
    }
    
    resource appService 'Microsoft.Web/sites@2020-06-01' = {
      name: appServicePlanName
      location: location
      properties: {
        serverFarmId: appServicePlan.id
        siteConfig: ((appServicePlanOS == 'linux') ? configReferenceLinux : configReferenceWindows)
      }
      identity: {
        type: 'SystemAssigned'
      }
    }
    

    Sample Output Screenshot for reference:

    enter image description here

    You can refer to this similar SO thread as well.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search