PhantomJS as web job in Azure

2019-01-07 15:38发布

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.

3条回答
Explosion°爆炸
2楼-- · 2019-01-07 15:53

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

查看更多
我只想做你的唯一
3楼-- · 2019-01-07 16:05

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.

查看更多
唯我独甜
4楼-- · 2019-01-07 16:06

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

查看更多
登录 后发表回答