web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested Answer

Error creating a Azure SAS-token in AL

(0) ShareShare
ReportReport
Posted on by 35

I trying to create a function in AL that will create a SAS auth to be able to send a message to Azure. 

Below is an example of a call that returns a complete SAS-token that I can use for a http-request. 

pastedimage1678441026446v3.png

This is the function that creates the token. 

pastedimage1678438231022v2.png

But when I try to use the SAS-key I get an error saying that the the token is incorrect, not invalid, just simply wrong. 

pastedimage1678437624118v1.png

On a visual inspection of the key it seems very similar to a real token created.
Obviously there is something wrong in my function but I cannot find out why. 

Help!

I have the same question (0)
  • Suggested answer
    Nitin Verma Profile Picture
    21,698 Moderator on at

    Hi,

    You can visit the below link, see if it help you.

    github.com/.../service-bus-shared-access-signature-authentication.md

  • Jan Hoglund Profile Picture
    35 on at

    Thank you Sir for a quick response.

    The link shows similar documentation that MS has in it's documentation

    learn.microsoft.com/.../service-bus-sas

    learn.microsoft.com/.../generate-sas-token

    However, I suspect that the Crypto.GenerateBase64KeyedHashAsBase64String using HMACSHA256 does not give me a correct response and thus creating an invalid authorization.

    Or is there a better way to create a SAS auth in BC/AL?

  • Jan Hoglund Profile Picture
    35 on at

    After lots of testing and debugging and a good night sleep I have made some adjustments and the function is now working correctly. 

    My error was primarily that I used the Base64decode on the Key. However, the key should be used as-is and not be decoded before used. 

    Complete working function below if anyone else stumbles upon this. The function will return a complete SAS-token that can be used as Authorization in a http-request header to send a message to an Azure Service Bus Queue. 

    pastedimage1678717159841v1.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,143

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 1,694 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 1,067 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans