Problem
I’m trying to use a Bicep template from Azure CLI to launch a.NET Core 3.1 Azure App Service on Linux. The app service and accompanying app service plan are deployed correctly, however the Azure portal’s app service stack settings are blank, and I must fill them up manually. I tried setting the metadata property on both the ‘Microsoft.Web/sites’ and the ‘Microsoft.Web/sites/config’ resources, but the outcome was the same.
My app service strategy is as follows:
resource appServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = {
name: 'MyAppService'
location: resourceGroup().location
properties: {
reserved: true
}
sku: {
name: 'P1v2'
}
kind: 'linux'
}
Here’s my first effort at utilizing ‘Microsoft.Web/sites’ as suggested here to set up the stack.
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'
}
]
}
}
}
Here’s my second effort at using ‘Microsoft.Web/sites/config’ as suggested here to set the stack:
How to configure Runtime Stack to Azure App Service with Bicep (Bicep version 0.4)
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'
}
]
}
}
}
The end outcome is identical. With the following warning, the deployment is complete.
Although the resources have been deployed, the app service stack configuration is blank, and I must manually set it in order for it to work.
I know that in the ARM template, this is set on the Microsoft.Web/sites/config metadata’s CURRENT STACK property (as recommended here https://cloudstep.io/2020/11/18/undocumented-arm-oddities-net-core-app-services/). However, this does not appear to be supported in Bicep (yet). If someone has come up with a viable solution, please share it here. Thanks.
Asked by erionpc
Solution #1
In SiteConfig, the Metadata argument is no longer available. LinuxFxVersion is a stack setting that can be mentioned.
So, solution will be You should use DOTNETCORE|3.1 instead of dotnet|3.1. The over all code will be as below:
resource appServicePlan 'Microsoft.Web/serverfarms@2021-02-01' = {
name: 'MyAppService'
location: resourceGroup().location
properties: {
reserved: true
}
sku: {
name: 'P1v2'
}
kind: 'linux'
}
resource appService 'Microsoft.Web/sites@2021-02-01' = {
name: 'anumantestapp'
location: resourceGroup().location
identity: {
type: 'SystemAssigned'
}
kind: 'app'
properties: {
enabled: true
serverFarmId: appServicePlan.id
siteConfig: {
linuxFxVersion: 'DOTNETCORE|3.1'
appCommandLine: 'dotnet MyApp.dll'
}
}
}
Ouptut:
Answered by AnsumanBal-MT
Post is based on https://stackoverflow.com/questions/69897663/setting-azure-app-service-server-stack-on-a-bicep-template