The simplest of functions (http and timer) do not require the .net core dlls installing. if you use queue, blob storage triggers, you have to run func extensions install
before you run the function to install the necessary bindings. How to do this with docker is not covered in your tutorials. Please advise
⚠ Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.
Hi @GuyHarwood Thank you for your feedback! We have assigned this issue to the author to investigate further and take the right course of action.
The following worked for me:
type="queue"
or type="queueTrigger"
to function.jsonfunc extensions install
locally to create extensions.csproj
(I think this utility parses your function.json files)dotnet build -o bin
bin
directory gets added to your container in your Dockerfile. I use COPY . .
so everything gets added.For build, I'm using Azure Pipelines, so I added this task:
- task: DotNetCoreCLI@2
inputs:
command: custom
custom: build
arguments: -o bin
The cleanest approach (IMO) to this, is to use an intermediary container during docker build to install the binding extensions, then just copy the final sources to the official functions container. That way your build server (we use AzureDevOps & Travis) is kept clean...
### STAGE 1: Build ###
FROM node:10.6.0 as builder
SHELL ["/bin/bash", "-c"]
WORKDIR /func-app
COPY . .
RUN yarn install
# install .net core, azure functions core tools & required bindings
RUN apt-get update && \
curl -O https://dot.net/v1/dotnet-install.sh && \
source dotnet-install.sh --channel Current && \
rm dotnet-install.sh && \
npm i -g azure-functions-core-tools@core --unsafe-perm true && \
func extensions install
### STAGE 2: functions runtime image ###
FROM mcr.microsoft.com/azure-functions/node:2.0
ENV AzureWebJobsScriptRoot=/home/site/wwwroot
COPY --from=builder /func-app /home/site/wwwroot
This is working well for us in Travis and AzureDevOps / VSTS
@dariagrigoriu or @ahmelsayed can you please confirm what the best approach is for adding extensions to a function app in a custom Docker container? We either need to document this in a separate article or change the scenario to use a trigger other than HTTP.
Looking forward to this coming to fruition 👍
I think that extension bundles solves this issue. Let me confirm.
I tried the extension bundle in my host.json and it seemingly fixed this issue.
My host.json looks like this:
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
}
}
We've updated the original tutorial to show how to add an output binding to the function project and rebuild the container. #please-close
Most helpful comment
Looking forward to this coming to fruition 👍