# How to Authenticate with Azure Service Bus - SOLVED

**URL:** <https://community.cdata.com/t/how-to-authenticate-with-azure-service-bus-solved/629>\
**Category:** CData Arc\
**Tags:** discussion, hmac, authentication, azure-service-bus\
**Created:** [February 14, 2024, 12:43pm UTC](https://community.cdata.com/t/how-to-authenticate-with-azure-service-bus-solved/629 "2024-02-14T12:43:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![russell-jerseypost](https://avatars.discourse-cdn.com/v4/letter/r/439d5e/32.png) [@russell-jerseypost](https://community.cdata.com/u/russell-jerseypost)\
**Post date:** [February 14, 2024, 12:43pm UTC](https://community.cdata.com/t/how-to-authenticate-with-azure-service-bus-solved/629/1 "2024-02-14T12:43:10Z")

</div>

Use this script before your REST connector

```xml
<!-- %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]\n[expiry]</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…

 ![a0fb35b2-1dfb-47f6-92a5-d51cccdb0516.png](https://us1.discourse-cdn.com/cdata/original/2X/4/4c69c5fa664c06355b687b17bb9721194e725f75.png)
