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
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).
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.
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
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.
Related
I am trying to run a python flask app on azure app service for linux and I am deploying it using git hub actions, but I am running in to ModuleNotFoundError: No module named 'html2text' Error. Below are app service logs :
I am new to app service and flask applications and dont understand what is the reason as the build of the application is fine and all dependencies from requirement.txt are installed.
Here are the logs of my build showing the package getting installed :
I need support here guys ! Thanks.
I have deployed Python Flask app in Azure using GitHub Actions.
Please Check the below Work around
Make sure you are using the latest Python version
No module named 'html2text'
Create a python flask app in Local environment and push it to Git new repository.
In Azure Portal => Deployment Center => Settings => Select GitHub as Source and provide the required details and Save.
Workflow in GitHubAction :
Verify,html2text must be installed in dist-packages folder.
Issue will be resolved with the latest python version. If you are still getting the same error, Install the html2text.
In VSCode, Terminal run the below command to install html2text
pip install html2text
I am using Azure Dev Ops build agents to do all my CI/CD. I am having trouble installing Az Powershell Module version 2.8.0 on the build agent. I need that particular version because a lot of new APIs have been released on that version when compared to 2.6.0. Installing 2.8.0 on the build agent before running my build process results in failure. As you can see here 2.8.0 is not yet installed on the base images for these agents. If anyone has some tips on how I can consume this specific module that would be really helpful. In the mean time I have opened an issue to add the version
Use below script in Powershell task to install Az 2.8.0 into Hosted linux agent:
Install-Module -Name Az -RequiredVersion 2.8.0 -Force -AllowClobber
Get-InstalledModule #Just print out the details to confirm whether `Az 2.8.0` has been installed successfully
You can see Az 2.8.0 has been installed into hosted agent successfully.
Just one thing you should pay attention to, after the pipeline finished, our server will recycle the image of the currently used host agent. And the system will obtain a brand new agent image when you re-run the pipeline. So, this powershell task must be executed in every pipeline to let the environment satisfied your requirements.
I am following this tutorial on how to create a HTML web app within Azure
When I enter the az webapp up command I receive the error:
Could not auto-detect the runtime stack of your app, see 'https://go.microsoft.com/fwlink/?linkid=2109470' for more information
The version of Azure CLI I'm running is:
azure-cli 2.0.78 *
command-modules-nspkg 2.0.3
core 2.0.78 *
nspkg 3.0.4
telemetry 1.0.4
Extensions:
azure-devops 0.16.0
Any help with this would be much appriciated!
I ran into the same problem and it looks like there is a problem with static html site. Today version 2.0.79 was released and it supports an --html flag. At least my app is now working.
The tutorial guide you use the Azure Cloud Shell to deploy it, but as you know the CLI in the Cloud Shell is version 2.0.78 and it does not support the parameter --html and you also cannot upgrade the CLI in the Cloud Shell.
The parameter now is only supported in version 2.0.79. So the solution is to install the CLI in your own environment. Follow the steps here to install the CLI then it will work well with the parameter --html.
It just seems the issue is with the current directory from which the command is run.
It probably needs to detect files specific to a run-time stack before uploading the app; Such files, like the 'package.json' file for Node.js would on exist within the app's directory. So please try 'cd' into the app's directory
i have just begun with Azure.
Here i have simple flask api and i tried to deploy the app with azure cli in vscode then it ends up with following error. I'm completely new to Azure so can anyone please sort out this for me. Thanks in advance.
I cannot reproduce your issue, but here is what I did and it can publish successfully using python 3.7. Note: I'm using azure cli version 2.0.75. Please check your cli version using az --version, and upgrade it as per this link if you're using old version.
1.Create a web app for Linux, the screenshot as below:
2.After step 1 is completed, then in visual studio code, open the folder where your project locates, and follow this doc:
In visual studio code -> terminal, use the following commands first(you need to nav to the folder where the project locates):
py -3 -m venv env
env\scripts\activate
pip install -r requirements.txt
Set-Item Env:FLASK_APP ".\application.py"
flask run
Then, input the commands to publish the flask api:
az webapp up --sku F1 -n <app-name> -l <location-name>
it can be published successfully. The screenshot as below:
just wonder is there a way to use pyodbc in a python WebJob
I want to set up a scheduled web job which will periodically fetch data from Azure database
However there's always error loading the pyodbc module, even if I upload the compiled version and add path in my script. anyone knows how to use pyodbc in an Azure WebJob?
Thanks!
Get the working PyODBC :
To use PyODBC you should compile it in its 32bits version (very important) with Python 2.7 or Python 3.4
Or install Python 2.7 or 3.4, 32bits, and type the command "pip install pyodbc"
Use in Azure WebJob
Put the PyODBC.pyd file in the root directory of your job and it should work.
Note :
If your PyODBC library isn't in a 32bits version, you should have the error "... Not a valid Win32 application"