web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

upload the file to Azure blob storage

(1) ShareShare
ReportReport
Posted on by 16
Hi team, 
 
Required assistance to complete the POC to upload the files to Azure blob storage using X++ code.
 
While i went through available team post on the same. few details seems to be missing like which all assembly we need to include. How we can include in?
 
 
Any available code sample (solution) that i can be tested as POC and later if required will modify the sample as per the requirement.
 
 
I have the same question (0)
  • Martin Dráb Profile Picture
    238,322 Most Valuable Professional on at
    There are two huge differences:
    • You have an executable application, but now your code won't execute by itself. It'll be used as a library of the web application.
    • Your application runs on your local machine and can read files there, while F&O is a web application running somewhere in cloud and it can't simply connect to users computers and read their files.
  • AshishAnand Profile Picture
    16 on at
    Hi Martin,
     
    Thanks for guidance so far. 
     
    Given that i have the c# solution already working (Getting file from desktop and uploading the azure blob storage) i thought if i can use same solution by leveraging the concept of taking reference of C# project in X++.
     
    If this is not possible with same logic i will try to check the suggestion -  F&O, you can simply use File::GetFileFromUser() in X++ and update in case of any blocker 
     
     
  • Martin Dráb Profile Picture
    238,322 Most Valuable Professional on at
    Making a reference from an X++ project to a C# project is simple. Put them to the same solution, compile the C# project and then add a project reference to the X++ project.
     
    But your statement that "selecting the file from desktop to uploading the file to container is written in C# class library" makes no sense to me. It's a pity that you didn't mention how you imagine it to work, but your idea is most likely wrong.
     
    If you want a dialog for uploading a file to F&O, you can simply use File::GetFileFromUser() in X++.
  • AshishAnand Profile Picture
    16 on at
    Hi Martin 
     
    For POC starting now i am trying to upload the file here it is image/video to azure blob storage.
     
    The C# console application written is uploading the file (from folder specified) and upload it to container in storage account.
     
    To simplify: 
     
    I have one of the console app working as expected (Able to upload the file from local computer to  container).
     
    There is a process about referencing the C# in X++ so wanted to know if this is possible ? 
     
    Like if i reference this C# code -> say create it as C# class library and then reference it in X++ solution. How i can do that? 
     
    in simple ways what are the steps i need to follow: 
     
    1 Create a visual studio solution selecting the Finance and operation template. 
     
    2 Create a Xpp project 
     
    3 Create a c# class library (Add the same code in it ) - Name AzureBlobOperation ==> All operation like selecting the file from desktop to uploading the file to container is written in 
    C# class library (i just wanted to reference and use this in X++ code )
     
    4 Add reference of this C# class library to the X++ project. 
     
    5 Now create an X++ class (AzureBlobupload) - add reference of this C# class library - using AzureBlobOperation 
     
    6 Creating method inside X++ class (AzureBlobupload) 
     
    7. call these methods inside the main method of the X++ class (AzureBlobupload) 
     
    8. Finally run the class in the Visual studio 
     
    I am not sure if this is possible or how i can write the methods in X++ which perform operation like Select file from desktop / upload file to container in X++ class. 
     
    Once i can complete this one POC then can try the other option of authenticating using the client id and client secret 
     
  • Martin Dráb Profile Picture
    238,322 Most Valuable Professional on at
    Please tell us more about "the files"? Where are they located? If in your local machine, you'll need a mechanism to upload them to cloud. X++ running on web server in Azure can't simply connect to users' machine and copy files from their hard disks.
  • AshishAnand Profile Picture
    16 on at
    My requirement is to upload the files to blob. (Authentication method to use is client id and client secret). 

    In D365FO also authentication should happen using the client id and client secret then finally the SSRS reports generated should be uploaded to blob.
     
    As part of requirement first i am trying to develope the stand alone C# console application and will be replicating the same in X++. 
  • Martin Dráb Profile Picture
    238,322 Most Valuable Professional on at
    No, you shouldn't use the same code. Half of it wouldn't make sense in an F&O library: reading files from local disk (not applicable in cloud), using a configuration file, using Main(), writing to console.
     
    First of all, think about how you want to deal with files, because your current code is useless in cloud. Explain your business requirements if you have no idea how to design the application, so we can help you with the design.
  • AshishAnand Profile Picture
    16 on at
    Thanks Martin.
     
    Instead of creating the console application say is created the C# class library using the same code.
     
    Will i able to just call the method from X++ just like i called these methods defined on main class of console application.?
     
    I will try to perform the same action and update if i got any blocker however once we say we can directly use the C# class in X++ can we directly use those method directly in X++
     
     
  • Martin Dráb Profile Picture
    238,322 Most Valuable Professional on at
    You suddenly start talking about a different assembly. If you want make things a bit easier for you, you may want to go back and use X++ code discussed below.
     
    If you want to use the other one, a good news is that even Azure.Storage.Blobs assembly is already include in F&O and you can use it directly.
     
    Both approaches are possible - you can either use .NET classes from directly from X++, or you can create a C# class library and use that from X++. The benefit of a C# library is that you can use features of C# that aren't available in X++, such as LINQ (that you're using in GetFiles()).
  • AshishAnand Profile Picture
    16 on at
    Hi team, 
     
    While i was able to create the standalone C# console application to upload the file to azure blob storage. 
     
    Now i am not sure how i can replicate the same logic in X++
     
    - Should i create a X++ runnable class and just add (using Azure.Sto..) and use these methods directly 
     
    - should create a X++ class and add different methods to this. 
     
    - Should i add C# class library to the X++ solution and add reference of the C# code to X++ project. Write business logic by using C# and X++ source code - Finance & Operations | Dynamics 365 | Microsoft Learn

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 843 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 503 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 288 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans