Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
The local virtual environment test is a good start, but by itself it doesn’t fully guarantee that the Azure App Service will work after a Python upgrade. Compatibility depends on two things:
- The Python version your code and dependencies support.
- The Python runtime versions that Azure App Service supports and how the app is configured there.
From the context:
- Azure App Service lets the Python version be configured either in the portal (Stack/Version) or via
linuxFxVersionusing Azure CLI. - Outdated runtimes are eventually deprecated and removed from the portal, but apps already using them continue to run until the runtime is fully removed.
To increase confidence before changing production:
- Confirm the target version is supported in App Service
Use Azure CLI to list supported Python runtimes for Linux:
This shows which exactaz webapp list-runtimes --os linux | grep PYTHONPYTHON|x.yvalues are available for your web app. - Match local tests to the Azure runtime
When creating the local virtual environment, use the same major/minor version that App Service will use (for example, 3.11.x). Install all dependencies withpip install -r requirements.txtand run the application’s own tests or a basic startup test (for example, run the web app locally) to ensure imports and startup succeed. - Plan the change in App Service
For Linux apps, the Python version is controlled bylinuxFxVersion. You can view or set it with Azure CLI:
Replace names as appropriate. This aligns the app with the Python version you tested locally.az webapp config show \ --resource-group <resource-group-name> \ --name <app-name> \ --query linuxFxVersion az webapp config set \ --resource-group <resource-group-name> \ --name <app-name> \ --linux-fx-version "PYTHON|3.11" - Use a non‑production slot when possible
If deployment slots are added later, first set the new Python version on a staging slot, deploy the app there, verify it runs correctly, and then swap the slot into production. This minimizes downtime and risk. - Be aware of deprecation timelines
Azure Advisor already recommends upgrading apps off older Python versions as support ends. Keeping the app on a supported version (for example, moving from 3.10 to a newer supported version) avoids losing security updates and support.
In summary, the local venv test is useful but should be combined with checking supported runtimes in App Service and, ideally, validating on a staging slot before changing production. The actual upgrade in Azure is done by updating the linuxFxVersion/stack version to the desired supported Python version.
References: