Skip to main content

Use this script before your REST connector

 

<!-- %3A etc must be uppercase! -->
<arc:set attr="encodedurl">https%3A%2F%2Fyour-sb-resource-name.servicebus.windows.net%2Fyour-topic</arc:set>

<arc:set attr="expiry">;now(unix)|add(604800)]</arc:set> <!-- add a week -->
<arc:set attr="scope">;encodedurl]\nnexpiry]</arc:set>

<!-- Encode using HMAC -->
<arc:set attr="encIn.data" value=""scope]" />
<!--<arc:throw code="x" desc=""encIn.data]" /> -->
<arc:set attr="encIn.format" value="HMAC" />
<arc:set attr="encIn.hmackey" value=""azureprimary.key]" />
<arc:set attr="encIn.hmacalgorithm" value="SHA" />
<arc:set attr="encIn.hmacbits" value="256" />
<arc:set attr="encIn.outformat" value="BASE64" />
<arc:call op="encEncode" in="encIn" out="result">
<!-- setting the output file data to be the encoded data returned from the operation -->
<arc:set attr="output.hashb64">;result.encodeddata]</arc:set>
</arc:call>
<!--<arc:throw code="hash" desc=""output.hashb64]" />-->

<-- sig must be urlencoded -->
<arc:set attr="encIn2.data" value=""output.hashb64]" />
<arc:set attr="encIn2.format" value="URL" />
<arc:call op="encEncode" in="encIn2" out="result2">
<!-- setting the output file data to be the encoded data returned from the operation -->
<arc:set attr="output.signatureUrlEncoded">;result2.encodeddata]</arc:set>
</arc:call>
<!--<arc:throw code="x" desc=""output.signatureUrlEncoded]" />-->

<!-- note again %3d must be converted uppercase -->
<arc:set attr="sigheader">SharedAccessSignature sr==encodedurl]&sig==output.signatureUrlEncoded|replace('%3d','%3D')]&se==expiry]&skn=sas-tracking-events-topic</arc:set>
<arc:set attr="outfile.FilePath" value=""FilePath]" />

<!-- debug -->
<arc:set attr="outfile.Header:expiry">;expiry]</arc:set>
<arc:set attr="outfile.Header:scope">;scope]</arc:set>
<arc:set attr="outfile.Header:signature">;output.hashb64]</arc:set>
<!-- debug end-->

<arc:set attr="outfile.Header:sigheader" value=""sigheader]" />
<arc:set attr="outfile.Header:brokerProperties">{"SessionId":""guid()]"}</arc:set>

<arc:push item="outfile" />

and use Headers…

 

Be the first to reply!

Reply