Deploying a Node Application for Azure Features

I am wondering how one could deploy the Node.js app for Azure Functions.

Basically, I have the function set up and run the main http hello world example, which looks like this:

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 application I'm trying to deploy to a function is a simple moc client that uses swagger (basically it accepts the request and returns some xml). App.js looks like this:

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

That I'm not sure how to handle module.exports = application when modeul.exports is used to set a function (i.e. module.exports = function (context, req))

+4
source share
1 answer

azure-function-express, swagger.

, (, body-parser). , req - body.

+3

Source: https://habr.com/ru/post/1675620/


All Articles