Search code examples
azureservicebusibm-datapower

DataPower - Azure Service Bus Integration


I am trying to post messages to Azure service bus from DataPower using http protocol. How should I pass the credentials since I am getting an unauthorized error 401.

Please help since I got stuck here

Thanks


Solution

  • I figured out the solution. Below is how I achieve SAS authentication token.

    1. Generate SAS token in IIB using a Java module which requires 4 parameters:

      a. Resource URI of Azure Service Bus
      b. Key
      c. Key Name
      d. Expiry in seconds.

    2. Set the SAS token in MQRFH2 header and send to DataPower

    3. Extract SAS token and set as Authorization header for HTTP POST request in DataPower using the below xslt.

    <xsl:variable name="entries" select="dp:request-header('MQRFH2')" />
    <xsl:variable name="header" select="dp:parse($entries)" />
    <xsl:variable name="SAS">
    <xsl:choose>
    <xsl:when test="$header//usr//SAS">
    <xsl:value-of select="$header//usr//SAS" />
    </xsl:when>
    <xsl:otherwise>
    <xsl:value-of select="false()" />
    </xsl:otherwise>
    </xsl:choose>
    </xsl:variable>
    <dp:set-http-request-header name="'Authorization'" value="$SAS"/>