Wednesday, 11 May 2022

Azure Blob storage trigger for Azure Functions - Messag from Azure Blob Storage to Azure-Service-Bus using azure blob trigger funtion

Azure Function

Azure Functions is a serverless computing service and is hosted on the Microsoft Azure public cloud. It is designed to accelerate and simplify application development. 

Azure Functions are the individual functions created in a Function App. Every Function can be invoked using the configured trigger.


 Blob Storage working scenario.

The Blob storage trigger starts a function when a new or updated blob is detected. The blob contents are provided as input to the function.

When Azure Function runs, it needs to know how to connect to the blob container. In local.settings.json from the Storage Account copy the connection string from Access keys and add the connection string in local.settings.json 

 Blob Trigger function having parameter myBlob which gives the details of the uploaded blob,

These details will send to Service Bus Queue for further process.

  


Azure Function Will be Triggered once the file is uploaded to Azure Storage Account





Prerequisites

  • Microsoft Azure Account.
  • Visual Studio with the Azure Development workload enabled. you can also create Azure Function directly in the portal, but the visual studio is preferred when you want easy source control integration.


Code Snippet for Azure Blob Trigger Function

Function Name: Triggerwhenfileuploads
Return Type: JSON
Blob Container Name: Your-container-Name
Service bus Queue Name: Your-Queue-Name
 

BlobTrigger

name - holds the name of the file found in the blob container.

myBlob - holds the content of the file.

containerName - actual container name created in blob storage.

connection - blob storage connection string.

Service Bus

Service-Bus-demo: Service bus Queue Name

Connection - Service bus connection string.







Class File For Message     






OutPut






The connection string from the storage account to local.setting.json

This config file will not be going to deploy to Azure, so will need to specify the information in the portal as well.








 

No comments:

Post a Comment