https://github.com/arjunattam/playwright-azure-functions
Example project to run Playwright on Azure Functions
https://github.com/arjunattam/playwright-azure-functions
Last synced: 3 months ago
JSON representation
Example project to run Playwright on Azure Functions
- Host: GitHub
- URL: https://github.com/arjunattam/playwright-azure-functions
- Owner: arjunattam
- Created: 2020-01-23T18:43:47.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2021-06-05T19:54:32.000Z (about 5 years ago)
- Last Synced: 2025-10-22T10:47:45.636Z (8 months ago)
- Language: Dockerfile
- Homepage:
- Size: 24.4 KB
- Stars: 22
- Watchers: 0
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Playwright on Azure Functions
Working reference example for running [Playwright](https://github.com/microsoft/playwright/) scripts on Azure Functions. Supports Chromium, WebKit and Firefox. Tested with Playwright v0.11.1.
```
https://az-functions-pw-test.azurewebsites.net/api/HttpExample?browser=webkit
```
## Usage
This example currently requires a Linux premium plan on Azure Functions. The project was bootstrapped with [this tutorial](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-function-linux-custom-image?tabs=portal%2Cbash&pivots=programming-language-javascript).
The project sets up a basic HTTP trigger function which returns a screenshot of a web page in the browser of your choice.
### Running locally
* Clone the repo and run `npm install`
* Build the docker image with `docker build .`
* Run the docker container with `docker run -p 8080:80 `
* Open `localhost:8080/api/HttpExample` and pass the browser as a query parameter `?browser=webkit`
### Deploy
Once the pieces work locally, deploy them to Azure by following the steps in [this tutorial](https://docs.microsoft.com/en-us/azure/azure-functions/functions-create-function-linux-custom-image?tabs=portal%2Cbash&pivots=programming-language-javascript). Broadly speaking, these steps will be:
* Create a resource group, storage account and premium plan on your Azure subscription
* Push the Docker image to Docker Hub
* Create a function with an HTTP trigger, pointed at the Docker image
## Usage with a single browser
It is also possible to use this example for a single browser (instead of 3). To do this
* Use a different NPM package: `playwright-chromium`, `playwright-firefox`, or `playwright-webkit` instead of `playwright`
* Optionally, modify the Dockerfile to remove browser-specific changes
* Update the `index.js` to require the correct NPM package
## Contributing
Does this example not work for your needs? File an issue so we can make it work better. Thank you!