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

Connecting to Azure File Share (Not Blob Storage) through AL Code

(0) ShareShare
ReportReport
Posted on by

Is it possible to connect to Azure File Share through AL code and import data from a file on the file share into a journal in BC? I have tried to use the Rest APIs with no luck (https://docs.microsoft.com/en-us/rest/api/storageservices/file-service-rest-api). The particular issue I keep running into is authorization. I'm doing authorization with a Shared Key and following the authorization guidelines based on MS documentation (https://docs.microsoft.com/en-us/rest/api/storageservices/authorize-with-shared-key).

Code Sample:

trigger OnRun()
    var
        requestMethod: Text;
        request: HttpRequestMessage;
        RequestHeader: HttpHeaders;
        hhtpres: HttpResponseMessage;
        canonicalizedResource: Text;
        canonicalizedHeaders: Text;
        urlPath: Text;
        client: HttpClient;
        content: HttpContent;
        authorizationHeader: Text;
        stringToSign: Text;
        msVersion: Text;
        cha: Char;
        contenttype: Text;
        contentLength: Integer;
        SharedKey: Text;
        dateInRfc1123Format: Text;
        EncryptionManagement: Codeunit "Cryptography Management";
        uri: Text;
        fileName: Text;
    begin
        cha := 10;
        msVersion := '2019-12-12';
        SharedKey := '';
        dateInRfc1123Format := GetUTCDateTimeText();
        requestMethod := 'GET';
        fileName := 'abc.xlsm';
        urlPath := '//';
        CanonicalizedResource := StrSubstNo('/%1/%2', '', '//');
        canonicalizedHeaders := 'x-ms-date:'   dateInRfc1123Format   Format(cha)  
                                'x-ms-version:'   msVersion;



        stringToSign := (requestMethod   Format(cha)  
                         Format(cha)  
                         Format(cha)  
                         Format(cha)  
                         Format(cha)  
                         Format(cha)  
                         Format(cha)  
                         Format(cha)  
                         Format(cha)  
                         Format(cha)  
                         Format(cha)  
                         Format(cha)  
                         canonicalizedHeaders   Format(cha)  
                         canonicalizedResource);

        authorizationHeader := 'SharedKey :'   EncryptionManagement.GenerateBase64KeyedHashAsBase64String(stringToSign, SharedKey, 2);

        uri := 'https://.file.core.windows.net///';

        request.SetRequestUri(uri);
        request.Method := requestMethod;
        RequestHeader.Clear();
        request.GetHeaders(RequestHeader);
        RequestHeader.Add('Authorization', authorizationHeader);
        RequestHeader.Add('x-ms-date', dateInRfc1123Format);
        RequestHeader.Add('x-ms-version', msVersion);

        client.Send(request, hhtpres);

        if not hhtpres.IsSuccessStatusCode then
            Error(FORMAT(hhtpres.HttpStatusCode)   ': '   hhtpres.ReasonPhrase)
        else
            Message(FORMAT(hhtpres.HttpStatusCode)   ': '   hhtpres.ReasonPhrase);
    end;

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,172 Most Valuable Professional on at

    Never tried directly from AL. Personally I'm using an Azure Function called from AL and the logic to access the file share is handled in the Azure Function itself.

    Are you using shared keys?The shared key normally should be passed in the url.

  • Zay Profile Picture
    on at

    Thanks for the reply Stefano.

    Do you have any links or samples I could review? Also is there any other way besides Azure File Share to accomplish the goal of automatically reading file and importing it into a BC journal with no user interaction?

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 1,825 Super User 2026 Season 1

#2
YUN ZHU Profile Picture

YUN ZHU 967 Super User 2026 Season 1

#3
Teagen Boll Profile Picture

Teagen Boll 652 Super User 2026 Season 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans