I am attempting to deploy an Azure Function to production.
Local environment:
- Windows 10
- VS Code 1.82.2
- Python 3.9.10
- Azure Function Core Tools 4.0.5390
Azure environment:
- Two function apps (dev/prod)
- Both using runtime version ~4
- Both running on App Service Plan which is P2v2.
The issue: When deploying from my local environment to Azure, the VS Code output windows shows that the build progresses to the "Running pip install…" step, but no further. It never completes:
11:53:56 PM <function name removed>: Starting deployment...
11:53:56 PM <function name removed>: Creating zip package...
11:54:00 PM <function name removed>: Zip package size: 17.6 MB
11:54:05 PM <function name removed>: Fetching changes.
11:54:06 PM <function name removed>: Cleaning up temp folders from previous zip deployments and extracting pushed zip file <removed>.zip (16.84 MB) to /tmp/zipdeploy/extracted
11:54:09 PM <function name removed>: Updating submodules.
11:54:10 PM <function name removed>: Preparing deployment for commit id <removed>.
11:54:10 PM <function name removed>: PreDeployment: context.CleanOutputPath False
11:54:10 PM <function name removed>: PreDeployment: context.OutputPath /home/site/wwwroot
11:54:10 PM <function name removed>: Repository path is /tmp/zipdeploy/extracted
11:54:10 PM <function name removed>: Running oryx build...
11:54:10 PM <function name removed>: Command: oryx build /tmp/zipdeploy/extracted -o /tmp/build/expressbuild --platform python --platform-version 3.9.7 -i <removed> -p packagedir=.python_packages/lib/site-packages
11:54:11 PM <function name removed>: Operation performed by Microsoft Oryx, https://github.com/Microsoft/Oryx
11:54:11 PM <function name removed>: You can report issues at https://github.com/Microsoft/Oryx/issues
11:54:11 PM <function name removed>: Oryx Version: 0.2.20230508.1, Commit: 7fe2bf39b357dd68572b438a85ca50b5ecfb4592, ReleaseTagName: 20230508.1
11:54:11 PM <function name removed>: Build Operation ID: <removed>
11:54:11 PM <function name removed>: Repository Commit : <removed>
11:54:11 PM <function name removed>: OS Type : bullseye
11:54:11 PM <function name removed>: Image Type : githubactions
11:54:11 PM <function name removed>: Detecting platforms...
11:54:12 PM <function name removed>: Detected following platforms:
11:54:12 PM <function name removed>: python: 3.9.7
11:54:12 PM <function name removed>: Using intermediate directory <removed>.
11:54:12 PM <function name removed>: Copying files to the intermediate directory...
11:54:12 PM <function name removed>: Done in 0 sec(s).
11:54:12 PM <function name removed>: Source directory : <removed>
11:54:12 PM <function name removed>: Destination directory: /tmp/build/expressbuild
11:54:13 PM <function name removed>: Python Version: /tmp/oryx/platforms/python/3.9.7/bin/python3.9
11:54:13 PM <function name removed>: Creating directory for command manifest file if it does not exist
11:54:13 PM <function name removed>: Removing existing manifest file
11:54:13 PM <function name removed>: Running pip install...
I have confirmed this is the behavior both when deploying to the dev and the prod app in Azure.
Things I have tried with no luck:
- Upgrade VS Code to latest version
- Upgrade Azure Function Core Tools to latest version
- Initiate deployment via "External Git" connection in Deployment Center in Azure Function blade of Azure Portal. When doing this, the deployment logs in the Azure Portal likewise show the build progressing to "Running pip install…" but no further.
- Remove the latest changes to requirements.txt thus returning it to a known working state
Any ideas?
2
Answers
In order to reproduce the steps being carried out by the Azure build locally, I deleted my entire .venv folder, then rebuilt locally. I found this took an inordinately long amount of time and, in researching the errors I saw, came across this post: pip's dependency resolver takes way too long to solve the conflict
I had not pinned version numbers in my
requirements.txt
file. Doing this resolved the issue and I was again able to deploy to Azure.This kind of issue occurs when your Python function has a high number of dependencies, and it takes an extensive amount of time to install pip.
Need to check below:
First, check that the Azure functions core tools extension is up to date. Check if it is compatible with the VScode version you are using if it has been updated.
Upgrade pip if required. To upgrade pip, use
Check and clear Pip cache Because it caches downloaded packages in the local cache by default. When the cache becomes faulty, problems can occur.
pip cache purge
Try to use a virtual environment for python function execution to isolate your Python package dependencies. To activate virtual environment in your VScode terminal.
Steps detailed in doc given.
I tried to create a Python Azure function and deploy it using VScode as shown. It worked as expected.
Deployment successful:
Note: If still the issue persists, restart your VScode IDE and try deployment again.
Refer Troubleshoot errors for function deployments.