# How to send CSV/Excel file from azure blob storage to DMF data project through X++

**URL:** <https://www.dynamicsuser.net/t/how-to-send-csv-excel-file-from-azure-blob-storage-to-dmf-data-project-through-x/76165>\
**Category:** Developer Forum\
**Created:** [April 13, 2022, 1:34pm UTC](https://www.dynamicsuser.net/t/how-to-send-csv-excel-file-from-azure-blob-storage-to-dmf-data-project-through-x/76165 "2022-04-13T13:34:36Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Haribabu\_Annangi](https://avatars.discourse-cdn.com/v4/letter/h/a587f6/32.png) [@Haribabu\_Annangi](https://www.dynamicsuser.net/u/Haribabu_Annangi)\
**Post date:** [April 13, 2022, 1:34pm UTC](https://www.dynamicsuser.net/t/how-to-send-csv-excel-file-from-azure-blob-storage-to-dmf-data-project-through-x/76165/1 "2022-04-13T13:34:36Z")

</div>

Hello all,

I have requirement that third party application will send the CSV file azure blob storage.  
From azure blob I have to send this to DMF data project to import it D365 F&O.

I have followed below link but I can only see that data from blob and get the file names  
but not bale to send it to D365 DMF data project

> **[Part-2: Azure BLOB storage with Dynamics 365 for operations](https://sainacloudconsulting.com/blog/f/part-2-azure-blob-storage-with-dynamics-365-for-operations)**
>
> Consuming files stored in the Azure Blob Storage within Dynamics 365 Finance and Operations using X++ code

And also I followed below link where it will take file from user and and send to Data project but could not mix both links.

> **[D365FO: Import data through DMF data project using x++](https://startspacers.wordpress.com/2019/03/12/d365f0-import-data-through-dmf-data-project-using-x/)**
>
> Following code can be used to import data using x++ through DMF data project. Prerequisites: Data entity Setup an import project using the entity How it works….. When you run the code, it pro…

Please suggest if any

---

<div class="post-metadata">

**Author:** ![jacob.roder](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/jacob.roder/32/7480_2.png) [@jacob.roder](https://www.dynamicsuser.net/u/jacob.roder)\
**Post date:** [April 13, 2022, 4:02pm UTC](https://www.dynamicsuser.net/t/how-to-send-csv-excel-file-from-azure-blob-storage-to-dmf-data-project-through-x/76165/2 "2022-04-13T16:02:28Z")

</div>

Use logic apps. Instead of using the dynamics 365 connector, use the HTTP connector and send to the enqueue endpoint.

here’s a link from michael stashwick’s presentation at DynamicsCon that might help.

[DynamicsCon - Michael Stashwick Logic Apps and Dynamics 365](https://www.youtube.com/watch?v=67I4VxXnVZc)

---

<div class="post-metadata">

**Author:** ![Haribabu\_Annangi](https://avatars.discourse-cdn.com/v4/letter/h/a587f6/32.png) [@Haribabu\_Annangi](https://www.dynamicsuser.net/u/Haribabu_Annangi)\
**Post date:** [April 14, 2022, 8:07am UTC](https://www.dynamicsuser.net/t/how-to-send-csv-excel-file-from-azure-blob-storage-to-dmf-data-project-through-x/76165/3 "2022-04-14T08:07:33Z")

</div>

Hello Jacob,

customer is not willing to use logicapp, due to various reasons.

I have to do it through X++ and I need to send file from azure blob to DMF data project.

Please suggest if any logic or reference documentation, this is bit critical for me.

The links that I have mentioned is talking about getting file name from azure blob and I need to send that file to DMF project with X++ thats where I struck

Please help on how to do it through dynamics 365 connector

---

<div class="post-metadata">

**Author:** ![jacob.roder](https://sea1.discourse-cdn.com/flex023/user_avatar/www.dynamicsuser.net/jacob.roder/32/7480_2.png) [@jacob.roder](https://www.dynamicsuser.net/u/jacob.roder)\
**Post date:** [April 15, 2022, 3:44am UTC](https://www.dynamicsuser.net/t/how-to-send-csv-excel-file-from-azure-blob-storage-to-dmf-data-project-through-x/76165/4 "2022-04-15T03:44:02Z")

</div>

then i have no idea 🙂 maybe someone else has a better option.

---

<div class="post-metadata">

**Author:** ![Haribabu\_Annangi](https://avatars.discourse-cdn.com/v4/letter/h/a587f6/32.png) [@Haribabu\_Annangi](https://www.dynamicsuser.net/u/Haribabu_Annangi)\
**Post date:** [April 18, 2022, 5:00am UTC](https://www.dynamicsuser.net/t/how-to-send-csv-excel-file-from-azure-blob-storage-to-dmf-data-project-through-x/76165/5 "2022-04-18T05:00:47Z")

</div>

Hi Team,

If any suggestion please suggest, this is bit critical integration .

I have requirement that third party application will send the CSV file to azure blob storage.  
From azure blob I have to send this to DMF data project to import it D365 F&O with X++.

Please suggest if you have any possible solution for this

---

<div class="post-metadata">

**Author:** ![MartinDrab](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@MartinDrab](https://www.dynamicsuser.net/u/MartinDrab)\
**Post date:** [April 19, 2022, 6:12am UTC](https://www.dynamicsuser.net/t/how-to-send-csv-excel-file-from-azure-blob-storage-to-dmf-data-project-through-x/76165/6 "2022-04-19T06:12:14Z")

</div>

If the customer doesn’t like Logic Apps, use Azure Functions instead.  
And if the customer doesn’t like Azure at all, then why we’re talking about getting data from Azure storage to a cloud ERP running in Azure too?  
Deciding not to use the right tools for the job means a lot of extra work, and if don’t know how to do it in any other way, then it means not being able to do the job at all.  
Anyway, if you insist, reading data though Azure Storage API is quite easy (I already [showed it to you in your other thread](https://www.dynamicsuser.net/t/how-to-get-file-from-azure-blob-storage-and-import-it-into-d365-f-o-through-data-management/76033)). Injecting files to data management from X++ will likely be more difficult, because that’s not what you’re supposed to do. I don’t have code for that, but I’m pretty sure that it can be done. Instead, you should use [data management APIs](https://docs.microsoft.com/en-us/dynamics365/fin-ops-core/dev-itpro/data-entities/data-management-api?WT.mc_id=DX-MVP-5000414) from outside (such as Azure Functions).

---

<div class="post-metadata">

**Author:** ![Haribabu\_Annangi](https://avatars.discourse-cdn.com/v4/letter/h/a587f6/32.png) [@Haribabu\_Annangi](https://www.dynamicsuser.net/u/Haribabu_Annangi)\
**Post date:** [April 19, 2022, 11:57am UTC](https://www.dynamicsuser.net/t/how-to-send-csv-excel-file-from-azure-blob-storage-to-dmf-data-project-through-x/76165/7 "2022-04-19T11:57:44Z")

</div>

Hello Martin,

I am able to read the file names and file content with X++ and below but not able to send it to DMF

> **[Part-1: Azure BLOB storage with Dynamics 365 for operations](https://sainacloudconsulting.com/blog/f/part-1-azure-blob-storage-with-dynamics-365-for-operations)**
>
> With the introduction of cloud based applications, Dynamics has opened doors for seamless integration with Azure services. This blog is created to portray one such example of how Azure capability can be utilized within D...

CloudBlobDirectory cloudBlobDirectory;// The directory of the blob container  
container con;  
cloudBlobDirectory = cloudBlobContainer.GetDirectoryReference(“SainaCloudConsulting\Test1”);//File path where the files are stored  
System.Collections.IEnumerable lstEnumarable = cloudBlobDirectory.ListBlobs(false, 0, null, null);  
System.Collections.IEnumerator lstEnumarator = lstEnumarable.GetEnumerator();  
List filenames = new List(Types::String);  
while(lstEnumarator.MoveNext())  
{  
IListBlobItem item = lstEnumarator.Current;  
if(item is CloudBlockBlob)  
{  
CloudBlockBlob blob = item;  
blob.FetchAttributes(null, null, null);  
con = str2con(blob.name, “/”);  
filenames.addStart(conPeek(con,conlen(con)));  
}  
}

With above code I have all file names from azure storage account.

I have below code to send the file to DMF data project from user manually by browsing

class XYZCustGroupImport  
{  
private static DMFDefinitionGroup findDMFDefinitionGroup()  
{  
DMFDefinitionGroup definitionGroup;

```
    select firstonly definitionGroup
        where definitionGroup.DefinitionGroupName == 'CustGroupImport'; //DMF import data project

    return definitionGroup;
}

private static DMFDefinitionGroupEntity findDMFDefinitionGroupEntity(DMFDefinitionGroup _definitionGroup)
{
    DMFDefinitionGroupEntity definitionGroupEntity;
    DMFEntity dmfEntity;

    select firstonly RecId, Entity from definitionGroupEntity exists join dmfEntity
        where definitionGroupEntity.DefinitionGroup == _definitionGroup.DefinitionGroupName
            && dmfEntity.EntityName == definitionGroupEntity.Entity
            && dmfEntity.TargetEntity == dataentityviewstr(CustCustomerGroupEntity);

    if (!definitionGroupEntity)
    {
        throw error(strFmt("@DMF:DMFNoEntityExists", _definitionGroup.DefinitionGroupName));
    }

    return definitionGroupEntity;
}

private static DMFLocalFilePath applyTransforms(SharedServiceUnitFileID _uploadedStatement, DMFDefinitionGroup definitionGroup)
{
    DMFDefinitionGroupEntity definitionGroupEntity = XYZCustGroupImport::findDMFDefinitionGroupEntity(definitionGroup);
    DMFExecutionId executionId = DMFUtil::setupNewExecution(definitionGroup.DefinitionGroupName);

    DMFDefinitionGroupExecution execution = DMFDefinitionGroupExecution::find(
        definitionGroup.DefinitionGroupName,
        definitionGroupEntity.Entity,
        executionId,
        true);

    execution.IsTransformed = NoYes::No;
    DMFLocalFilePath filePath = execution.applyTransforms(_uploadedStatement);

    DMFExecution e = DMFExecution::find(executionId, true);
    e.delete();

    return filePath;
}

public static void main(Args _args)
{      
    SharedServiceUnitFileID fileId;

    //Get the file from user
    FileUploadTemporaryStorageResult result = File::GetFileFromUser() as FileUploadTemporaryStorageResult;

    if (result && result.getUploadStatus())
    {
        fileId = result.getFileId();

        DMFDefinitionGroup definitionGroup = XYZCustGroupImport::findDMFDefinitionGroup();

        XYZCustGroupImport::applyTransforms(fileId, definitionGroup);

        DMFDefinitionGroupEntity definitionGroupEntity = XYZCustGroupImport::findDMFDefinitionGroupEntity(definitionGroup);
        DMFExecutionId executionId = DMFUtil::setupNewExecution(definitionGroup.DefinitionGroupName);

        // Find execution
        DMFDefinitionGroupExecution execution = DMFDefinitionGroupExecution::find(definitionGroup.DefinitionGroupName, definitionGroupEntity.Entity,
                                                                                    executionId, true);
        execution.FilePath = fileId;
        execution.IsTransformed = NoYes::Yes;
        execution.update();

        // Import the file via quick import DMF
        DMFQuickImportExport::doPGImport(definitionGroup.DefinitionGroupName, executionId, true);
        
        //deletes file
        result.deleteResult();
    }
}

```

}

But I am not able to incorporate the code which I have, to get filenames from azure blob into the code that sending the file to DMF

I have to something with below line which will take the file from user manually  
_FileUploadTemporaryStorageResult result = File::GetFileFromUser() as FileUploadTemporaryStorageResult;_

Please suggest if we can do something on it

---

<div class="post-metadata">

**Author:** ![MartinDrab](https://avatars.discourse-cdn.com/v4/letter/m/e0b2c6/32.png) [@MartinDrab](https://www.dynamicsuser.net/u/MartinDrab)\
**Post date:** [April 21, 2022, 12:33pm UTC](https://www.dynamicsuser.net/t/how-to-send-csv-excel-file-from-azure-blob-storage-to-dmf-data-project-through-x/76165/8 "2022-04-21T12:33:18Z")

</div>

Look at [MSDyn365FO: Execution of Data projects through X++ code](https://community.dynamics.com/365/financeandoperations/b/365operationswithsukrut/posts/msdyn365fo-execution-of-data-projects-through-x-code) - it shows how to import data from a data stream.

Getting a stream from `CloudBlockBlob` is easy - simply call its `DownloadToStream()` method.
