Playwright azure function doesn't install chromium Python based
Question:
Answers:
PLAYWRITH_BROWSERS_PATH=0
Please make sure your above configuration was correct. There are some spelling mistakes in the settings. Its like PLAYWRIGHT_BROWSERS_PATH = 0
In your local.settings.json it should be
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "python",
"PLAYWRIGHT_BROWSERS_PATH": "0"
}
}
And In your requirement.txt file it should be
azure-functions
playwright==1.18.0
here we can see the playwright running in local as well as azure after deployment
Local:
Azure:
You can solve this by installing the drivers into the function project and defining the location in PLAYWRIGHT_BROWSERS_PATH
, as follows:
- Create a
bin
folder in the project, here we want to store the drivers
- Install the drivers in the bin folder using the following command, this installs the drivers in a
pw-browers
folder in the bin:
PLAYWRIGHT_BROWSERS_PATH=./bin/pw-browsers python -m playwright install
- Define the path to the drivers in
local.settings.json
AND in the Azure function project itself:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "python",
"PLAYWRIGHT_BROWSERS_PATH": "./bin/pw-browsers"
}
}
EDIT:
alternative solution:
https://github.com/anthonychu/20220303-python-func-playwright
PLAYWRITH_BROWSERS_PATH=0
Please make sure your above configuration was correct. There are some spelling mistakes in the settings. Its like PLAYWRIGHT_BROWSERS_PATH = 0
In your local.settings.json it should be
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "python",
"PLAYWRIGHT_BROWSERS_PATH": "0"
}
}
And In your requirement.txt file it should be
azure-functions
playwright==1.18.0
here we can see the playwright running in local as well as azure after deployment
Local:
Azure:
You can solve this by installing the drivers into the function project and defining the location in PLAYWRIGHT_BROWSERS_PATH
, as follows:
- Create a
bin
folder in the project, here we want to store the drivers - Install the drivers in the bin folder using the following command, this installs the drivers in a
pw-browers
folder in the bin:
PLAYWRIGHT_BROWSERS_PATH=./bin/pw-browsers python -m playwright install
- Define the path to the drivers in
local.settings.json
AND in the Azure function project itself:
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "python",
"PLAYWRIGHT_BROWSERS_PATH": "./bin/pw-browsers"
}
}
EDIT:
alternative solution:
https://github.com/anthonychu/20220303-python-func-playwright