Make a Docker image or Vagrant box for local Azure Functions development

Category: azure functions

Question

snoopdouglas on Mon, 06 Nov 2017 11:51:18


Docker and Vagrant are great to develop with (in my opinion ;) and so it'd be great to have a ready-made environment posted to Docker Hub and/or Hashicorp Atlas rather than having to set it up myself.

If there were to be a Docker image, this'd obviously be a goal for Functions 2.0 given the lack of Linux compatibility for v1.

Replies

Chris Gillum (MSFT) on Mon, 06 Nov 2017 22:47:43


We're working on something like this right now as part of the Functions 2.0 work we're doing. Stay tuned for announcements related to this by checking out the Azure Functions Twitter account or the Azure App Service Team Blog (which also posts Azure Functions announcements).

AhmedElSayed on Tue, 07 Nov 2017 00:47:50


I have a very basic docker image here that has the 2.0 cli

https://hub.docker.com/r/ahmelsayed/azure-functions-dev

and here is its Dockerfile https://github.com/ahmelsayed/docker-images/blob/master/azure-functions-dev/Dockerfile

It's still pretty rough, but should get you started.

The container contains .NET Core 2.0, Node 8.x, and docker client. If you wanna use the docker client, run your container with -v /var/run/docker.sock:/var/run/docker.sock (if you are running unix machine)

snoopdouglas on Wed, 08 Nov 2017 19:04:40


I've just noticed the --docker option on the functions CLI, which generates the following Dockerfile:

FROM microsoft/azure-functions-runtime:v2.0.0-beta1
ENV AzureWebJobsScriptRoot=/home/site/wwwroot
COPY . /home/site/wwwroot


AhmedElSayed on Wed, 08 Nov 2017 21:20:38


yep, that's there too, though that only has runtime itself, no cli bits. so you can deploy the whole container to any container hosting solution.

but please do update the tag to point to 2.0.0-jessie instead of v2.0.0-beta1. I need to update the cli to do that as well. the 2 tags are identical at the moment, but the final one will be the -jessie one.

snoopdouglas on Thu, 09 Nov 2017 13:57:25


Sounds good. Only problem I've noticed with using this in Docker is CLI's lack of ability to bind on 0.0.0.0, which prevents port exposure; for the moment I've got nginx running in the container as a proxy to localhost:7071.