How to configure runtime stack for app service in bicep script to create appservice in windows os

SISIRA SARU ABEY 20 Reputation points
2023-10-27T08:50:36.47+00:00

How to configure runtime stack for app service in bicep script to create appservice in windows os

I am able to create appservice but run time stack is not reflecting.

I want the runtime stack of web appservice to be Node - ~18 and runtime stack of webapp-api appservice as Dotnetcore

param location string = resourceGroup().location

resource appserviceplan 'Microsoft.Web/serverfarms@2022-09-01' = {
  name: 'appserviceplan1'
  location: location
  sku: {
    name: 'S1'
    capacity: 1
  }
}

resource appserviceapi 'Microsoft.Web/sites@2022-09-01' = {
  name: 'appservice-webapp-api1'
  location: location
  properties: {
    serverFarmId: resourceId('Microsoft.Web/serverfarms', appserviceplan.name)
    siteConfig: {
      appSettings: [
        {
          name: 'WEBSITE_NODE_DEFAULT_VERSION'
          value: '18.14.0'
        }
      ]
    }
  }
  dependsOn: [
    appserviceplan
  ]
}

resource appservice 'Microsoft.Web/sites@2022-09-01' = {
  name: 'appservice-webappservice-app1'
  location: location
  properties: {
    serverFarmId: resourceId('Microsoft.Web/serverfarms', appserviceplan.name)
    siteConfig: {
      appSettings: [
        {
          name: 'CURRENT_STACK'
          value: 'Node.js - ~18'
        }
      ]
    }
  }
  dependsOn: [
    appserviceapi
  ]
}

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,930 questions
0 comments No comments
{count} votes

Accepted answer
  1. Grmacjon-MSFT 19,151 Reputation points Moderator
    2023-10-30T02:18:55.8766667+00:00

    Hi @SISIRA SARU ABEY

    To configure the runtime stack for an App Service in a Bicep script, you can use the siteConfig property of the Microsoft.Web/sites resource Here’s how you can set the runtime stack for your web app service to Node.js - ~18 and your webapp-api app service to Dotnetcore:

    resource appserviceplan 'Microsoft.Web/serverfarms@2022-09-01' = {
      name: 'appserviceplan1'
      location: location
      sku: {
        name: 'S1'
        capacity: 1
      }
    }
    
    resource appserviceapi 'Microsoft.Web/sites@2022-09-01' = {
      name: 'appservice-webapp-api1'
      location: location
      properties: {
        serverFarmId: resourceId('Microsoft.Web/serverfarms', appserviceplan.name)
        siteConfig: {
          appSettings: [
            {
              name: 'FUNCTIONS_WORKER_RUNTIME'
              value: 'dotnet'
            }
          ]
        }
      }
      dependsOn: [
        appserviceplan
      ]
    }
    
    resource appservice 'Microsoft.Web/sites@2022-09-01' = {
      name: 'appservice-webappservice-app1'
      location: location
      properties: {
        serverFarmId: resourceId('Microsoft.Web/serverfarms', appserviceplan.name)
        siteConfig: {
          appSettings: [
            {
              name: 'WEBSITE_NODE_DEFAULT_VERSION'
              value: '~18'
            }
          ]
        }
      }
      dependsOn: [
        appserviceapi
      ]
    }
    

    In this example, its set the siteConfig property of each Microsoft.Web/sites resource to include an appSettings array with a single object that specifies the desired runtime stack. For the web app service, we set the WEBSITE_NODE_DEFAULT_VERSION to ~18, and for the webapp-api app service, we set the FUNCTIONS_WORKER_RUNTIME to dotnet.

    -Grace


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.