Featured image of post Adding Azure Functions Support to a Devcontainer

Adding Azure Functions Support to a Devcontainer

A container image for developing Azure Functions with Azure Functions Core Tools exists. What if one wants to add Azure Functions Core Tools to an existing dev container?

Recently, I needed to add support for Azure Functions to an existing Dev Container.

The first thing I tried was to add the following to my Dockerfile:

1
2
RUN apt-get update \
    && apt-get -y install azure-functions-core-tools-4

Unfortunately, that resulted in errors when rebuilding the container. So after searching online, and reviewing documentation, I eventually landed on this RUN command:

1
2
3
4
5
6
RUN curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg \
    && sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg \
    && apt-get update \
    && sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/debian/$(lsb_release -rs | cut -d'.' -f 1)/prod $(lsb_release -cs) main" > /etc/apt/sources.list.d/dotnetdev.list' \
    && sudo apt-get update \
    && apt-get -y install azure-functions-core-tools-4

This successfully rebuilt the container image and had the Azure Functions Core Tools installed.

Next, I added the following extensions to the devcontainer.json file:

1
2
3
4
5
6
	"extensions": [
		"ms-azuretools.vscode-azurefunctions",
		"ms-vscode.azure-account",
		"ms-azuretools.vscode-azureresourcegroups",
		"azurite.azurite"
	]

With that, I had a working environment fully loaded with Azure Functions Core Tools and the necessary Visual Studio Code extensions installed. Hope that helps, dear future reader!

References:
Use a Docker container as a development environment with Visual Studio Code
Work with Azure Functions Core Tools
Azure Functions Core Tools

Built with Hugo
Theme Stack designed by Jimmy