Skip to Content
Technical Articles
Author's profile photo Priyanka Chakraborti

Cloud Integration with Commerce Azure Blob Storage using Open Connectors

Introduction:

This blog post is to showcase the capability of Azure Blob Open Connector.

Scenario:

Transfer a ZIP file from FTP server to Commerce Azure Blob storage.

Prerequisite Setup:

Set up an Integration suite trial. Help Link: Setup.

Instance Creation in Open Connectors:

Connector%20Instance

Connector Instance

Design Solution in Cloud Integration:

Integration%20Flow

Integration Flow

Step 1:

Configure FTP sender channel to pick a zip file from the FTP server.

Step 2:

Use Content Modifier to set properties as shown below.

Content%20Modifier

Content Modifier

 

‘credentialAlias’ refers to the user credentials of type Open Connectors.

Security%20Material

Security Material

Step 3-4:

Construct multipart and set authorization header using Groovy Script.

import com.sap.gateway.ip.core.customdev.util.Message
import javax.activation.DataHandler
import javax.mail.internet.ContentType
import javax.mail.internet.MimeBodyPart
import javax.mail.internet.MimeMultipart
import javax.mail.util.ByteArrayDataSource
import com.sap.it.api.ITApiFactory
import com.sap.it.api.securestore.SecureStoreService
import com.sap.it.api.securestore.UserCredential
import com.sap.it.api.securestore.exception.SecureStoreException
def Message constructMultipart(Message message) {
    byte[] bytes = message.getBody(byte[])
    MimeBodyPart bodyPart = new MimeBodyPart()
    ByteArrayDataSource dataSource = new ByteArrayDataSource(bytes, 'application/zip')
    DataHandler byteDataHandler = new DataHandler(dataSource)
    bodyPart.setDataHandler(byteDataHandler)
    String fileName = message.getHeaders().get("CamelFileName")
    bodyPart.setFileName(fileName)
    String fileType = message.getProperties().get("fileType")
    bodyPart.setDisposition('form-data; name="file"')
    bodyPart.setHeader("Content-Type",fileType)
    MimeMultipart multipart = new MimeMultipart()
    multipart.addBodyPart(bodyPart)
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream()
    multipart.writeTo(outputStream)
    message.setBody(outputStream)
    String boundary = (new ContentType(multipart.contentType)).getParameter('boundary')
    message.setHeader('Content-Type', "multipart/form-data; boundary=${boundary}")
    return message
}

def Message setAuthHeader(Message message) {
    def credentialAlias = message.getProperty("credentialAlias")
    def secureStorageService =  ITApiFactory.getService(SecureStoreService.class, null)
    def credential = secureStorageService.getUserCredential(credentialAlias)
    def pwd = credential.getPassword()
    message.setHeader("Authorization",pwd)
    return message
}

 

I have re-used the code for multipart creation from here (solution provided by Eng Swee Yeoh).

Step 5:

Configure HTTP receiver channel as shown below.

HTTP%20Receiver%20Adapter

HTTP Receiver Adapter

TakeAway Points:

  1. Instead of Open Connectors receiver adapter, HTTP receiver adapter is used because of the some unsupported features mentioned in the SAP Note
  2. Open connector instance expects the file in form-data format.
  3. Container name and path should be passed as query parameters while posting data to open connector.

 

Thank you for reading this blog post. Please feel free to share your feedback or thoughts or ask questions in the Q&A tag below.

QA link

Regards,

Priyanka Chakraborti

Assigned Tags

      2 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Rajesh PS
      Rajesh PS

      Priyanka Chakraborti

       

      1. Is there any subscription / cost involved when creating instance for Azure blob ? cost involved per user?

       

      2. Now open connectors adapter supports below or still to use https adapter  ?

      1. Multiple query parameters
      2. Dynamic query parameters
      3. Special Characters in Payload
      4. Content-Type Header propagations in request

      3. how secured to expose Integration suite paas to external apps via Azure blob for inbound case?

      Author's profile photo Rajesh PS
      Rajesh PS

      Priyanka Chakraborti

      Open connector instance accepts only multi form data by default when integrating BTP Integration Suite with Azure Blob ? Do we have any alternatives ? .

       

      when Container name and path should be passed as query parameters while posting data to open connector instance then there will be HTTP usage since multiple query isn't supported by open connector adapter ?