I am trying to create a Devops Pipeline to deploy to a Python Azure Function App. Using Vs code I can successfully deploy to the function app and everything works 100%. I had to add 2 app settings mentioned here (https://github.com/anthonychu/20220303-python-func-playwright) to get it working.
Next steps was to create a Pipeline in Azure Devops. I tried using the classic editor and the YAML creator but I just cant get Playwright to install. I keep getting the error:
Looks like Playwright was just installed or updated. Please run the following command to download new browsers: playwright install <3 Playwright Team.
Anyone here managed to get a Devops pipeline to deploy to a Python Azure Function App V2 that includes Playwright to work yet?
Basically I need to figure out how to run playwright install chromium as a post build task. I tried adding a POST_BUILD_COMMAND app setting but it doesn’t seem to run when I deploy using the Pipeline, its does however run when deploying using VS Code
My current YAML:
pool:
vmImage: ubuntu-latest
steps:
- task: UsePythonVersion@0
displayName: "Set Python version to 3.10"
inputs:
versionSpec: '3.10'
architecture: 'x64'
- bash: |
if [ -f extensions.csproj ]
then
dotnet build extensions.csproj --output ./bin
fi
pip install --target="./.python_packages/lib/site-packages" -r ./requirements.txt
- bash: |
sudo mkdir -p /home/site/wwwroot
PLAYWRIGHT_BROWSERS_PATH=/home/site/wwwroot
python -m pip install playwright
PLAYWRIGHT_BROWSERS_PATH=/home/site/wwwroot /opt/hostedtoolcache/Python/3.10.13/x64/bin/python3.10 -m playwright install chromium
displayName: 'Install Playwright'
- task: ArchiveFiles@2
displayName: "Archive files"
inputs:
rootFolderOrFile: "$(System.DefaultWorkingDirectory)"
includeRootFolder: false
archiveFile: "$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip"
- task: PublishBuildArtifacts@1
inputs:
PathtoPublish: '$(System.DefaultWorkingDirectory)/build$(Build.BuildId).zip'
artifactName: 'drop'
2
Answers
Add an app setting
PLAYWRIGHT_BROWSERS_PATH=/home/site/wwwroot
in the function app.Then the function works as shown below.
I am running a jenkins piple line and I use the Playwright image instead. I am quoting the Playwright documentation. I am using the Jammy image myself in my pipeline
Have you tried that? That could be a potential solution and you won’t have to hunt for the right version of chromium and install it. This comes preinstalled with Playwright browsers.