Scheduled task on Azure that runs a webpage with javascript

≡放荡痞女 提交于 2020-02-28 23:11:40

问题


I have a data-driven view on an Azure site that renders a lot of JavaScript/ CSS / XML and HTML from a third party plugin and generates a PDF which is emailed to a user.

I need to call this page on a weekly schedule for each user - and with Azure Jobs it's really straightforward to set this up. But obviously there will be no JavaScript engine to render the code that generates the PDF, so what are my options?

Would I have to go down the route of installing NodeJS on my Azure instance? If so what are the steps and other modules required.

The site is running MVC C# and has a SQL back end.

Cheers for any pointers.


回答1:


If code you need to run can be factored / extracted as a Node.js app, you can run it as a scheduled Azure WebJob. You can find details on how to do that here. You don't need to install Node.js - it's already installed on all the Azure App Service workers.

One thing to note is that WebJobs run an execution sandbox (details here) and there are some restrictions on what is allowed to run in the sandbox. So you'd have to experiment to see if your PDF library runs successfully there.

For example, one of the popular libraries for PDF generation wkhtmtopdf will not work on Azure App Service. This SO post discusses this in more detail. One user has successfully hosted wkhtmtopdf on an Azure VM and offers it as a service that you can call.



来源:https://stackoverflow.com/questions/34918670/scheduled-task-on-azure-that-runs-a-webpage-with-javascript

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!