How to Put a Exported XML file from Xmlport to Azure Blob Container in BC 365 AL

devanshu_chaudharydevanshu_chaudhary IndiaMember Posts: 6
Hello Everyone,

I wanted to achieve a task in which i am using an xmlport to export a xml file and trying to put that file into Azure Blob Storage Containers. Written the code something like this.This code is just placing a blank file on Azure, not my Exported Xml file which is in Outstream (OutStr). Please help with the edit in code
var
ABSContClient: Codeunit "ABS Container Client";
StorageAccount: Text;
Authorization: Interface "Storage Service Authorization";
ContainerName: Text;
Response: Codeunit "ABS Operation Response";
StorageServiceAuth: Codeunit "Storage Service Authorization";
SharedKey: Text;
ABSContainer: Record "ABS Container";
ABSBlobClient: Codeunit "ABS Blob Client";
ABSContainerContent: Record "ABS Container Content";
Ins: InStream;
FileName: Text;
OutStr: OutStream;
TempBlob: Codeunit "Temp Blob";
PersistanceBlob: Codeunit "Persistent Blob";

//begin

ClosedPO.RESET;
ClosedPO.SETRANGE("Is Exported", FALSE);
IF NOT ClosedPO.FINDSET THEN BEGIN
InsertLogEntry('Error', 'Nothing to Export');
CurrReport.BREAK;
END ELSE BEGIN
PurchPayableSetup.Get();
ContainerName := 'poclosure';
StorageAccount := PurchPayableSetup."Storage Account Name";
SharedKey := PurchPayableSetup."Access Key";
Authorization := StorageServiceAuth.CreateSharedKey(SharedKey);
ABSBlobClient.Initialize(StorageAccount, ContainerName, Authorization);
TempBlob.CreateOutStream(OutStr);
if XMLPORT.Export(50008, OutStr, ClosedPO) then begin
TempBlob.CreateInStream(Ins);
CopyStream(OutStr, Ins);
ABSBlobClient.PutBlobBlockBlobStream('Closed PO List: ' + format(CurrentDateTime), Ins);
InsertLogEntry('Export', 'XML File Export Successfully ');
end;
END;
Sign In or Register to comment.