Azure-webjobs-sdk: Unable to load Microsoft.Azure.WebJobs.Extensions.Storage

Created on 13 May 2019  路  2Comments  路  Source: Azure/azure-webjobs-sdk

I am unable to use version 3.0.6 of Microsoft.Azure.WebJobs.Extensions.Storage

Repro steps

Simply create an Azure Functions project with a csproj like below:

<Project Sdk="Microsoft.NET.Sdk">

    <PropertyGroup>
        <TargetFramework>netcoreapp2.2</TargetFramework>
        <AzureFunctionsVersion>v2</AzureFunctionsVersion>
    </PropertyGroup>

    <ItemGroup>
        <PackageReference Include="Newtonsoft.Json" Version="11.0.2" />
        <PackageReference Include="Microsoft.Azure.Functions.Extensions" Version="1.0.0" />
        <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.Storage" Version="3.0.6" />
        <PackageReference Include="Microsoft.Azure.WebJobs.Script.ExtensionsMetadataGenerator" Version="1.1.0" />
        <PackageReference Include="Microsoft.Extensions.Http.Polly" Version="2.2.0" />
        <PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0" />
        <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.27" />
    </ItemGroup>

    <ItemGroup>
        <None Update="host.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
        </None>
        <None Update="local.settings.json">
            <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
            <CopyToPublishDirectory>Never</CopyToPublishDirectory>
        </None>
    </ItemGroup>

</Project>

Use a host.json file like this:

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

Run your function using func start

Expected behavior

The function runs locally.

Actual behavior

[05/13/2019 13:47:21] Starting JobHost
[05/13/2019 13:47:21] Starting Host (HostId=wtambp486-511200089, InstanceId=71da8891-a2a9-4ca0-8467-1431bd33be53, Version=2.0.12438.0, ProcessId=50673, AppDomainId=1, InDebugMode=False, InDiagnosticMode=False, FunctionsExtensionVersion=)
[05/13/2019 13:47:21] Loading functions metadata
[05/13/2019 13:47:21] 1 functions loaded
[05/13/2019 13:47:21] WorkerRuntime: dotnet. Will shutdown other standby channels
[05/13/2019 13:47:21] Generating 1 job function(s)
[05/13/2019 13:47:21] A host error has occurred
[05/13/2019 13:47:21] System.Private.CoreLib: Could not load file or assembly 'Microsoft.Azure.WebJobs.Extensions.Storage, Version=3.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Could not find or load a specific file. (Exception from HRESULT: 0x80131621). System.Private.CoreLib: Could not load file or assembly 'Microsoft.Azure.WebJobs.Extensions.Storage, Version=3.0.6.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.
[05/13/2019 13:47:21] Stopping JobHost
Container is disposed and should not be used: Container is disposed.
You may include Dispose stack-trace into the message via:
container.With(rules => rules.WithCaptureContainerDisposeStackTrace())
Application is shutting down...

Known workarounds

Using version 3.0.4 of Microsoft.Azure.WebJobs.Extensions.Storage seems to fix the issue.

Related information

None.

Most helpful comment

I noticed that I get a similar issue in azure portal.
This only occurs when including the same extensionBundle section in the host.json (shown above).
When I take this section out (and install with nuget, 3.0.6), it seems to work fine.

All 2 comments

I noticed that I get a similar issue in azure portal.
This only occurs when including the same extensionBundle section in the host.json (shown above).
When I take this section out (and install with nuget, 3.0.6), it seems to work fine.

This is actually by design. When you add the following extension bundle config to host.json.

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

It signals the runtime to use a pre-packaged set of extension instead of using the extension installed explicitly by the user. Extension bundles is not designed to be used for pre-compiled C# functions. Here is the list of set of extensions present in the latest extension bundle: extensions.

When a new extension bundle with updated extension is published, the runtime will automatically fetch it and consume the new extension bundle, As long as the new bundle version is within the version range [1.*, 2.0.0).

Here is link to the documentation on extensionBundle configuration.
https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-register

Was this page helpful?
0 / 5 - 0 ratings