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

How to Test Azure Blob Trigger Functions

Welcome to today’s post.

Today I will show how to test an Azure Blob Trigger function.

In a previous post I showed how to create an Azure Blob Trigger Function.

An Azure trigger function runs continuously in an idle state, being triggered once a specific condition is met.

An Azure blob trigger function is triggered when a blob is uploaded into the function’s Azure storage.

An upload of a resource into the Azure storage can be completed using either a cloud-hosted .NET application or directly from the Azure portal.

The most typical usage for a blob trigger is to trigger an event when an image is uploaded into our site, then within the event handler we action a process such as the next stage of a workflow or execute a notification email to the end user.

Following the creation of an Azure blob trigger function and the associated functionality within the function, the next step for us is to be able to test the trigger function. Being able to test an upload that results in the execution of an Azure blob trigger is important as we would like to know the destination of the blob (file) within Azure storage. I will show how to locate the uploaded blob within an Azure blob container. In addition, I will show two ways in which you can inspect logs during the blob upload:

  1. Invocation details generated from Azure Blob Trigger Function App monitoring.
  2. Error, debug, and information log outputs from within our blob trigger function and written to logs viewable from the Azure App Services Kudu console.

Armed with these tools, you will be able to test blob uploads of Azure Blob Trigger functions.

Preconditions for Testing an Azure Blob Trigger

Before you can test an Azure Blob Trigger function, you will need to ensure the Azure Storage Account that is a dependency of your blob trigger is a valid connection endpoint.

In addition, you will need to ensure the Azure Function App from where the Azure Trigger Function created from is in a running state. The running status is verified by checking the green tick icon shows in the overview section of the Azure Function App as shown below:

Next, you will need to upload a file to the Azure Storage blob container location that is referenced from the bob trigger function.

To determine the location that we wish to upload the blob within Azure storage, you will need to view to trigger source function definition and locate the path attribute as shown:

Starting the Blob File Upload

We next upload our file using the blob upload dialog.

In the upload blob dialog select a file to upload:

After uploading, the next step is to review the logs for the blob upload.

Reviewing the Diagnostic Logs

To start diagnostics logging and monitoring return to the function app overview screen and select the Monitor option:

The status of the trigger is shown. If we have been successful uploading the file, you will see a green tick:

We drill down into this successful log entry by clicking on it.

The messages relevant to the blob trigger function execution are as shown:

An alternative way of verifying the result of an Azure Blob Trigger is to use the Kudu services console to check the logs.

Opening the latest log file will show similar messages that are to the portal invocation details:

The log will display any logs we have output from within our trigger function C# handler, which is useful for diagnostic and troubleshooting purposes.

That’s all for today’s post.

I hope you have found this post useful and informative.

Social media & sharing icons powered by UltimatelySocial