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...
Unanswered

What is the best way to store secrets in Business Central?

(1) ShareShare
ReportReport
Posted on by 2
We want to store an azure client secret to be used in a code unit to generate JWT tokens for sending HTTP requests.
 
We have explored the key vault option but we are using business central online with a Per-Tenant Extension which does not seam to support key vault integration (https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/administration/setup-app-key-vault).
 
Which other secure options do we have to achieve this?
I have the same question (0)
  • Suggested answer
    Aman Kakkar Profile Picture
    1,714 on at
    What is the best way to store secrets in Business Central?
    Hi,
     
    One option that works well in PTEs is using the SecretText data type. I've used this approach before to store and use client secrets securely inside AL code.
     
     

    Create a setup field and set ExtendedDatatype = Masked. This ensures the user can enter the value, but cannot read it afterward.

    field(7; "Client Secret"; Text[2048])
    {
        Caption = 'Client Secret';
        ExtendedDatatype = Masked;
        ToolTip = 'Azure AD Client Secret.';
    }
     
    Inside your codeunit (e.g., when generating JWT or OAuth tokens), convert the stored value into SecretText:
     
    procedure GetSecretKey()
    var
        SecretKey: SecretText;
    begin
        SecretKey := SecretText.SecretStrSubstNo(Setup."Secret Key");
    end;
     

    The advantage of SecretText is:

    • It cannot be directly converted back to plain text
    • It avoids exposure in debugging, errors, and telemetry
     
    Do mark as verified if this helps.
    Aman K

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 3,106

#2
Jainam M. Kothari Profile Picture

Jainam M. Kothari 2,291 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 2,010 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans