Skip to content

Use App Service Always On#

Reliability · App Service · Rule · 2020_12 · Important

Configure Always On for App Service apps.

Description#

Azure App Service apps are automatically unloaded when there's no traffic. Unloading apps reduces resource consumption when apps share a single App Services Plan. After an app have been unloaded, the next web request will trigger a cold start of the app. A cold start of the app can cause request timeouts.

Web apps using continuous WebJobs or WebJobs triggered with a CRON expression must use always on to start.

Recommendation#

Consider enabling Always On for each App Services app.

Examples#

Configure with Azure template#

To deploy App Services that pass this rule:

  • Set the properties.siteConfig.alwaysOn property to true.

For example:

Azure Template snippet
{
  "type": "Microsoft.Web/sites",
  "apiVersion": "2023-01-01",
  "name": "[parameters('name')]",
  "location": "[parameters('location')]",
  "identity": {
    "type": "SystemAssigned"
  },
  "kind": "web",
  "properties": {
    "serverFarmId": "[resourceId('Microsoft.Web/serverfarms', parameters('planName'))]",
    "httpsOnly": true,
    "siteConfig": {
      "alwaysOn": true,
      "minTlsVersion": "1.2",
      "ftpsState": "Disabled",
      "remoteDebuggingEnabled": false,
      "http20Enabled": true,
      "netFrameworkVersion": "v8.0",
      "healthCheckPath": "/healthz",
      "metadata": [
        {
          "name": "CURRENT_STACK",
          "value": "dotnet"
        }
      ]
    }
  },
  "dependsOn": [
    "[resourceId('Microsoft.Web/serverfarms', parameters('planName'))]"
  ]
}

Configure with Bicep#

To deploy App Services that pass this rule:

  • Set the properties.siteConfig.alwaysOn property to true.

For example:

Azure Bicep snippet
resource web 'Microsoft.Web/sites@2023-01-01' = {
  name: name
  location: location
  identity: {
    type: 'SystemAssigned'
  }
  kind: 'web'
  properties: {
    serverFarmId: plan.id
    httpsOnly: true
    siteConfig: {
      alwaysOn: true
      minTlsVersion: '1.2'
      ftpsState: 'Disabled'
      remoteDebuggingEnabled: false
      http20Enabled: true
      netFrameworkVersion: 'v8.0'
      healthCheckPath: '/healthz'
      metadata: [
        {
          name: 'CURRENT_STACK'
          value: 'dotnet'
        }
      ]
    }
  }
}

Configure with Azure Verified Modules

A pre-built module is avilable on the Azure Bicep public registry. To reference the module, please use the following syntax:

br/public:avm/res/web/site:<version>

Notes#

The Always On feature of App Service is not applicable to Azure Functions and Standard Logic Apps under most circumstances. To reduce false positives, this rule ignores apps based on Azure Functions and Standard Logic Apps.

When running in a Consumption Plan or Premium Plan you should not enable Always On. On a Consumption plan the platform activates function apps automatically. On a Premium plan the platform keeps your desired number of pre-warmed instances always on automatically.

Comments