Understanding Blob Storage - Part Ten - Implementing Storage Events

In this article we are going to design a logic app which will copy the blob to a folder in OneDrive whenever a new Blob is created.

Azure Storage events allow applications to react to the creation and deletion of blobs using modern serverless architectures. It does so without the need for complicated code or expensive and inefficient polling services. Instead, events are pushed through Azure Event Grid to subscribers such as Azure Functions, Azure Logic Apps, or even to your own custom HTTP listener, and you only pay for what you use.

Common Blob storage event scenarios include an image or video processing, search indexing, or any file-oriented workflow. Asynchronous file uploads are a great fit for events. When changes are infrequent, but your scenario requires immediate responsiveness, event-based architecture can be especially efficient.

Blob storage event subscriptions can include two types of events,

  • Microsoft.Storage.BlobCreated - Fired when a blob is created or replaced through the PutBlob, PutBlockList, or CopyBlob operations
  • Microsoft.Storage.BlobDeleted - Fired when a blob is deleted through a DeleteBlob operation

In this article, we are going to design a logic app which will copy the blob to a folder in OneDrive whenever a new blob is created.

Step 1

Log in to your Microsoft Azure portal, click on Create new resource and select Logic App from web category to create a Logic app and give the necessary details as follows and click on create.

  • Name: A Unique NameDeployment: Resource manager
  • Account kind: General purpose (Can’t work with Files, Tables or Queues in case of Blob Storage)
  • Location: Nearest to you
  • Log Analytics: Off
Azure 

Step 2

On successful creation, clicking on the resource will take you Logics App Designer. Scroll down and click on Blank Logic App template

Azure 

Step 3

In the search connectors field search for blob and select When a blob is added or modified trigger

Azure 

Step 4

Give a connection name and select the storage account of the blob from the list of storage account from your account and click on create.

Azure 

Step 5

Select the container to which it wanted to check for blob changes and also customize the frequency if needed

Azure

Step 6

As the next step choose an action and search for blob and select Get blob content using path action

Azure 

Step 7

In the blob path select path from the dynamic content.
Azure 

Step 8

Add an action as the new step and search for OneDrive and select OneDrive from the list and select Create File action

Azure 

Step 9

Sign in to your OneDrive account and allow the permission for access. Specify the folder to which the file to be added. Choose File Name and File Content from the dynamic content list.

Azure 

Step 10

Save and Run the App. Uploading a new content to your blob will trigger running of the app and the file will be copied to the Pictures folder of the OneDrive account specified.

Azure 
Azure
 
Azure