Review App Service Python runtime support

Maintain security fixes and compatibility with a supported Python runtime and dependencies.

Description

Choose a Python version offered by App Service that still receives security fixes and supports your app’s packages. A supported release can meet those requirements even when a newer version exists.

Potential impact

An unsupported runtime can retain known vulnerabilities. Packages incompatible with a new runtime can prevent startup or break requests.

Remediation

Set site_config.application_stack.python_version on the Linux Web App. Start the app with its deployment startup command and test its main packages and request paths. Schedule the next upgrade before Python support ends.

Examples

The first excerpt uses Python 2.7 on Windows. App Service’s current built-in Python runtime runs on Linux. Supply the real Linux plan ID and selected Python version in the second excerpt. When migrating a Windows app, adapt its dependencies and startup command for Linux.

Before

hcl
resource "azurerm_app_service" "example" {
  name                = "example-app-service"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  app_service_plan_id = azurerm_app_service_plan.example.id

  site_config {
    dotnet_framework_version = "v4.0"
    scm_type                 = "LocalGit"
    python_version           = "2.7"
  }
}

After

hcl
resource "azurerm_linux_web_app" "example" {
  name                = "example-app-service"
  location            = azurerm_resource_group.example.location
  resource_group_name = azurerm_resource_group.example.name
  service_plan_id     = var.service_plan_id

  site_config {
    application_stack {
      python_version = var.python_version
    }
  }
}

References