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

Announcements

No record found.

News and Announcements icon
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!

  • Suggested answer
    Nitin Verma Profile Picture
    21,812 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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Congratulations to the August Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 720 Super User 2026 Season 2

#2
YUN ZHU Profile Picture

YUN ZHU 436 Super User 2026 Season 2

#3
AndrewThomas81 Profile Picture

AndrewThomas81 409 Super User 2026 Season 2

Last 30 days Overall leaderboard

Featured topics

Microsoft Training Manuals

Product updates

Dynamics 365 release plans