Integrating an Azure Storage blob with MuleSoft

  • June 10, 2022

Microsoft Azure is a public cloud computing platform that offers infrastructure as a aervice (IaaS), platform as a service (PaaS) and software as a service (SaaS) solutions for use with analytics, virtual computing, storage, networking and other services.

A binary large object — or blob — stores unstructured data as text, binary and audio formats, among others.

Azure Storage is used for data storage on cloud for the following use cases:

  • Writing log files on the Azure Storage
  • Storing data for backup and restore, disaster recovery and archiving
  • Storing data for analysis by an on-premises or Azure-hosted service
  • Saving images or documents directly to a browser

In this article, we’ll create a resource group, storage account and container to upload a blob (a .json file, here) and perform the following operations on it using MuleSoft:

  • List blobs in container
  • Download blob
  • Delete blob
  • Upload blob

Prerequisites:

  • Microsoft Azure account (Enterprise or Student version)
  • Microsoft Azure Storage Connector
  • Anypoint Studio

Steps

  1. Create a resource group — a resource group is a logical container that associates multiple resources so they can be managed as a single entity in terms of both lifecycle and security. a.Go to Home -> Resource Groups -> Create b.Name the Resource Group and select the region c.Click Review and Create
  2. Create a storage account — an Azure Storage account holds all your Azure Storage data objects, such as blobs, file shares, queues, tables and discs. Data in your storage account is highly available, secure and enormously scalable. a.Go to Home -> Storage Accounts -> Create b.In the Project Details, provide the Resource Group (created in the previous step) for the storage account c.In the Instance Details, provide the Storage Account Name, Region, Performance (Standard or Premium) and Data Storage Redundancy (this example uses georedundant storage) d.Click Review and Create

    To learn more about the suitable data storage redundancy methods, click here.

  3. Create a container within a storage account
    1. Go to Storage Accounts -> (your_storage_account) -> Containers -> Create
    2. Provide the Name and select Public Access Level as Blob
    3. Click Create
  4. MuleSoft configurations
    1. From Exchange, download the Azure Storage Connector

    NOTE: To find the storage account name and connection string, go to Storage Account -> Access Keys -> Connection String

  5. MuleSoft application
    1. Create a scheduler-based application
      • It gets the list of all the blobs from a container using List Blobs in the container connector
      • If a blob exists, it downloads and deletes it using the Download blob and Delete blob connectors respectively
      • It creates a new blob within the specified container using the Upload blob connector

    NOTE: In Set Payload, a .json structured data is uploaded as a blob.

    — By Rahul Dusaje