Azure Blob Storage Adapter

Azure Blob Storage Adapter

The Azure Blob Storage Adapter is a simple component which can be used to interact with Azure’s Blob Storage. The adapter provides functionality to read, upload, list and delete blobs in the blob storage container.

This component authenticates to Azure Blob Storage by using Microsoft Entra ID to request an OAuth access token. This component uses the AZBLOB Library.

Requirements

  • An existing Azure storage account and associated Azure Blob Container.

  • Entra ID with permissions to perform operations on the Azure Blob Storage. The authentication piece of the adapter requires the following:

    • Tenant ID

    • Client ID

    • Client Secret

The configured app registration must have the appropriate Azure Blob Storage RBAC role, such as Storage Blob Data Reader or Storage Blob Data Contributor.

Running the Component

Using +COMPONENT, import the Azure Blob Storage Adapter component.

Bolded fields are required, otherwise default values defined in config.json are used:

Field

Description

Default Value

Field

Description

Default Value

Tenant ID

The Microsoft Entra tenant ID used to authenticate the adapter.

 

Client ID

The client ID of the Microsoft Entra app registration used to request an access token.

 

Client Secret

The client secret associated with the Microsoft Entra app registration.

 

Storage Account

The name of the Azure Storage account that hosts the target blob container.

 

Container

The name of the Azure Blob Storage container the adapter will access.

 

If using the default sample data (no upstream component), the log results should resemble the above.

Adapting the Component

  1. Simply add the component.setTimer function just below main and;

  2. Replace the section about the INIT keyword, (Data == “INIT”) with a relevant code, like a logging function and;

  3. Add useful polling code like a search, below is a comprehensive example:

Configs = component.fields() require "AZBLOB.AZBLOBclient" function main(Data) component.setTimer{delay=10000, data="Hello World!"} -- 10 seconds if Data == "INIT" then -- If no upstream component detected iguana.log("Using" .. "\nStorage Account: " .. Configs["Storage Account"] .. "\nContainer: " .. Configs["Container"]) end -- 1) Create an Azure Blob Storage client instance local AZBLOB = AZBLOBclient{ tenant_id = Configs["Tenant ID"], client_id = Configs["Client ID"], client_secret = Configs["Client Secret"], storage_account = Configs["Storage Account"], container = Configs["Container"] } -- 2) Search for available blobs local SearchParameters = {} -- SearchParameters["prefix"] = "Iguana" -- Optional search for prefix local Res = AZBLOB:search{ parameters = SearchParameters, live = true } iguana.log("Search results:\n" .. Res) -- 3) Parse blob results and iterate over them Res = xml.parse{data=Res} for i = 1, Res.EnumerationResults.Blobs:childCount("Blob") do -- Iterate over all blobs trace(Res.EnumerationResults.Blobs:child("Blob", i).Name:nodeText()) -- if blob A then do task A else do task B end... -- etc... end end

The component by default will perform the following operations, in order:

  1. Upload a file to the Azure Blob Storage.

  2. Performs a search.

  3. Retrieve the same file’s data.

  4. Deletes the same file and its snapshots.

Simply use only the functions that are required to your workflow and customize them to your needs. If any assistance is required, feel free to reach out to our support team.