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: 
former_member595526
Active Participant
Many of you aware that there is no standard adapter like SFTP, SOAP available to connect Azure Cloud with SCPI. So I am writing this post to share how we can get connected with Azure Cloud using SCPI

In this post you will learn how to get connected with Azure Cloud and uploading file to Azure

Azure provides SDK in Java to get connected. As SCPI supports groovy, we can write a simple groovy script to upload any file to azure blob container

For example, I have created a simple flow which uploads csv file to azure folder "trial"



And the script to upload the file is below
import com.sap.gateway.ip.core.customdev.util.Message
import java.io.*
import com.microsoft.azure.storage.*
import com.microsoft.azure.storage.blob.*

def Message processData(Message message) {
def body = message.getBody(java.lang.String) as String

String accountName = "your_azure_account_name"
String accountKey = "your_azure_account_key"
String storageConnectionString = "DefaultEndpointsProtocol=http;" + "AccountName=" + accountName+ ";" + "AccountKey=" + accountKey

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

CloudBlobContainer container = serviceClient.getContainerReference("azurefoldername/containername")

String fileName = "filename.csv"
String fileContent = body
byte[] fileBytes = fileContent.getBytes()

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

blob.getProperties().setContentType("text/csv;charset=utf-8")
blob.uploadProperties()

message.setBody("OK")

return message;
}


 

you have to replace the accountname, account key and container's name with your azure's credentials.

File name can be either static or dynamically populated.

In my groovy script, I have replaced all the credentials and file name as test.csv and azure container name as trial( which is already available in my azure cloud)

Now we have all set to upload a file to Azure cloud. Let's test it via Postman tool



It is Status 200, which indicates success of uploading the file to Azure. Now let's check the file in Azure using Azure Storage Explorer



 

Good Luck !

 

Questions/Comment and Suggestions are welcome ?
33 Comments
Labels in this area