Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
dharamverma
Explorer
10,875



Introduction: This document describes how to access Azure blob storage via APIs from CPI/ PO/PI, including steps required at Azure side to give access to an external system like CPI.

 

Let’s set up Azure blob storage first.

Make sure that you have proper resource group assigned to your user id and storage account created under that resource group on Azure Portal.

  • Go inside the resource group then storage account on Azure portal

  • At left side, click on containers.

  • Click on +Container to create container to store blob.


 

  • Give any name in small case and click on create.



  • Click on created container.


 

  • Container has no file in it.

  • Click on access policy and the add policy to add stored access policy.

  • Give any name of identifier, select permissions and start/end date then click ok and save it.





  • Now click on Shared Access Token, select stored access policy created earlier from drop down list and click on generate SAS token and URL at bottom.




 

Copy SAS url
https://<storageAccount>.blob.core.windows.net/cpiblob?st=2023-11-16T04:31:42Z&se=2023-11-16T12:31:4...

 

Copy SAS Token to use in CPI Azure Storage Adapter

 
st=2023-11-16T04:31:42Z&se=2023-11-16T12:31:42Z&si=PolicyforCPIblob&sv=2022-11-02&sr=c&sig=2mfvSkWmlqL4dxgfsdnsdlAB9%2FtS0gCwBUtEaRmaL9YP8AA%3D

 

If you want to access blob storage using http adapter of SAP PO/PI/ CPI or any testing tool, then here you go

 

Now we have URL to access that container.

Let’s divide the URL into 3 parts
Part1- https://<storageAccount>.blob.core.windows.net/<ContainerName>;?st=2023-11-16T04:31:42Z&se=2023-11-16T12:31:42Z&si=PolicyforCPIblob&sv=2022-11-02&sr=c&sig=2mfvSkWmlqL4dxgfsdnsdlAB9%2FtS0gCwBUtEaRmaL9YP8AA%3D


Part2,Part 3, Query Parameters and Headers- as per below table




























































Activity Azure Blob Permission (in access policy) http Operation Header Part2 Part 3 (Query Parameters)
Read the file names from storage List Get x-ms-blob-type=blockblob ?restype=container&comp=list&<SAS Key>
Read file from storage Read Get x-ms-blob-type=blockblob /<FilePath or FileName> <SAS Key>
Create File Create Put x-ms-blob-type=blockblob /<FilePath or FileName> <SAS Key>
Append File Add Put x-ms-blob-type=appendblob /<FilePath or FileName> ?comp=appendblock&<SAS Key>
Delete File Delete Delete x-ms-blob-type=blockblob /<FilePath or FileName> <SAS Key>
Overwrite file Write Put x-ms-blob-type=blockblob /<FilePath or FileName> <SAS Key>

***Append file option is not available with older version of blob

 

let's take an example, if we need to create a file with name test.txt in the blob using http api,

Then...

Part1-  https: //<storageAccount>.blob.core.windows.net/<ContainerName>

Here we are using container cpiblob

 

Part2- /<FilePath or FileName?

Here we are using filename test.txt

 

Part3- It is nothing but the SAS Key of the container and some other query parameters

So, complete URL is
https: //<storageAccount>.blob.core.windows.net/cpiblob/test.txt? st=2023-11-16T04:31:42Z&se=2023-11-16T12:31:42Z&si=PolicyforCPIblob&sv=2022-11-02&sr=c&sig=2mfvSkWmlqL4dxgfsdnsdlAB9%2FtS0gCwBUtEaRmaL9YP8AA%3D

 

Above URL can be used in any receiver http or rest adapter to create a file in blob storage.

 

Let’s create an iflow in CPI to write a file into blob using Azure Storage Adapter.

 

Create an iFlow where message will come over http protocol with header “FileName”, iflow will read payload and name of the file from FileName header and write the file in blob storage with the same name and data.

 

  • Create a security material with secure parameter option.


 

  • Give any proper name and paste SAS token (Copied earlier from Azure Portal) in secure parameter and deploy it.


 

  • Let’s create a simple iflow without any condition or exception handing because this iflow is getting created just for a POC purpose.

  • Content Modifier to create BlobPath property from incoming Header FileName

  • Content Modifier to delete Header FileName


 

  • Create connection to receiver with Azure Adapter and Blob Type message protocol.


 

  • Put Security Material name as Token Alias.


 

  • Set operation as Upload Block Blob, Put your Storage Acccount Name, Container Name and put property BlobPath in BlobPath.





  • Deploy it


 

  • Let’s test it from Postman



  1.         Write something in body

  2.         Set FileName Header with Test.txt value

  3. Click on send and you can see file created in blob storage


 


 

Conclusion: This document explains setting at Azure side for blob access via API and how to use Azure storage adapter in CPI.

 

 
6 Comments
Labels in this area