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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Dynamics 365 Community / Forums / Finance forum / Get all files (Blobs) ...
Finance forum

Get all files (Blobs) in a list from Azure storage container in D365 using X++ code

(0) ShareShare
ReportReport
Posted on by 3,732

Now a days Microsoft have moved everything to Azure. But in D365 fetching blobs as a list from a storage container is still tricky. Here in this blog code you'll be able to get all the blobs from Azure container in a single list.


using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;

class Azure
{
    public void processAzureBlobFiles()
    {      
         var storageCredentials = new Microsoft.WindowsAzure.Storage.Auth.StorageCredentials("Storage account name", "Access key");

        CloudStorageAccount storageAccount = new Microsoft.WindowsAzure.Storage.CloudStorageAccount(storageCredentials, true);

       CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

       CloudBlobContainer blobContainer = blobClient.GetContainerReference("Container Name");

       System.Collections.IEnumerable list = new System.Collections.Generic.List<str>();
       list = blobContainer.ListBlobs(null, false, 0, null, null);
       System.Collections.IEnumerator listEnumerator = list.getEnumerator();

       while  (listEnumerator.moveNext())
      {
      CloudBlockBlob blob = listEnumerator.get_Current();

      if (blob.Exists(null, null))
      {
           str file = blob.StorageUri.PrimaryUri.AbsoluteUri;
           str fileName = blob.Name;
      }
   }
 }
}
I have the same question (0)

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

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard > Finance

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans