2

I was able to create an App Service Plan and App Service using the latest Bicep Version 0.4.

resource myAppServicePlan 'Microsoft.Web/serverfarms@2021-01-01'={
name: AppServicePlanName
location: Location
sku: {
 name: appServicePlanSkuName
 tier: AppServiceTier
 }  
}
resource myAppService 'Microsoft.Web/sites@2021-01-01'={
  name: AppServiceName
  location: Location
  properties:{
  serverFarmId: myAppServicePlan.id
  }
 }

Be default, it takes ASP.NET 4.8 as the framework version. I would like to use the Framework as Netcore 3.1. is there a way to achieve it yet?

Please suggest. Thank you. Praveen

Prawin
  • 1,158
  • 2
  • 12
  • 26

1 Answers1

5

It does not matter bicep version, you configure it by setting appropriate parameter to the resource. For Linux plans it’s LinuxFxVersion, same as in ARM, but a different syntax of writing. You need to see the app service documentation to get more details: https://learn.microsoft.com/en-us/azure/app-service/quickstart-arm-template

If you cannot figure out which property you need to set in bicep/ARM one option is to open developer tools in your browser and examine POST message sent by Portal to management.azure.com or go to resources.azure.com and see the details of the already configured (via Portal) resource or use export template functionality.

Edit:
For Windows App Service Plan setting up runtime stack is a bit complicated. Basically, there's property netFrameworkVersion which can be v3.0 v4.0 or v5.0.

However to get the core It seems you need to manipulate with metadata in sites/config:

resource myAppService 'Microsoft.Web/sites@2021-01-01' = {
  name: AppServiceName
  location: Location
  properties:{
  serverFarmId: myAppServicePlan.id
  }

  resorce 'webConfig' config = {
    name: 'web'
    properties: {
      metadata: [
      {
        name: 'CURRENT_STACK'
        value: 'dotnetcore'
      }
      ]
    }
  }
}

If you wish to get back to .NET or switch to .NET5 (and then to .NET6) you need to set back the value to dotnet and use netFrameworkVersion property.

It seems that when you have CURRENT_STACK with value dotnetcore, the netFrameworkVersion is ignored.

I extracted this knowledge from observing the PUT requests - what portal do when changing the stack. I don't know what options is to set different stacks like Java or PHP. Probably in similar way - some combination of CURRENT_STACK + other properties in sites/config 'web'.

It seems that there's no docs on this.

BTW - do not attempt to use it within Microsoft.Web/Sites resource - use the Microsoft.web/sites/config with web name instead. I had history when although I could use those options under siteConfig property, it was not set by the resource provider API.

Miq
  • 3,931
  • 2
  • 18
  • 32
  • I have already tried all those and couldn't find anything that helps and hence posted the question. If you know how to do it, I would appreciate if you post the specific answer! – Prawin Jun 04 '21 at 05:23
  • The accepted answer doesn't work. Please remove the "accepted" status to avoid confusing people. – erionpc Nov 09 '21 at 11:15
  • @erionpc can you explain what exactly means ‘doesn’t work’? – Miq Nov 09 '21 at 21:03
  • @Miq setting the server stack in the site config "metadata" results in an empty stack setting on Azure App Service. I posted a new question about this problem and I was given a working solution, thankfully. https://stackoverflow.com/questions/69897663/setting-azure-app-service-server-stack-on-a-bicep-template?noredirect=1#comment123566981_69897663 – erionpc Nov 09 '21 at 23:06
  • note that above configuration is for windows app service plan. linux one is different. – Miq Nov 10 '21 at 15:21
  • This works for a windows app service plan, thanks a lot! But it throws a warning: ```Warning BCP037: The property "metadata" is not allowed on objects of type "SiteConfig"```. Any ideas how to get rid off it? – spikey May 20 '22 at 21:18
  • unfortunately this warning message has to be fixed by App Service Team by including this field in the swagger spec published on https://github.com/Azure/azure-rest-api-specs. You can disable this warning using linter rule comment (best to use a quickfix in Visual Studio Code) – Miq May 23 '22 at 09:49
  • 1
    you can avoid the warning by defining new resource such as: resource appSettingsStack 'Microsoft.Web/sites/config@2021-03-01' = { name: '${appService.name}/metadata' properties: { CURRENT_STACK: 'dotnet' } } – kevinob Aug 03 '22 at 12:31