Access Files on Public Azure BLOB Storage using .NET Core

  • Serving images or documents directly to a browser.
  • Storing files for distributed access.
  • Streaming video and audio.
  • Storing data for backup and restore, disaster recovery, and archiving.
  • Storing data for analysis by an on-premises or Azure-hosted service.

Access Public Azure Blob Storage

  • First you need to open your package manager, search “Microsoft.WindowsAzure.Storage”, “Microsoft.WindowsAzure.Storage.Auth” and “Microsoft.WindowsAzure.Storage.Blob” then click install
  • Create new project , e.g : Console project, then write below code
CloudStorageAccount mycloudStorageAccount = new CloudStorageAccount(new StorageCredentials(), {accountName}, "", true);
CloudBlobClient blobClient = mycloudStorageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference({containerName});
var blobList = await container.ListBlobsSegmentedAsync(string.Empty, false, BlobListingDetails.None, {maxRecordNumber}, null, null, null);
CloudStorageAccount mycloudStorageAccount = new CloudStorageAccount(new StorageCredentials(), {accountName}, "", true);
CloudBlobClient blobClient = mycloudStorageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference({containerName});var blobList = await container.ListBlobsSegmentedAsync(string.Empty, false, BlobListingDetails.None, 1000, null, null, null);foreach (CloudBlockBlob item in blobList.Results){await item.DownloadToFileAsync($"{item.Name}", FileMode.CreateNew);}
CloudStorageAccount mycloudStorageAccount = new CloudStorageAccount(new StorageCredentials(), {accountName}, "", true);
CloudBlobClient blobClient = mycloudStorageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference({containerName});var blobList = await container.ListBlobsSegmentedAsync(string.Empty, false, BlobListingDetails.None, 1000, null, null, null);foreach (CloudBlockBlob item in blobList.Results){string fileText = await item.DownloadTextAsync();}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store