1
votes

When I deploy my Azure Function project to my Function App based on the v2 runtime, the binding extensions my project depend on (Azure Storage in my case), are not automatically created.

I deploy my project with an extensions.csproj file on the root, but after deploying I have to manually run the following command to create a bin and obj folder at wwwroot.

dotnet build extensions.csproj -o bin --no-incremental --packages D:\home\.nuget

If I understand correctly, this should happen automatically.

2
Are you using the correct version of the packages/extensions? Version should be >=3.0.0. - Boris Wilhelms
I'm using version 3.0 of the Nuget packages: <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Http" Version="3.0.0" /> <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.0" /> <PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.0.0" /> - Ramon
@Ramon How do you generate function code and deploy it, using function core tools? - Jerry Liu
@JerryLiu, yes I use function core tools version 2. Runtime is nodejs btw. - Ramon

2 Answers

2
votes

For deployment by CLI func azure functionapp publish

Function core tools use zip deployment to deploy functions, in this way, kudu doesn't build project by default. To enable the feature, set SCM_DO_BUILD_DURING_DEPLOYMENT to true in Application settings on portal.

As for why the default setting is false, zip deployment usually requires the content to be deployed including all related files hence there's no need to build again.

For Azure function core tools, we usually use command func extensions install to register extensions for input/output binding when extensions are not installed automatically like we create trigger from template. This is why command func start and func azure functionapp publish doesn't build extensions.csproj, extensions are supposed to be installed before we run or publish functions.

Update for DevOps deployment

With Azure pipeline, we need to build extensions.csporj before archive files. Add a .NET Core build task, arguments are -o bin.

If you want kudu to build project, go to Deployment Center under Platform features. Choose VSTS as a CI repository and kudu will build and deploy project for you.

0
votes

When using Visual Studio, you'll be referencing the extension packages directly from your project in order to use their attributes and other types, so Visual Studio handles the installation process, but registration still needs to be performed.

This is handled by a custom build task, added by the Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator NuGet package, which must be explicitly referenced (this will be automatically brought in by the SDK/Visual Studio tools in a future update).

These are the steps you must follow to use the CosmosDB extension mentioned in our previous example:

1.Add a reference to the Microsoft.Azure.WebJobs.Extensions.Storage NuGet package

2.Add a reference to the Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator

3.Build the project

For more details, you could refer to this article.