Skip to main content

Notifications

Announcements

No record found.

Dynamics 365 Community / Forums / Finance forum / Connect D365 finOps to...
Finance forum
Suggested answer

Connect D365 finOps to Azure file storage

Posted on by Microsoft Employee

Hello,

i'm using Azure file storage to read file from fileshare and insert data to D365 finOps. I begin testing it with x++ and if import was succeded i copy the file in fileshare in another folder. the problem is when i try to copy file i try different method on the  Microsoft.WindowsAzure.Storage.File.CloudFile but i get this error : 

'UploadFromFileAsync(System.String, System.IO.Stream)' is not found on type 'Microsoft.WindowsAzure.Storage.File.CloudFile'

Could you help me ?

below my code :
// Set Azure storage auth credentials
StorageCredentials credentails = new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials(storageAccountName, storageAccountKey);
        
// Find Azure cloud storage account
CloudStorageAccount cloudStorageAccount = new Microsoft.WindowsAzure.Storage.CloudStorageAccount(credentails, true);
        
// Create cloud file client
CloudFileClient cloudFileClient = cloudStorageAccount.CreateCloudFileClient();

// Get Azure cloud file share created on Azure portal
CloudFileShare  cloudFileShare = cloudFileClient.GetShareReference(azureStorageShareName);

if(cloudFileShare.Exists(null, null))
{
   // Get cloud file share root directory
   CloudFileDirectory rootDirectory = cloudFileShare.GetRootDirectoryReference();

   if(rootDirectory.Exists(null, null))
   {
       // Get directory on file share root directory
       CloudFileDirectory sourceDir = rootDirectory.GetDirectoryReference('Groupe/HCBA');

       if (sourceDir.Exists(null, null))
       {
           // Get file
           CloudFile file = sourceDir.GetFileReference('Group CB HSO NN 1.0 1200000NU HSONN GFX EAM perpetual license.lic');

           if (file.Exists(null, null))
           {
               // Delete file
               //file.Delete(null, null, null);
                        
               CloudFileDirectory destDir = rootDirectory.GetDirectoryReference('Groupe/HCBA/bak');

               if (destDir.Exists(null, null))
               {
                  System.Uri path = file.Uri;

                  file.UploadFromFileAsync(file.Uri.ToString(), file.OpenRead(null, null, null));
               }        
           }
       }         
   }
}

Thanks,

Best regards 

MOALLA Mehdi

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Connect D365 finOps to Azure file storage

    Hi all,

    The solution is to create a c# project and add reference to AX. 

    Thanks 

  • Jie G Profile Picture
    Jie G on at
    RE: Connect D365 finOps to Azure file storage

    Hello Mehdi,

    Check the Microsoft.WindowsAzure.Storage.dll on your server where your code is running and compare its version with the one your code reference. There should be a mismatch.

  • Suggested answer
    Joris dG Profile Picture
    Joris dG 17,775 on at
    RE: Connect D365 finOps to Azure file storage

    It's quite possible the web server has its own version of this DLL that is older than the one you reference (check packageslocaldirectory/bin or webroot or webroot/bin). This method may not exist or have a different method signature on that older version. Your only option is to use whatever version the platform is currently using, knowing that if it gets updated your code may break.

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,773 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,513 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans