web
You’re offline. This is a read only version of the page.
close
Skip to main content
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)
  • Jan Hoglund Profile Picture
    35 on at
    RE: Error creating a Azure SAS-token in AL

    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

  • Jan Hoglund Profile Picture
    35 on at
    RE: Error creating a Azure SAS-token in AL

    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?

  • Suggested answer
    Nitin Verma Profile Picture
    21,593 Moderator on at
    RE: Error creating a Azure SAS-token in AL

    Hi,

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

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

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…

Mansi Soni – Community Spotlight

We are honored to recognize Mansi Soni as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

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

#1
Sohail Ahmed Profile Picture

Sohail Ahmed 2,899 Super User 2025 Season 2

#2
Sumit Singh Profile Picture

Sumit Singh 2,444

#3
Jeffrey Bulanadi Profile Picture

Jeffrey Bulanadi 2,304

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans