Application diagnostics
.NET Core Azure Azure App Services Azure Function Azure Storage Blob Trigger C# Diagnostics PaaS Visual Studio

How to Troubleshoot Azure Blob Trigger Functions

Welcome to today’s post.

I will discuss some errors and issues you may have encountered while trying to use Azure Function bob triggers.

I will also suggest some workarounds that have worked for me.

One type of error that can occur is the loading of blob trigger types:

The function runtime is unable to start. System.Private.CoreLib: Could not load type 'Microsoft.Azure.WebJobs.BlobTriggerAttribute' from assembly 'Microsoft.Azure.WebJobs, Version=3.0.15.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

This occurs after deploying the blob trigger, and selecting the trigger function in the function app:

My recommended fix for this issue is to upgrade the following NuGet packages to the latest versions:

Microsoft.Azure.WebJobs

Microsoft.Azure.WebJobs.Extensions

Microsoft.Azure.WebJobs.Extensions.Http

After upgrading, your solution should look as follows:

Note: The Azure Function tools package Microsoft.NET.Sdk.Functions will have its package references overridden by the upgraded packages, so it does not require upgrading for this workaround.

Rebuild and republish the function app, then refresh the function app application service from the portal. The error should no longer occur.

Another type of error you may experience is the blobTrigger binding type error as shown:

Function (BookLoanEventGridFunctionApp??????????/BlobTriggerFunction) Error: The binding type(s) 'blobTrigger' are not registered. Please ensure the type is correct and the binding extension is installed.

After a search, I found the following in GitHub for Azure web jobs:

There is an additional NuGet package below:

Microsoft.Azure.WebJobs.Extensions.Storage

that needs installation in order to recognize the blob trigger attribute. After installation, your solution should contain the following packages:

In addition, you will need to register the extension bundle in the Function app by updating the host.json file as follows:

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

See the link for further details.

Rebuild and republish the function app, then refresh the function app application service from the portal. The error should no longer occur.

Another error you should be aware of is with connection strings. One common error is shown below:

Function (BookLoanEventGridFunctionApp?????????????/BlobTriggerFunction) Error: Microsoft.Azure.WebJobs.Host: Error indexing method 'BlobTriggerFunction'. Microsoft.Azure.WebJobs.Extensions.Storage: Storage account connection string ‘?????????????????????????????????????’ does not exist. Make sure that it is a defined App Setting.

The more details error is shown below:

To fix this issue, you will need to check your trigger function implementation includes a correct connection string declaration that is validly declared within the host.settings.json file:

Also confirm the connection string is valid within the local.settings.json configuration file:

The final error I will show is to do with missing connection strings. The error below:

Error: Microsoft.Azure.WebJobs.Host: Error indexing method. Microsoft.Azure.WebJobs.Extensions.Storage: Storage account connection string does not exist. Make sure that it is a defined App Setting.

This error is caused by not having the connection string included within the App Settings for the Azure Function App in the portal:

Check your settings have been deployed and they match the settings on your function app implementation.

When publishing to Azure, ensure the remote connection string is specified in the Application Settings publisher by selecting the Insert value from local:

This will copy the local connection to the remote value.

After the settings are saved in the publisher dialog, they will be updated in Azure (no need to redeploy as VS applies a CLI command to update the remote settings).

That’s all for today’s post.

I hope this has been useful and informative.

Social media & sharing icons powered by UltimatelySocial