For large XML Files you can use a blob storage to host these files. In addition to this, you will need an Azure storage account with container created. You can reference the .NET Assemblies Azure.Storage.Blobs (recommended using since v40).
class AzureBlobStorageHelper
{
/// <summary>
/// Uploads an XML string to Azure Blob Storage using connection string (recommended)
/// </summary>
/// <returns>true if uploaded successfully</returns>
public static boolean uploadFiletoBlobStorage(
str _connectionString,
str _containerName,
str _blobName,
str _xmlContent)
{
boolean ret = false;
try
{
// These types are available natively in D365 FO (PU40+)
Azure.Storage.Blobs.BlobServiceClient serviceClient;
Azure.Storage.Blobs.BlobContainerClient containerClient;
Azure.Storage.Blobs.BlobClient blobClient;
System.IO.Stream stream;
System.Text.Encoding utf8;
System.Byte[] bytes;
utf8 = System.Text.Encoding::get_UTF8();
bytes = utf8.GetBytes(_xmlContent);
// Create stream from bytes
stream = new System.IO.MemoryStream(bytes);
// Initialize clients
serviceClient = new Azure.Storage.Blobs.BlobServiceClient(_connectionString);
containerClient = serviceClient.GetBlobContainerClient(_containerName);
blobClient = containerClient.GetBlobClient(_blobName);
// Upload (overwrites if exists)
blobClient.Upload(stream, true); // true = overwrite
info(strFmt("XML uploaded successfully: %1/%2", _containerName, _blobName));
ret = true;
}
catch (Exception::Error)
{
error("Failed to upload XML to blob storage. Check the connection parameters");
}
catch
{
error("<Error uploading to blob storage>");
}
return ret;
}
///Sample
public static void main(Args _args)
{
str connectiongstring = <Retrievefromparamtertable>;
str containername =<blobstoragecontainerdetailsinparametertable>;
str blobName = <blobnameparametertablewillhostthedetails>;
str xmlContent = <xmlschema>
AzureBlobStorageHelper::uploadFiletoBlobStorage(connectionstring,containername,blobname,xmlcontent);
}
Hope this helps. Happy to answer questions, if any.