<commit_before>---
layout: post
title: "Running Playwright on Azure Functions"
subtitle: "This post is about Running Playwright on Azure Functions and deploying it to Azure."
date: 2020-12-10 00:00:00
categories: [Azure,Playwright,Serverless,Nodejs]
tags: [Azure,Playwright,Serverless,Nodejs]
author: "Anuraj"
image: /assets/images/2020/12/playwright_config.png
---
This post is about Running Playwright on Azure Functions and deploying it to Azure. Playwright is a Node.js library to automate Chromium, Firefox and WebKit with a single API. Playwright is built to enable cross-browser web automation that is ever-green, capable, reliable and fast. Since it is a Node.js library I am creating this azure function in Javascript. This function will read a URL as input parameter and converts that URL into a PDF file. So first I am creating an Azure function with Javascript.

I am creating the function using VSCode. I am created a function using Javascript and HttpTrigger. Next I am installing the Playwright package using the command - `npm install playwright`. this command installs Playwright and browser binaries for Chromium, Firefox and WebKit. 

Here is my `package.json` file
{% highlight Javascript %}

{% endhighlight %}
<commit_msg>Code updated<commit_after>---
layout: post
title: "Running Playwright on Azure Functions"
subtitle: "This post is about Running Playwright on Azure Functions and deploying it to Azure."
date: 2020-12-10 00:00:00
categories: [Azure,Playwright,Serverless,Nodejs]
tags: [Azure,Playwright,Serverless,Nodejs]
author: "Anuraj"
image: /assets/images/2020/12/playwright_config.png
---
This post is about Running Playwright on Azure Functions and deploying it to Azure. Playwright is a Node.js library to automate Chromium, Firefox and WebKit with a single API. Playwright is built to enable cross-browser web automation that is ever-green, capable, reliable and fast. Since it is a Node.js library I am creating this azure function in Javascript. This function will read a URL as input parameter and converts that URL into a PDF file. So first I am creating an Azure function with Javascript.

I am creating the function using VSCode. I am created a function using Javascript and HttpTrigger. Next I am installing the Playwright package using the command - `npm install playwright`. this command installs Playwright and browser binaries for Chromium, Firefox and WebKit. And I am installing `playwright-chromium` as well, so that I can access the library in the code.

Here is my `package.json` file
{% highlight Javascript %}
{
  "name": "url2pdf",
  "version": "1.0.0",
  "description": "",
  "scripts": {
    "start": "func start",
    "test": "echo \"No tests yet...\""
  },
  "dependencies": {
    "playwright": "^1.6.2",
    "playwright-chromium": "^1.6.2"
  },
  "devDependencies": {}
}
{% endhighlight %}

{'fraction_non_alphanumeric': 0.08143208143208143, 'fraction_numerical': 0.01755001755001755, 'mean_word_length': 4.577299412915851, 'pattern_counts': {'":': 10, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3831838', 'n_tokens_mistral': 841, 'n_tokens_neox': 747, 'n_words': 376}