Skip to main content

Notifications

Announcements

No record found.

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!

  • Jan Hoglund Profile Picture
    Jan Hoglund 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
    Jan Hoglund 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
    Nitin Verma 21,081 Super User 2024 Season 1 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

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,622 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans