Reputation: 852
I have an application that uses Selenium WebDriver to automated a website's visual testing simulated on different browser on another server/computer. In the same application I am taking screenshots of the website and sending those to a storage endpoint.
In one possible scenario, I would like this application to run from the command of an Azure Function after receiving a message from a message queue.
Question: How can an Azure Function start a Node.js application on command? Could I put this application under and Azure Web App?
Upvotes: 1
Views: 506
Reputation: 24148
As I known, Selenium WebDriver works to communicate with the browsers which require GDI
support. However, due to the Win32k.sys (User32/GDI32) Restrictions
of Azure Web App sandbox
as below, so you can not smoothly migrate your Node application for visual testing and screenshots to Azure App services for Windows include Azure WebApp, Azure Functions and WebJobs.
There are two solutions for yours: Azure App Services on Linux or Azure VM.
To build a Docker image pre-installed headless chrome/chromium and deploy your Node app into it as web app, then you can do the same thing via request it from an Azure Functions with a trigger you want. Or even directly integrate this Node app with Azure Functions on Linux. You can refer to these offical tutorials to get the knowledge of Azure Functions on Windows/Linux, such as Create your first function hosted on Linux using Core Tools and the Azure CLI (preview).
To create an Azure VM, then you can do any thing what you want, even run an Azure Functions dev environment with a trigger on VM instead of an Azure Functions instance. The base logic flow is to use Azure Functions dev env with a trigger to invoke your Node app, that they can be deployed on the same one VM.
Hope it helps. Any concern, please feel free to let me know.
Upvotes: 0
Reputation: 14334
If your Node.js app is an azure web or Azure Webjob, you could start it with REST API. Here are web app and webjob.
From your situation, I think you could just develop a queue trigger Function(Node.js), don't have to use a queue trigger function to call Node.js app.The below is a Node.js queue Function sample.
module.exports = async function (context, message) {
context.log('Node.js queue trigger function processed work item', message);
// OR access using context.bindings.<name>
// context.log('Node.js queue trigger function processed work item', context.bindings.myQueueItem);
context.log('expirationTime =', context.bindingData.expirationTime);
context.log('insertionTime =', context.bindingData.insertionTime);
context.log('nextVisibleTime =', context.bindingData.nextVisibleTime);
context.log('id =', context.bindingData.id);
context.log('popReceipt =', context.bindingData.popReceipt);
context.log('dequeueCount =', context.bindingData.dequeueCount);
context.done();
};
Further more information about Node.js Function, you could refer to these docs:Trigger - JavaScript example and Azure Functions JavaScript developer guide.
Upvotes: 1