Code Monkey home page Code Monkey logo

azure-functions-pack's Introduction

Azure Functions Pack

This is a tool to make it easy to package your Azure Functions Node.js Functions for optimal performance on Azure Functions.

The problem addressed

Whenever an Azure Function App is recreated on demand (a so called "cold start") the node'js module cache for each Function will be empty. The current Functions file system is sluggish in dealing with many small file accesses so there is a significant delay as node reads all the module files. Fortunately, node caches the modules in memory so subsequent accesses are fast.

The solution

A javascript module bundler (webpack) is used to place all the modules in a single file. The Function functions.json files are then modified so this bundle is used rather than the separate modules files. Magic!

๐Ÿšง This project is experimental; use with caution and be prepared for breaking changes ๐Ÿšง

How to run

In the Function App directory:

npm install -g azure-functions-pack
funcpack pack ./

You can then test locally using the CLI tool: func run <myfunc>

When uploading your files, you need to include the single .funcpack directory (in the Functions App root), but you don't need your node_modules directory.

API

Usage: main [options] [command]


  Commands:

    unpack [options] <path>  Will remove all traces of packing tool at the specified path or the current directory if none is specified
    pack [options] <path>    Will pack the specified path or the current directory if none is specified

  Options:

    -h, --help     output usage information
    -V, --version  output the version number
    -d, --debug    Emits debug messages

unpack

Usage: unpack [options] <path>

  Will remove all traces of packing tool at the specified path or the current directory if none is specified

  Options:

    -h, --help           output usage information
    -o, --output <path>  Path for output directory

Note: the uglify feature only supports some small amount of es6, so I recommend that if you get errors either don't uglify or drop your code down to es5.

Uglify will minimize the sample project that's included from 27 MB to 9 MB.

pack

Usage: pack [options] <path>

  Will pack the specified path or the current directory if none is specified

  Options:

    -h, --help           output usage information
    -u, --uglify         Uglify the project when webpacking
    -o, --output <path>  Path for output directory

License

MIT

azure-functions-pack's People

Contributors

christopheranderson avatar stevealee avatar

Watchers

James Cloos avatar Tamas avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.