# azure-function-express-cloudify

> Allows Express usage with Azure Function

Latest version **1.2.2-1** (published 2017-08-18) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install azure-function-express-cloudify
pnpm add azure-function-express-cloudify
yarn add azure-function-express-cloudify
bun add azure-function-express-cloudify
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2-1 |
| Published | 2017-08-18 |
| First published | 2017-08-18 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6.5.0 <7 |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 167 |
| Author | Merlicco Yves |
| Maintainers | cloudify |
| Keywords | azure function, express, connect, azure, koa |

## Links

- npm: https://www.npmjs.com/package/azure-function-express-cloudify
- Repository: https://github.com/yvele/azure-function-express
- Issues: https://github.com/yvele/azure-function-express/issues
- npm.io page: https://npm.io/package/azure-function-express-cloudify

## Recent versions

- 1.2.2-1 (latest) — 2017-08-18
- 1.2.2 — 2017-08-18

## README

# azure-function-express

<img align="right" alt="Function logo" src="media/function.png" title="Function" width="150"/>

> Allows Express usage with Azure Function

[![npm version](https://img.shields.io/npm/v/azure-function-express.svg)](https://www.npmjs.com/package/azure-function-express)
[![Travis Status](https://img.shields.io/travis/yvele/azure-function-express/master.svg?label=travis)](https://travis-ci.org/yvele/azure-function-express)
[![Coverage Status](https://img.shields.io/codecov/c/github/yvele/azure-function-express/master.svg)](https://codecov.io/github/yvele/azure-function-express)
[![MIT licensed](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](LICENSE)

## Description

[Connect](https://github.com/senchalabs/connect) your [Express](https://expressjs.com) application to an [Azure Function handler](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node), and make seamless usage of [all middlewares](http://expressjs.com/en/guide/using-middleware.html) you are already familiar with.

## Usage

In your `index.js`:

```js
const createHandler = require("azure-function-express").createHandler;
const express = require("express");

// Create express app as usual
const app = express();
app.get("/api/:foo/:bar", (req, res) => {
  res.json({
    foo  : req.params.foo,
    bar  : req.params.bar
  });
});

// Binds the express app to an Azure Function handler
module.exports = createHandler(app);
```

Make sure you are binding `req` and `res` in your `function.json`:

```json
{
  "bindings": [{
    "authLevel" : "anonymous",
    "type"      : "httpTrigger",
    "direction" : "in",
    "name"      : "req",
    "route"     : "foo/{bar}/{id}"
  }, {
    "type"      : "http",
    "direction" : "out",
    "name"      : "res"
  }]
}
```

To allow Express handles all HTTP routes itself you may set a glob star route in a single root `function.json`:

```json
{
  "bindings": [{
    "authLevel" : "anonymous",
    "type"      : "httpTrigger",
    "direction" : "in",
    "name"      : "req",
    "route"     : "{*segments}"
  }, {
    "type"      : "http",
    "direction" : "out",
    "name"      : "res"
  }]
}
```

Note that `segments` is not used and could be anything. See [Azure Function documentation](https://github.com/Azure/azure-webjobs-sdk-script/wiki/Http-Functions).

All examples [here](/examples/).

## Log via context

The [log function](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node#writing-trace-output-to-the-console) is the only [context](https://docs.microsoft.com/en-us/azure/azure-functions/functions-reference-node#context-object) function made available. You can access through `req.context.log`:

```js
app.get("/api/hello-world", (req, res) => {
  req.context.log({ hello: "world" });
  ...
});
```

## License

[Apache 2.0](LICENSE) © Yves Merlicco

---
_Source: https://npm.io/package/azure-function-express-cloudify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
