Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

265
Views
Deploying a Node app on Azure Functions

I am wondering about how it might be possible to deploy a Node.js app on Azure Functions.

Basically, I have a function setup and running a basic hello world http example that looks like:

module.exports = function (context, req) {
    context.log('JavaScript HTTP trigger function processed a request.');
    context.res = {
        // status: 200, /* Defaults to 200 */
        body: "Hello " + req.params.name
    };
    context.done();
};

The app I am trying to deploy into a function is a simple moc client that uses swagger (basically takes a request and returns some xml). The app.js looks like:

const SwaggerExpress = require('swagger-express-mw');
const app = require('express')();
const compression = require('compression');

const configSwagger = {
    appRoot: __dirname, // required config
};


SwaggerExpress.create(configSwagger, (err, swaggerExpress) => {
    if (err) {
        throw err;
    }

    // install middleware
    swaggerExpress.register(app);

    // server configuration
    const serverPort = process.env.PORT || 3001;
    app.listen(serverPort, () => {
        //logger.info('Listening on port %s', serverPort);
    });

    app.use(compression());
});

module.exports = app; // for testing

The thing I am not sure about is how to handle module.exports = app when modeul.exports is used to establish the function (i.e. module.exports = function (context, req))

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can try to use azure-function-express to enable your swagger middleware.

Note that certain middleware will not function correctly (for example, body-parser). This is because the functions req is not a stream - it is injected into the function with a 'body' property already populated.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!