Skip to Content
Technical Articles

Connect to AzureBlob from CPI: Using Azure Storage jar


I came across a requirement to upload file to AzureBlob container from CPI. There are multiple ways to achieve this : using REST API or using standard jar provided by MS.

In this blog post I will discuss about uploading files to AzureBlob container using standard jar available in maven repository.

Steps to Configure:

I followed the below blog post and done some modification:

Step 1: I downloaded Azure Storage Client SDK from

Step 2: I uploaded this .jar file as resource to my iFlow:


Step 3: I added properties using groovy or content modifier. I used content modifier and externalized so that I can configure as per my need.


Step 4: I created a Groovy script to directly upload the file to the container

Script to upload files to Azure Blob folder using parameters provided
import java.util.HashMap
import java.text.SimpleDateFormat

def Message processData(Message message) {
    def body = message.getBody(java.lang.String) as String
    map = message.getProperties()
    String accountName=map.get("AzureAccountName")
    String accountKey = map.get("AzureAccountKey")
    String containerRef =map.get("ContainerRef")
	String fileNameScheme = map.get("Filename")
	String timestamp = map.get("AddTimestamp")
    String storageConnectionString = "DefaultEndpointsProtocol=https;" + "AccountName=" + accountName+ ";" + "AccountKey=" + accountKey

    CloudStorageAccount account = CloudStorageAccount.parse(storageConnectionString)
    CloudBlobClient serviceClient = account.createCloudBlobClient()

    CloudBlobContainer container = serviceClient.getContainerReference(containerRef)
    String pattern = "yyyyMMddHHmmss";
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
    String date = simpleDateFormat.format(new Date());
    fileNameScheme = fileNameScheme + "_" + date;
    String fileName = fileNameScheme+ ".csv"
    String fileContent = body
    byte[] fileBytes = fileContent.getBytes()

    CloudBlockBlob blob = container.getBlockBlobReference(fileName)
    blob.uploadFromByteArray(fileBytes, 0, fileBytes.length)

    message.setBody("File is created with name : "+fileName)

    return message;

When the CPI flow runs successfully, file is uploaded if the properties mentioned are correct. We don’t need any particular adapter for this iFlow as this script takes care of uploading the files.


Using this concept you can upload a file to AzureBlob from CPI without any adapter, using jar provided in Maven repository.

In the next blog post I will describe how we can use REST API to achieve the same.


You must be Logged on to comment or reply to a post.
  • Can we pull all azure blob contents in a container using single rest URI call in SAP PO or CPI. Let's say I have four blobs with names abc,abcd,abcdef,def. I need to pull blob contents of abc,abcd,abcdef  based on some file name pattern in single REST URI call. Is that possible