In this blog, we will walk through the process of unzipping a file received from D365 FO DMF (Data Management Framework) data packages using an Azure Function App.
Below are the detailed steps to implement this solution.
🔹 Step 1: Access Azure Portal
Navigate to the Microsoft Azure Portal
Sign in with your credentials
Ensure you have the required permissions to create resources (Function App, Storage Account, etc.)
🔹 Step 2: Create a Function App
In the Azure Portal, click on “Create a resource”
Search for Function App and click Create
Provide the required details:
Subscription: Select your subscription
Resource Group: Create or use existing
Function App Name: e.g., UnZipFileProcesser
Runtime Stack: .NET / Node.js (depending on your preference)
Region: Choose closest region
Under Hosting:
Select or create a Storage Account
Review + Create → Click Create
✅ Once deployed, your Function App will be ready to host your code.
🔹 Step 3: Create Azure Function Project in Visual Studio
Open Microsoft Visual Studio
Click on Create a new project
Select Azure Functions
Click Next
Configure Project:
Project Name:
UnZipFileProcesserLocation: Choose your workspace
Click Create
Now your project will look like this and install all the packages that are showing in the project.
🔹 Step 4: Implement Unzip Logic
Inside your function, write logic to:
Read the zipped file from Blob Storage
Extract contents
Upload extracted files to another container (e.g.,
output-container)
Sample C# Code Snippet:
using Azure.Storage.Blobs;
using Azure.Storage.Blobs.Specialized;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.WebJobs;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using System;
using System.IO;
using System.IO.Compression;
using System.Net;
namespace UnZipFileProcesser
{
public class UnzipFile
{
[Function("UnzipFile")]
public static async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "post")] HttpRequest req, ILogger _logger)
{
try
{
// Inputs from Logic App / request
string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
dynamic data = JsonConvert.DeserializeObject(requestBody);
string sourceContainer = data?.sourceContainer;
string destinationContainer = data?.destinationContainer;
string sourcePath = data?.sourcePath;// Pass file name + Path
string dataFileName = data?.dataFileName;
string destinationPath = data?.destinationPath;
string filename = data?.filename;
string connectionString = data?.connectionString;
var blobServiceClient = new BlobServiceClient(connectionString);
var sourceContainerClient = blobServiceClient.GetBlobContainerClient(sourceContainer);
var destContainerClient = blobServiceClient.GetBlobContainerClient(destinationContainer);
await destContainerClient.CreateIfNotExistsAsync();
var sourceBlob = sourceContainerClient.GetBlobClient(sourcePath);
var extractedFiles = new List<string>();
var memoryStream = new MemoryStream();
await sourceBlob.DownloadToAsync(memoryStream);
memoryStream.Position = 0; // Reset position before reading
using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Read))
{
foreach (var entry in archive.Entries)
{
if (string.IsNullOrEmpty(entry.Name)) continue;
if (!string.Equals(entry.Name, dataFileName, StringComparison.OrdinalIgnoreCase))
continue;
string blobpath = $"{destinationPath.TrimEnd('/')}/" + filename + ".csv";
var destBlob = destContainerClient.GetBlobClient(blobpath);
using var entryStream = entry.Open();
await destBlob.UploadAsync(entryStream, overwrite: true);
extractedFiles.Add(blobpath);
}
}
return new OkObjectResult(new
{
Message = "Extraction complete",
Files = extractedFiles
});
}
catch (Exception ex)
{
_logger.LogError(ex, "error occurred!");
return new StatusCodeResult((int)HttpStatusCode.InternalServerError);
}
}
}
}
For the above function app pass the below parameters as request body
{
"connectionString": "Blob connection string",
"sourceContainer": "SourceFilePath container (Outbound Con)",
"destinationContainer": "Dest Container",
"sourcePath": "Filepath",
"destinationPath": "Destination file path (Output)",
"filename": "File name",
"dataFileName": "purchase order lines entity.txt"
}
🔹 Step 5: Publish the Function App
In Visual Studio:
Right-click project → Publish
Choose:
Azure
Azure Function App (Windows/Linux)
Select your created Function App (UnZipFileProcesser)
Click Publish
✅ Your code will be deployed to Azure.
🔹 Step 6: Test the Solution
Upload a
.zipfile (DMF package) into the input containerThe Blob-triggered function will:
Automatically execute
Extract contents
Save files to output container
🚀 Summary
By following the above steps, you can:
Automatically process DMF package files
Extract zipped contents
Integrate with downstream systems (like Logic Apps or D365 FO)


No comments:
Post a Comment