Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use node-horseman in azure function? #295

Open
karandesai28 opened this issue Jul 5, 2017 · 2 comments
Open

How to use node-horseman in azure function? #295

karandesai28 opened this issue Jul 5, 2017 · 2 comments

Comments

@karandesai28
Copy link

karandesai28 commented Jul 5, 2017

I am trying to run node-horseman in httptriggered azure function. I installed node-horseman using npm in azure function directory as well. However various service calls like, Log(), on(), open() etc does not seem to work.

So it will be great if a demo regarding the same is added, or shared for better understanding. Thanks.

@awlayton
Copy link
Collaborator

awlayton commented Sep 5, 2017

I have never worked with Azure. Did you make sure PhantomJS is installed on there?

@karandesai28
Copy link
Author

Yes, on Azure Portal via Kudu Cmd, I have installed the PhantomJS as well as Node Horseman and the node modules folder is also created on portal containing the packages. I wrote this sample code in Azure Function after installing all the required dependencies:


var Horseman = require('node-horseman');
var horseman = new Horseman();
horseman
  .open("http://google.com/")
  .pdf("Filename.pdf", {
      format: 'A4',
      orientation: 'portrait',
      margin: '1cm'
  })
  .close()`

I noticed that it does get executed without any error; but Pdf file wasn't generated. I placed success, info and error logs in between. I also added various event listeners mentioned in this part of Node-Horseman documentation. But neither logs printed anything.

I then commented the code, and wrote simple file creation code from azure function which didn't work either. On further researching, I asked on Stack Overflow, whether is it possible to Create and Write any file from Azure Function (Azure function supports Blob and File triggers) and store in File (or Blob) storage directly; to which I got the following reply and comment:

There is a preview of Azure Functions External File bindings to upload file to external storage, but it doesn't work with Azure File Storage. There is a github issue to create a new type of binding for Files.

This led me to conclusion that, we can do file operations from azure function on already existing file (via uploading, or any other similar method) but the creation of File is not possible as of date of writing. However, the feature is being tracked on their github page. Therefore, there is potentially not an issue with Node-Horseman code except that an exception or error should have been thrown on .pdf() when it fails to create file or faces any issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants