Skip to content

Custom Extension Bundle

Naren Soni edited this page Apr 26, 2022 · 2 revisions

Creating a custom extension bundle

You may need to create a custom version of extension bundle for number of scenarios. This page walks through the process of creating an extension bundle with an id of your choosing.

Requirements

  • Azure storage account with blob endpoint
  • Azure.Storage module for powershell

Generating a bundle package

  1. Choose a base branch from the bundle repo that you want use to generate your bundle.
  2. Clone the branch and follow the build steps for the respective branch. For this example we would use branch v2.x
  3. Build the branch to confirm your build setup works as expected.
  4. Update the Bundle id and version property to the custom id and version in bundleConfig.json file to match your expectations. Extension bundle follows NuGet package versioning scheme. Checkout this page for more information in versioning schema
  5. Build again to confirm the changes took effect
  6. Follow the steps here to add remove an extension

Bundle source endpoint

Azure Functions downloads the configured extension bundle based on host.json configuration. This would mean that for custom extension bundle to work you would need to override the default bundle source endpoint with a your own. The steps in this sections walks you through the process of creating such and endpoint and uploading bundle artifacts to one.

Create bundle source endpoint

  1. Create an Azure Storage account that is capable of hosting blobs.
  2. Create a container with name "public"
  3. Set the public access level to "Blob (anonymous read access for blobs only)"

Uploading bundle to custom bundle source

  1. Once the bundle is generated. Locate the artifacts directory at the root of the repo.
  2. Run the following commands to upload the extension bundle to the storage account.
#  Azure.Storage module is required to run script below
cd tools
.\uploadToStorage.ps1 -StorageAccountName "<AccountName>" -StorageAccountKey "StorageAccountKey" -bundleId "BundleId"

Configuring Azure functions to use a custom bundle source endpoint

  1. Delete the extensions bundle directory at /Users/<user>/.azure-functions-core-tools or %userprofile%\.azure-functions-core-tools
  2. Set the environment variable FUNCTIONS_EXTENSIONBUNDLE_SOURCE_URI=https://<storageAccountName>.blob.core.windows.net/public
  3. Set host.json to
{
  "version": "2.0",
  "extensionBundle": {
    "id": "Microsoft.Azure.Functions.ExtensionBundle",
    "version": "[<bundleVersion>,<nextMajorversion>)"    // Sample: "version": "[2.9.1,3.0.0)".
                                                         // By default this value is always a range. A single verison number is still considered as version range.
                                                         // "version": "2.9.1" would mean >= 2.9.1
  }
}