This document outlines the process of creating an Azure Function with a Blob trigger. This setup allows the Function to process files uploaded to a specific container within a Storage Account.
The following diagram illustrates the architecture of the solution:
Figure 1: Solution Architecture
Before you begin, ensure you have the following:
- An active Azure subscription.
- Access to the Azure Portal.
- A Storage Account created in Azure.
Follow these steps to set up your Azure Function with a Blob trigger:
First, create a new Function App resource in the Azure portal.
During the Function App creation or afterwards, remember to enable Application Insights for monitoring and logging.
Once the Function App is created, navigate to it and add a new function. Select the Blob Trigger template.
Figure 2: Create Blob Trigger Function Page
When configuring the Blob Trigger:
- Container Name: Correctly set the name of the container in your Storage Account that the trigger will monitor.
- Path (File Name Pattern): Set the path to
{file}. This configuration ensures that any file uploaded to the specified container will trigger the function. - Storage Account Connection: Create a new Storage Account connection or select an existing one, pointing to the Storage Account containing your target blob container.
Important:
- Ensure the container name is accurately specified.
- Using
{file}as the file name pattern allows the function to be triggered by any uploaded file in the container.- Verify that the Storage Account connection string is correctly configured and has the necessary permissions.
Upload a file to the container you specified in the Blob Trigger configuration. This action should trigger the function.
You can monitor the function's execution and check for logs:
- Navigate to your function in the Azure Portal.
- Go to the
Code + Testsection. - In the console, switch the log view to
Filesystem Logsto see the detailed execution logs.
Figure 3: Filesystem Logs View
Log Output Example: The logs will show entries indicating that the function was triggered by the blob upload and processed it.
As demonstrated, uploading a blob to the configured container successfully triggers the Azure Function, which then processes the blob. The execution logs can be easily accessed and reviewed through the Azure Portal.