jnotelddim
jnotelddim

Reputation: 2045

What to use instead of Azure Web Apps to allow installation of google chrome in app environment?

I've just created a feature for our application which generates a powerpoint report from the data a given user has in our system.

In short, the server spawns an instance of google chrome using Selenium's ChromeDriver, and from there scrapes out the charts from our application running in chrome. It was done this way to ensure the charts in the report look exactly the same as they appear in the clients' browsers.

We use Azure Web Apps to host our development and production environments, and while my reporting feature works fine in local environments, it doesn't work once deployed to any other environments, because it depends on chrome being installed, and I can't get it installed in the Azure Web App sandboxed environment. (you can see this other question of mine for a bit of a reference to where things are going wrong: PowerShell StartProcess: invalid handle )

SO

What I pretty much want to know is, if an Azure Web App environment isn't going to allow me to install google chrome, where should I look next?

Upvotes: 2

Views: 2581

Answers (2)

Dodger
Dodger

Reputation: 391

I have found myself this problem with chromedriver.exe needing a real Chrome. As I cannot install Chrome in Azure App Service I am trying a portable version of Chrome. When using the chrome webdriver I tell it where to find the chrome binary.

var options = new ChromeOptions();
options.AddArguments("headless"); // any options you need
options.BinaryLocation = "YOUR CHROME BINARY PATH HERE";
var driver = new ChromeDriver("YOUR CHROME DRIVER PATH HERE", options);

You should be able to copy the chrome portable files as no installation is required. Although it is heavy, 250 MB, because it includes the non portable version inside.

Be sure to use a Chrome version compatible with your ChromeDriver as pointed in the documentation

Upvotes: 0

Harald F.
Harald F.

Reputation: 4743

There's a couple of solutions which would work - depending on your code and framework dependencies.

IMO - the simplest way would be to build your code in a docker container (that runs the Selenium ChromeDriver) and deploy it either through the container features on Web Apps or run it on demand through ACI (Azure container instances) and have it create the report and drop it in Azure Storage. In a container you have a lot more options - and you have a great amount of options on how to run it. Spinning up an ACI on-demand to do the job can be done in multiple ways (e.g. from Code or through logic-apps or Powershell/Azure automation).

Here are some links on running containers in your App Service:

https://learn.microsoft.com/en-us/azure/app-service/containers/

https://learn.microsoft.com/en-us/azure/app-service/containers/tutorial-custom-docker-image

You could start off by building and adding your code from this image: https://github.com/SeleniumHQ/docker-selenium

Other alternatives of course - you could have a VM that you can install and do what you want with on-demand - however - it'd add more management overhead and other implications to think about.

Many options - but in the regual Web App Sandbox - you're limited.

Upvotes: 1

Related Questions