2
votes

I have created a web app on Microsoft Azure and choosen Python 3.8 as configuration.

Then I set up a deployment pipeline on Azure DevOps which deploys a django app into the web app. The deployment itself also runs fine, artifacts are copied and unzipped. But the installation of the requirements is giving me a hard time.

On the Configuration section for the Web App on Azure portal I defined "Python 3.8" in the general settings. And in the Azure DevOps pipeline the deployment task is configured to use "PYTHON|3.8" as runtime stack.

But still the post deployment actions do fail - and this as it looks like is caused by the Kundu component which executes the task and itself is running python 3.5 (python3) and python 2.7 (python).

The pip installation for django 3.1.4 then fails with error and I am getting warnings about end of life python 3.5.

Here's deployment step and full output of it

#Your build pipeline references an undefined variable named ‘Parameters.ConnectedServiceName’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.WebAppKind’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.WebAppName’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.StartupCommand’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
#Your build pipeline references an undefined variable named ‘Parameters.PythonAppFramework’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972

steps:
- task: AzureRmWebAppDeployment@4
  displayName: 'Deploy Azure App Service'
  inputs:
    azureSubscription: '$(Parameters.ConnectedServiceName)'
    appType: '$(Parameters.WebAppKind)'
    WebAppName: '$(Parameters.WebAppName)'
    packageForLinux: '$(System.DefaultWorkingDirectory)/_xxx-CI/drop/xxx**.zip'
    RuntimeStack: 'PYTHON|3.8'
    StartupCommand: '$(Parameters.StartupCommand)'
    ScriptType: 'Inline Script'
    InlineScript: |
     echo "Printing version of python3"
     python3 --version
     echo "Upgrading pip"
     /usr/bin/python3 -m pip install --upgrade pip
     echo "Installing requirements"
     /usr/bin/python3 -m pip install -r xxx/requirements.txt
    WebConfigParameters: '$(Parameters.PythonAppFramework)'
2020-12-26T14:52:34.2216420Z ##[section]Starting: Deploy Azure App Service
2020-12-26T14:52:34.2227205Z ==============================================================================
2020-12-26T14:52:34.2227775Z Task         : Azure App Service deploy
2020-12-26T14:52:34.2228172Z Description  : Deploy to Azure App Service a web, mobile, or API app using Docker, Java, .NET, .NET Core, Node.js, PHP, Python, or Ruby
2020-12-26T14:52:34.2228532Z Version      : 4.179.0
2020-12-26T14:52:34.2228747Z Author       : Microsoft Corporation
2020-12-26T14:52:34.2229021Z Help         : https://aka.ms/azureappservicetroubleshooting
2020-12-26T14:52:34.2229517Z ==============================================================================
2020-12-26T14:52:35.2840047Z Got service connection details for Azure App Service:'xxx-dev'
2020-12-26T14:53:22.4215194Z Package deployment using ZIP Deploy initiated.
2020-12-26T14:54:12.3861589Z Deploy logs can be viewed at https://xxx-dev.scm.azurewebsites.net/api/deployments/b87f0b8e9bee48e6a823e1ef681812dd/log
2020-12-26T14:54:12.3866079Z Successfully deployed web package to App Service.
2020-12-26T14:54:13.3092961Z Trying to update App Service Application settings. Data: {"SCM_COMMAND_IDLE_TIMEOUT":"1800"}
2020-12-26T14:54:13.3105380Z App Service Application settings are already present.
2020-12-26T14:54:13.5984663Z Executing given script on Kudu service.
2020-12-26T14:54:33.9532357Z Standard output from script: 
2020-12-26T14:54:33.9534448Z Printing version of python3
2020-12-26T14:54:33.9534739Z Python 3.5.3
2020-12-26T14:54:33.9534967Z Upgrading pip
2020-12-26T14:54:33.9535578Z Defaulting to user installation because normal site-packages is not writeable
2020-12-26T14:54:33.9536860Z Requirement already satisfied: pip in /home/.local/lib/python3.5/site-packages (20.3.3)
2020-12-26T14:54:33.9537372Z Installing requirements
2020-12-26T14:54:33.9537892Z Defaulting to user installation because normal site-packages is not writeable
2020-12-26T14:54:33.9538291Z Looking in indexes: https://pypi.org/simple, https://www.piwheels.org/simple
2020-12-26T14:54:33.9538602Z 
2020-12-26T14:54:33.9544250Z Standard error from script: 
2020-12-26T14:54:33.9593269Z ##[error]DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
ERROR: Could not find a version that satisfies the requirement django==3.1.4
ERROR: No matching distribution found for django==3.1.4

2020-12-26T14:54:34.7576240Z ##[error]Error: Unable to run the script on Kudu Service. Error: Error: Executed script returned '1' as return code. Error: DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
DEPRECATION: Python 3.5 reached the end of its life on September 13th, 2020. Please upgrade your Python as Python 3.5 is no longer maintained. pip 21.0 will drop support for Python 3.5 in January 2021. pip 21.0 will remove support for this functionality.
ERROR: Could not find a version that satisfies the requirement django==3.1.4
ERROR: No matching distribution found for django==3.1.4

2020-12-26T14:54:36.2470993Z Successfully updated deployment History at https://xxx-dev.scm.azurewebsites.net/api/deployments/321608994474759
2020-12-26T14:54:36.5240518Z App Service Application URL: http://xxx-dev.azurewebsites.net
2020-12-26T14:54:36.5358824Z ##[section]Finishing: Deploy Azure App Service

is this known - and more important is there a way to fix this?

Interestingly, when I ssh into the web app / app service and execute the commands all works fine

2
Same issue is present for PHP - specifying version 7.4 will still resolve version 7.3 in the InlineScript.kkliebersbach

2 Answers

1
votes

The Python 3.5.3 is the default version installed in root folders on the server. If you go to Azure App Service Kudu console to check the Python version, it will return the same result (Python 3.5.3).

enter image description here

When creating the App Services on Azure Portal, specifying Runtime Stack as Python 3.8 will not automatically install Python 3.8 and set it as the default for your App Services on the server. You need to manually set up the version on for your App Services on Azure Portal.

According to my test, using Inline Script on the Azure App Service deploy task to upgrade the Python version is not available.

I recommend that you can reference to the article "How to set up a Python environment on Azure App Service (Windows)" to set up Python 3.8 for your App Services on Azure Portal.

0
votes

ran-msft,

thank you for the hint, I already stumbled across this guide. Unfortunately the app service is not Windows based but Linux based. And according the outcome of some research the installation of Extensions is not possible on Linux based Web App.

Trying to set up a n ew Web App and selecting Runtime stack "Python 3.8" only Operating System "Linux" is available

enter image description here

I also tried to change (recreate) the Web App to be on runtime stack "Python 3.6" (which allows a Windows Operating System). But then the Extension installation does not allow to go beyond Python 3.6.