Introduction
Azure Storage connector allows user to make use of Azure Storage services using Microsoft Azure Storage SDK for Java.
Microsoft’s Azure Storage is the cloud storage solution for modern applications that rely on durability, availability and scalability to meet the needs of their customers.
Read through this user guide to understand how to set up and configure a basic flow using the connector. Track feature additions, compatibility, limitations and API version updates with each release of the connector using the Connector Release Notes. Review the connector operations and functionality using the Technical Reference alongside the demo application.
MuleSoft maintains this connector under the Enterprise IT support policy.
Prerequisites
This document assumes that you are familiar with Mule, Anypoint Connectors, and Anypoint Studio Essentials. To increase your familiarity with Studio, consider completing a Anypoint Studio Tutorial. This page requires some basic knowledge of Mule Concepts, Elements in a Mule Flow, and Global Elements.
Software Requirements
-
Anypoint Studio 7.1.x with Mule Runtime 4.1.x
-
Azure Storage Connector v2.1.0
Compatibility
Azure Storage connector supports Mule 4.1.x version.
Installing the Connector
You can install the connector in Anypoint Studio using the instructions in Installing a Connector from Anypoint Exchange.
Installation guide is also available here
Upgrading from an Older Version
This is the next version of Azure Storage Connector for Mule 4, upgraded from the earlier released version v2.1.0 and is compatible with Studio 7, Mule 4.x. and Java 17
Configuring the Connector Global Element
To use the Anypoint Azure Storage connector in your Mule application, you must configure a global element that can be used by the Anypoint Azure Storage connector (read more about Global Elements). The Azure Storage connector offers the following global configuration(s), requiring the following credentials: Storage Account Name and Account Key or SAS Token.
Field | Description |
---|---|
Access Key |
Enter the Access Key to log into Azure Storage account. |
Storage account name |
Enter the Storage Account Name. |
Shared Access Signature |
Login to the Azure Storage account to geerate the SAS token. |
Connector Configuration Strategies
There are two different strategies to connect to Azure Storage Account. First one is using Access Key and the other one is using Shared Access Signature. User needs to login to Storage account to get any one of these two for making connection.
Using the Connector
The below list of operations can be performed by using Azure Storage Connector.
Operation |
Description |
Inbound |
Outbound |
Download Blob |
Downloads the Blob from the container. |
container, File Name |
Inputstream of Blob. |
List All Containers |
Gets list of all containers. |
No input required. |
List of all Blob containers. |
Create Container |
Creates a Blob container. |
Container Name |
True for successful creation, False for failure. |
List Blobs In Container |
Gets the list of Blobs in a container |
Container Name |
List of Blob items. |
Upload Blob |
Uploads the Blob into the storage. |
Container, File Name, File inputstream |
True for successful upload, False for failure. |
Upload Blob From Path |
Uploads the Blob into the storage from a file path. |
Container, File Name, File path |
True for successful upload, False for failure. |
Delete Blob |
Deletes the Blob in the storage account |
Container, File Name |
True for successful deletion, False for failure. |
Delete Container |
Deletes container from the storage account. |
Container Name |
True for successful deletion, False for failure. |
Create Queue |
Creates Queue in the storage account |
Queue Name |
True for successful creation, False for failure. |
Add Message To Queue |
Uploads message to the Queue. |
Queue Name, Message |
True for successful upload, False for failure. |
Peek Message From Queue |
Peek at the message in the front of a queue without removing it from the queue. |
Queue Name |
Message. |
Update Message |
Updates the contents of a queued message |
Queue Name, Old message, New message |
True for successful update, False for failure. |
Get Queue Length |
Gets the length of the Queue. |
Queue Name |
Length of Queue. |
Dequeue Message |
Retrieves single message from the Queue. |
Queue Name |
Message |
Dequeue Messages |
Gets list of messages from the Queue |
Queue Name, Number Of Messages |
List of Messages. |
Get List Of Queues |
Gets list of Queues in the storage account |
No input required |
List of Queues. |
Delete Queue |
Deletes the Queue |
Queue Name |
True for successful deletion, False for failure. |
Create Table |
Creates a Table in the storage account |
Table Name |
True for successful creation, False for failure. |
List Table |
Gets list of Tables in the storage account |
No input required |
List of Tables. |
Add Entity |
Adds entity to the table |
Table Name, Partition Key,Row Key, properties |
Table Result. |
Get Single Entity |
Retrieves single entity of the table |
Table Name, Partition key, Row key |
Table Entity |
Update Entity |
Updates entity in the given table |
Table Name,Partition Key,RowKey, properties |
Table Result |
Delete Entity |
Deletes the entity from the table |
Table Name, Partition Key, Row Key |
True for successful deletion, False for failure. |
Delete Table |
Deletes the table from the storage account |
Table Name |
True for successful deletion, False for failure. |
Create Share |
Creates Share in the storage account |
Share Name |
True for successful creation, False for failure. |
Get Share |
Gets Share details |
Share Name |
File Share |
Upload File In Directory |
Uploads file in directory |
File Path, Share Name, Directory Name |
True for successful updload, False for failure. |
Upload File In Root Directory |
Uploads file in root directory |
File Path, Share Name |
True for successful upload, False for failure. |
Upload File In Directory With Stream |
ploads a file input stream to the specified directory of a share |
File Stream, File Name, Share Name, Directory Name |
True for successful upload, False for failure. |
Upload File In Root Directory With Stream |
Uploads a file input stream to the specified directory of a share |
File Stream, File Name, Share Name |
True for successful upload, False for failure. |
Create Directory |
Create directory in the Share |
Directory Name, Share Name |
True for successful creation, False for failure. |
Lst Files and Dir in Share |
Gets the list of Files and Directories |
Share Name |
List of File items |
List Files and Dir In Directory |
Gets the list of Files and Directories |
Share Name, Directory Name |
List of File items |
Download File |
Downloads the file from the directory |
File Name, Directory Name, Share Name |
File inputstream |
Download File From Root Dir |
Downloads the file from root directory |
File Name, Share Name |
File text |
Delete File |
Deletes file from the directory |
File Name, Directory Name, Share Name |
True for successful deletion, False for failure |
Delete Directory |
Deletes the directory from the Share |
Directory Name, Share Name |
True for successful deletion, False for failure |
Delete Share |
Deletes the Share from the storage account |
Share Name |
True for successful deletion, False for failure |
Insert or Replace Entity |
Insert or Merge to the storage account |
Table Entity |
True for successful replace, False for failure |
Insert or Merge Entity |
Insert or Merge to the storage account |
Table Entity |
True for successful merge, False for failure |
Batch Insert or Replace Entities |
Batch Insert or Replace to the storage account |
List of table entities |
True for successful replace, False for failure |
Batch Insert or Merge Entities |
Batch Insert or Merge to the storage account |
List of table entities |
True for successful Merge, False for failure |
Is Blob Exists |
Check the Blob existence from the storage account |
Blob Name and Container |
True for existing or False |
Download Blob Using RegEx |
Downloads the Blob from the storage account |
Part of Blob Name |
File Stream |
Get All Entities |
Gets all the Entities from the storage account |
Entity Definition |
List of Table entities |
Connector Namespace and Schema
When designing your application in Studio, the act of dragging the connector from the palette onto the Anypoint Studio canvas should automatically populate the XML code with the connector namespace and schema location.
Namespace: http://www.mulesoft.org/schema/mule/azure-storage-service
Schema Location: http://www.mulesoft.org/schema/mule/azure-storage-service/current/mule-azure-storage-service.xsd
Tip
|
If you are manually coding the Mule application in Studio’s XML editor or other
text editor, define the namespace and schema location in the header
of your Configuration XML, inside
the <mule> tag.
|
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/file http://www.mulesoft.org/schema/mule/file/current/mule-file.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/azure-storage-service http://www.mulesoft.org/schema/mule/azure-storage-service/current/mule-azure-storage-service.xsd
<!-- put your global configuration elements and flows here -->
</mule>
Using the Connector in a Mavenized Mule App
If you are coding a Mavenized Mule application, this XML snippet must
be included in your pom.xml
file.
<dependency>
<groupId>org.mule.modules</groupId>
<artifactId>azure-storage-connector</artifactId>
<version>3.0.0</version>
<classifier>mule-plugin</classifier>
</dependency>
Demo Mule Applications Using Connector
You can download fully functional demo applications using the Azure Storage connector from this link
Example Use Case
The current use case describes how to create a Mule application to upload Blob into Azure Storage account.
-
Create a new Mule Project in Anypoint Studio.
-
Set Azure Storage account credentials in src/main/mule/mule-app.properties.
-
Copy the api.raml file in src/main/resources/api folder, which is available in the azure-storage-demo application.
-
Generate Flows from REST Api.
-
Drag and drop the Azure storage connector from Mule palette.
-
Click Test Connection to confirm that Mule can connect with the instance. If the connection is successful, click OK to save the configuration. Otherwise, review or correct any invalid parameters and test again.
-
Paste the below XML in the generated Mule Flow.
-
Deploy the application and check "DEPLOYED" on the console.
-
Browse the URL: http://localhost:8081/console
-
Click the Upload button and enter the input values.
-
Submit the values and verify the results.
Example Use Case - XML
Paste this into Anypoint Studio to interact with the example use case application discussed in this guide.
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:ee="http://www.mulesoft.org/schema/mule/ee/core"
xmlns:azure-storage="http://www.mulesoft.org/schema/mule/azure-storage"
xmlns:http="http://www.mulesoft.org/schema/mule/http"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-current.xsd http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/http http://www.mulesoft.org/schema/mule/http/current/mule-http.xsd
http://www.mulesoft.org/schema/mule/azure-storage http://www.mulesoft.org/schema/mule/azure-storage/current/mule-azure-storage.xsd
http://www.mulesoft.org/schema/mule/ee/core http://www.mulesoft.org/schema/mule/ee/core/current/mule-ee.xsd">
<configuration-properties file="mule-app.properties" doc:name="Configuration properties"/>
<azure-storage:config name="access-key-azure-connection-key" doc:name="Azure Storage Config" doc:id="9cf50bdb-2bf7-4739-a06e-aff22e2b7c09" >
<azure-storage:access-key-config-connection accountName="${account.name}" accountKey="${account.key}" />
</azure-storage:config>
<http:listener-config name="HTTP_Listener_config" doc:name="HTTP Listener config" doc:id="e54d52e2-de53-4ec8-915a-f5386274170a" >
<http:listener-connection host="0.0.0.0" port="${http.port}" />
</http:listener-config>
<azure-storage:config name="Azure_Storage_Config_Sas" doc:name="Azure Storage Config" doc:id="6c7e2b65-8001-4726-8ba8-8a903729faf2" >
<azure-storage:sas-token-config-connection accountName="${account.name}" sasToken="${sas.token}" />
</azure-storage:config>
<flow name="UploadBlobFromPathFlow" doc:id="ec672dfb-1046-4542-957a-6a87e5112d34" >
<http:listener doc:name="Listener" doc:id="c3e65d01-e453-4691-a7f3-1a89246c59a6" config-ref="HTTP_Listener_config" path="/blob-test" allowedMethods="POST"/>
<azure-storage:create-container doc:name="Create container" doc:id="83b0dc5c-7125-47de-9362-643e357e04fd" config-ref="Azure_Storage_Config_Access-key" containerName="wwazuredemo"/>
<azure-storage:delete-container config-ref="Azure_Storage_Config_Access-key" containerName="wwazuredemo"/>
<ee:transform doc:name="Transform Message" doc:id="1b83fc06-b95a-4ccb-910e-2e261619fde5" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" doc:name="Logger" doc:id="66f61425-05d6-46ea-85c1-4c925ac3e995" message="#[payload]"/>
</flow>
<flow name="ListAllContainersFlow" doc:id="b10028e8-3bdc-4774-bccc-c79ede654f4b" >
<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/list-all"/>
<azure-storage:list-all-containers doc:name="List all containers" doc:id="28d527a7-4334-4d7d-ab22-e60b2c23dc22" config-ref="Azure_Storage_Config_Access-key"/>
<ee:transform doc:name="Transform Message" doc:id="afc08479-c7a1-4b43-95bc-4bc0c2212017" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
containers: {
name: payload.name
}
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" doc:name="Logger" doc:id="66f61425-05d6-46ea-85c1-4c925ac3e995" message="#[payload]"/>
</flow>
<flow name="UploadBlobFlow" doc:id="67ddf897-9d50-4a66-b378-8d318c62e994" >
<http:listener doc:name="Listener" config-ref="HTTP_Listener_config" path="/azure-test"/>
<set-payload value="First Test for Azure" doc:name="Set Payload" doc:id="7dc2743a-4a0d-4d9f-95ef-ba781c9397dc" />
<azure-storage:upload-blob doc:name="Upload blob" doc:id="5b39b0ae-2930-47f8-8d6a-b1909726891c" config-ref="Azure_Storage_Config_Access-key">
<azure-storage:storblob container="wwazurestorage" fileName="test2" fileStream="#[payload]" />
</azure-storage:upload-blob>
<ee:transform doc:name="Transform Message" doc:id="0689dab4-f2c4-4c49-9bee-0119248002a1" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" doc:name="Logger" doc:id="d3de7914-4bd1-4f82-8c13-1150def8eb5f" message="#[payload]"/>
</flow>
<flow name="DeleteBlobFlow" doc:id="373b6d34-f113-471a-a34b-362f43fec90f" >
<http:listener doc:name="Listener" doc:id="c957e872-e6ee-42bd-8624-31806bf4c99f" config-ref="HTTP_Listener_config" path="/deleteblob"/>
<azure-storage:delete-blob doc:name="Delete blob" doc:id="1ba60db0-7fcc-44f1-a05a-ca4775982523" config-ref="Azure_Storage_Config_Access-key">
<azure-storage:blob container="wwazurestorage" fileName="test2" />
</azure-storage:delete-blob>
<ee:transform doc:name="Transform Message" doc:id="09b4b44e-382d-45c8-98e7-11e6808ed16b" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
status: payload
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" doc:name="Logger" doc:id="4066bc49-6e19-4dd1-a70d-97cace8aa5df" message="#['Blob deleted']"/>
</flow>
<flow name="downloadBlobFlow" doc:id="9cf33c8c-17c6-45bc-9095-8daa6f8144ff" >
<http:listener doc:name="Listener" doc:id="e3b817f5-ef3a-4ee4-8004-d7fd8a97bf77" config-ref="HTTP_Listener_config" path="/download-blob"/>
<azure-storage:download-blob doc:name="Download blob" doc:id="109fd93b-718e-46c8-be60-ea04571afbcd" config-ref="Azure_Storage_Config_Access-key">
<azure-storage:blob container="wwazurestorage" fileName="test2" />
</azure-storage:download-blob>
<logger level="INFO" doc:name="Logger" doc:id="373d53ba-80c2-41d8-9a6b-b2642c216cb5" message="#[payload]"/>
</flow>
<flow name="isBlobExistsFlow" doc:id="6e3fa1cd-4273-4d5d-a1ea-c44d051cb915" >
<http:listener doc:name="Listener" doc:id="e12435f8-0447-41b7-8e2a-87cf73c05385" config-ref="HTTP_Listener_config" path="/isblobexists"/>
<azure-storage:is-blob-exists doc:name="Is blob exists" doc:id="831413a6-c056-46a1-aaa4-5deb4b4969e2" config-ref="Azure_Storage_Config_Access-key" containerName="wwazurestorage" blobName="#['test']"/>
<ee:transform doc:name="Transform Message" doc:id="e8071616-50ba-4827-8efd-26a1ee2c0374" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/json
---
{
status: payload
}]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" doc:name="Logger" doc:id="39f6029b-7a07-4339-b50d-fa9b28f26c8f" message="#[payload]"/>
</flow>
</mule>
Resources
-
Access the Azure Storage Connector Release Notes.
-
Access the Azure Storage API reference