Auto Import File from Azure Storage to Cloud BC

julkifli33
Member Posts: 1,092
Hi All,
does anyone ever customize auto import file from Azure Storage to cloud BC?
is that possible?
Please advise and share.
Thanks before
does anyone ever customize auto import file from Azure Storage to cloud BC?
is that possible?
Please advise and share.
Thanks before
0
Best Answer
-
Hello @julkifli33,
You need to change these two lines:urlPath := GetAccountSharedResource() + '/' + GetAdditionalFolderPath + '?comp=list'; CanonicalizedResource := StrSubstNo('/%1/%2', GetAccountName(), urlPath);
With these:urlPath := GetAccountSharedResource() + '/' + GetAdditionalFolderPath + '?comp=list&restype=directory'; CanonicalizedResource := ConvertStr(StrSubstNo('/%1/%2', GetAccountName(), urlPath), '?=&', cha + ':' + cha);
And you get back and XML with the information.
Regards0
Answers
-
I want to read the files from 1 folder with this code
procedure ReadAzureStorageDirectory() var requestMethod: Text; request: HttpRequestMessage; RequestHeader: HttpHeaders; hhtpres: HttpResponseMessage; canonicalizedResource: Text; canonicalizedHeaders: Text; urlPath: Text; client: HttpClient; content: HttpContent; ContentHeaders: HttpHeaders; test: Boolean; authorizationHeader: Text; stringToSign: Text; msVersion: Text; cha: Text[1]; contenttype: Text; contentLength: Integer; res: Text; keyss: Text; dateInRfc1123Format: Text; // <------------ Changed //EncryptionManagement: Codeunit "Encryption Management"; EncryptionManagement: Codeunit "Cryptography Management"; // <------------ Changed BC15 uri: Text; Range: Text; InStr: InStream; ResponseText: Text; begin cha[1] := 10; msVersion := '2020-02-10'; keyss := GetAccountAccessKey(); dateInRfc1123Format := GetUTCDateTimeText(); // <------------ Changed requestMethod := 'GET'; urlPath := GetAccountSharedResource() + '/' + GetAdditionalFolderPath + '?comp=list'; CanonicalizedResource := StrSubstNo('/%1/%2', GetAccountName(), urlPath); CanonicalizedHeaders := 'x-ms-date:' + dateInRfc1123Format + Format(cha) + 'x-ms-version:' + msVersion; stringToSign := (requestMethod + Format(cha) + Format(cha) + //Content-Encoding + "\n" + Format(cha) + //Content-Language + "\n" + Format(cha) + //Content-Length + "\n" + Format(cha) + //Content-MD5 + "\n" + Format(cha) + //Content-Type + "\n" + Format(cha) + //Date + "\n" + Format(cha) + //If-Modified-Since + "\n" + Format(cha) + //If-Match + "\n" + Format(cha) + //If-None-Match + "\n" + Format(cha) + //If-Unmodified-Since + "\n" + Format(cha) + //Range + "\n" + canonicalizedHeaders + Format(cha) + // <------------ Changed canonicalizedResource); authorizationHeader := 'SharedKey ' + GetAccountName() + ':' + EncryptionManagement.GenerateBase64KeyedHashAsBase64String(stringToSign, keyss, 2); uri := StrSubstNo('https://%1.file.core.windows.net/%2', GetAccountName(), urlPath); 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(hhtpres.ReasonPhrase) else begin hhtpres.Content.ReadAs(ResponseText); message('%1', ResponseText); end; end;
but it keep get me the authentication error
0 -
@julkifli33
I have not done it myself but MS have created a Tech samle to communicate with Azure Storage.
Perhaps this can help you:
https://github.com/microsoft/BCTech/tree/master/samples/AzureStorage
For help, do not use PM, use forum instead, perhaps other people have the same question, or better answers.0 -
Hi @SanderDk
thanks for the link.
but i think this one is only for blob storage.
actually i need for file storage
0 -
Hello @julkifli33,
You need to change these two lines:urlPath := GetAccountSharedResource() + '/' + GetAdditionalFolderPath + '?comp=list'; CanonicalizedResource := StrSubstNo('/%1/%2', GetAccountName(), urlPath);
With these:urlPath := GetAccountSharedResource() + '/' + GetAdditionalFolderPath + '?comp=list&restype=directory'; CanonicalizedResource := ConvertStr(StrSubstNo('/%1/%2', GetAccountName(), urlPath), '?=&', cha + ':' + cha);
And you get back and XML with the information.
Regards0 -
0
-
Hi @ftornero
are we able to move the file after successfully imported ?
like for example this TestFile.csv
once imported then it should be moved to History folder.
0 -
Hello @julkifli33,
I haven't seen any method to move a file, so I think that you need delete the imported file and create a new one in the destination folder.
Regards.0 -
Hi @ftornero ,
yeah i managed to solve this issue.
recreate the file to another folder
and then delete this file
thx
0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions