简体   繁体   中英

Skip "Installing function extensions if needed"

I use the maven-plugin-for-azure-functions to create a Java Function App with a custom Trigger Binding. The custom trigger is created by another .Net project and publishs its artifacts via an Azure Devops Artifacts feed as an universal package.

I consume the custom trigger as universal package to get rid of the .Net dependencies during my Java Function App build.

While I download the package and copy its content into the stagingDirectory , the maven-plugin-for-azure-functions tries to install some extensions, too.

[INFO] Step 8 of 8: Installing function extensions if needed
...
[INFO] Function extension installation done.

The step creates a extensions.csproj with some default extensions and overrides the files of my custom extension. I tried to remove the PackageReference elements, but it's reverted with every package run.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp3.1</TargetFramework>
    <WarningsAsErrors></WarningsAsErrors>
    <DefaultItemExcludes>**</DefaultItemExcludes>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventGrid" Version="2.1.0" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.1.3" />
  </ItemGroup>
</Project>

How can I disable the function extensions installation ?

I found some workaround for the implicit extension installation of the plugin.

  1. During the prepare-package phase, I replace the host.json with some dummy file, which suppresses the installation process.

     { "version": "2.0", "extensionBundle": { "id": "Microsoft.Azure.Functions.ExtensionBundle", "version": "[1.*, 2.0.0)" } }

    Therefore the plugin skips the extension installation.

     [INFO] Step 8 of 8: Installing function extensions if needed [INFO] Extension bundle specified, skip install extension [INFO] Successfully built Azure Functions.
  2. I moved the script for the universal package download to the package phase, which is executed after the plugin. The script also reverts the host.json by removing the extensionBundle property and copies the reverted file to the stagingDirectory .

The resulting archive contains the bin folder of the universal package finally with the correct host.json .

In pom.xml add skipInstallExtensions to avoid run step in mvn package . Check example below:

<plugin>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-functions-maven-plugin</artifactId>
    <version>1.13.0-SNAPSHOT</version>
    <configuration>
        <!-- potential configuration property -->
        <skipInstallExtensions>true</skipInstallExtensions>
    </configuration>
</plugin>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM