brianzinn/create-react-app-typescript-babylonjs

Implementing Azure Function with Express.js

Closed this issue ยท 6 comments

yvele commented

Hey great job!

I've seen in your TODO that you are going to hook up the demo with Azure Function

image

Just to let you know that you can use https://github.com/yvele/azure-function-express ๐Ÿ˜‰

I don't want to advertise my own project but just want to help

PS: May I also suggest you to fill the repository website with https://brianzinn.github.io/create-react-app-typescript-babylonjs/todo

image

Nice Project! I've used Express quite a bit over the last year, but was planning on using Azure Functions Proxies for this. I want to be completely serverless and it looks like I would need Express running for your project. What are the advantages to your project over Azure Functions Proxies?

yvele commented

Thanks ๐Ÿ™‚

Oh with this simple adapter you can benefit from the popular express.js ecosystem and use many middlewares like http://expressjs.com/en/resources/middleware.html (+ integration testing frameworks, etc.)

That makes also the code portable to another platform (e.g. on AWS Lambda with aws-serverless-express).

I'm also using azure-function-express to run the API locally with a dead simple node.js app with express.

Plus a lot of node.js developers are familiar with express.js and connect (or koa)

PS: My project don't need you to install

yvele commented

PS: Express will run within your Azure Function without making a listening server.. Everything will still be serverless ๐Ÿ˜‰

Yes, I will definitely take a look. It's actually for another project I'm working on, so I will look at latency and cold start times with running Express in the function compared to Function Proxies. Curious also about how much memory and time are spent on each call for a cost comparison of the two.

For sure Function Proxies are not portable (lol), but do have integration for testing frameworks as they can be unit tested on local machine. They added BYOB (build your own bindings) to Azure Functions, but it's a long, long ways off all of the middleware options for Express, so I'll see where I end up. Thanks again.

PS: I realize function executions are super cheap, but would running Express within an Azure Function then calling a function incur two function executions? :)

yvele commented

No it's only one function execution.. Basically express is just simple code.. in a dependency

When you use dependencies within Azure Function and you want super optimised cold start, I recommend you using a bundler like Webpack or Rollup to flatten your dependencies, see Azure/azure-functions-host#298

Here is the Webpack configuration I actually use

Edit: Or use the brand new Azure App Setting SCM_USE_FUNCPACK=1 described here but it's experimental