azure-function-express
Allows Express usage with Azure Function
Description
Connect your Express application to an Azure Function handler, and make seamless usage of all middlewares you are already familiar with.
Usage
In your index.js
:
const createAzureFunctionHandler = require("azure-function-express").createAzureFunctionHandler;
const express = require("express");
const app = express();
app.get("/api/:foo/:bar", (req, res) => {
res.json({
foo : req.params.foo,
bar : req.params.bar
});
});
module.exports = createAzureFunctionHandler(app);
Make sure you are binding req
and res
in your function.json
:
{
"bindings": [{
"authLevel" : "anonymous",
"type" : "httpTrigger",
"direction" : "in",
"name" : "req",
"route" : "foo/{bar}/{id}"
}, {
"type" : "http",
"direction" : "out",
"name" : "res"
}]
}
You can have a single function.json
that matches all HTTP routes with binding "route": "{*segments}"
.
And let Express handles routing.
All examples here.
License
Apache 2.0 © Yves Merlicco