Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PhantomJS as web job in Azure

I have deployed an asp.net mvc website in azure and I am trying to deploy phantomJS as a web job to support the web site. I have uploaded a zip file with all the necessary dependencies to run PhantomJS and the web job starts successfully after running my batch file. The log reports that the server is up and running @ 127.0.0.1:8080. However when I try to hit the PhantomJS app at url 127.0.0.1:8080 from my azure site hosted under someProject.azurewebsites.net it just times out with no other error message.

Specifically I am trying to deploy a phantomJS application that hosts a web endpoint (https://github.com/thelgevold/PhantomSnapshot) that will enable me to convert web pages to pdf if I pass a url from the website to the phantomJS process.

The website will pass a url to PhantomJS that will respond back with a pdf file that can be downloaded. I already have it working outside of Azure, but was curious if the PhantomJS process can be hosted as a web job

Does anyone know if it is possible to deploy PhantomJS in this manner? I am running my site under the "free" configuration.

like image 311
TGH Avatar asked Apr 06 '14 21:04

TGH


3 Answers

PhantomJS is not working on azure Webjobs.

I tried to execute it through CMD shell [yoursite].scm.azurewebsites.net/DebugConsole , but it hanges when I call it with raserize.js script.

you can use phantomjs as worker role, it will work.

Update

Regarding to this: https://stackoverflow.com/a/23000040/3080500

phantomJS uses GDI to render images and pdf, and GDI is blocked in Azure Website

ref : GDI is not enabled in azure webisites http://social.msdn.microsoft.com/Forums/windowsazure/en-US/b4a6eb43-0013-435f-9d11-00ee26a8d017/report-viewer-error-on-export-pdf-or-excel-from-azure-web-sites

ref : PhantomJS uses GDI for rendering fonts : https://github.com/ariya/phantomjs/blob/6a01a8dece0c4dd697eaa0b208057d2bd43a30f3/src/qt/mkspecs/win32-msvc2003/qmake.conf#L63

like image 165
Ammaroff Avatar answered Nov 04 '22 17:11

Ammaroff


We have the same issue with WSAS (Windows Azure Web Sites). We can run can communicate via stdin/stdout with phantomjs.exe, but when ever it does an actual network request, it will time out, or will freeze if a timeout is not set.

Some other applications can make network requests (f.e. curl.exe), but if you try running "ping", it will respond with "Unable to contact IP driver. General failure." googling which tells that there's likely a Hyper-V misconfiguration on their virtual servers.

like image 43
Dmitry Dzygin Avatar answered Nov 04 '22 15:11

Dmitry Dzygin


Azure Websites will not allow you to listen on ports, also you cannot use localhost from within your Azure Website.

like image 3
Amit Apple Avatar answered Nov 04 '22 16:11

Amit Apple