Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get a C# azure service that uses ChromeDriver to work in an Azure Cloud Service

I've written a C# Azure cloud service that uses Selenium.WebDriver.ChromeDriver but it doesn't work when I deploy it to Azure (Locally it runs fine - probably because I have Chrome installed). I deploy chromedriver.exe with my service but it fails because chrome.exe isn't found. I've tried deploying a copy of chrome.exe but that didn't work. I also tried adding the GoogleChrome nuget package but this also didn't work.

Anyone know a way to get a C# azure service that uses Selenium/Chromedriver to work?

like image 983
Hallupa Avatar asked Sep 15 '17 20:09

Hallupa


People also ask

What grade do you need for AC?

Common examples of grade conversion are: A+ (97–100), A (93–96), A- (90–92), B+ (87–89), B (83–86), B- (80–82), C+ (77–79), C (73–76), C- (70–72), D+ (67–69), D (65–66), D- (below 65).


2 Answers

Three things you'll need to get this to run on an Azure cloudservice

  • ChromeSetup.exe file included in your CloudService/Roles/Role directory
  • A line in your service definition file to call a startup script that runs the above file
  • That startup script included in your worker role's project

To add ChromeSetup.exe, right click on the name of your role beneath the cloud service and just "Add Item" and find where you downloaded the chrome installer last.

Example of Where to Add ChromeSetup.exe from recent project

The startup task is added by going into the ServiceDefinition.cdef file--example from a recent project below.

<WorkerRole name="WebReportDownloader" vmsize="Small">
<Startup>
  <Task commandLine="Initialization\Startup.cmd" executionContext="elevated" taskType="simple">
    <Environment>
      <Variable name="MyVersionNumber" value="1.0.0.0" />
    </Environment>
  </Task>
</Startup>

The script the above task calls is pretty simple and logging anything to a text file is optional from my reading:

ECHO The current version is %MyVersionNumber% >> "%TEMP%\StartupLog.txt" 2>&1
START ChromeSetup.exe 
EXIT /B 0

Hopefully this saves you some of the grief I ran into while piecing together several resources...

like image 75
jdmac020 Avatar answered Oct 15 '22 22:10

jdmac020


I found another way of doing this without having to install Chrome - instead of using Chrome I ended up using Chromium.

For this I just downloaded the Chromium archive from https://chromium.woolyss.com/download/ then have it extract to my binaries directory - this still has Chrome.exe binary but doesn't need installing

like image 22
Hallupa Avatar answered Oct 15 '22 20:10

Hallupa