Download blob from Azure Storage Account using C#

When you download a blob from Private Endpoint enabled Azure Storage Account using C#

     public static async Task<byte[]> DownloadBlobAsync(string url, string fileName)
        {
            CloudStorageAccount storageAccount =
            CloudStorageAccount.Parse(BLOBStorageConnectionString);
            CloudBlobClient client = storageAccount.CreateCloudBlobClient();
            CloudBlobContainer container = client.GetContainerReference("d365bcfiles");
            CloudBlockBlob blob = container.GetBlockBlobReference(fileName);
            await blob.FetchAttributesAsync();
            long fileByteLength = blob.Properties.Length;
            byte[] fileContent = new byte[fileByteLength];
            for (int i = 0; i < fileByteLength; i++)
            {
                fileContent[i] = 0x20;
            }
            await blob.DownloadToByteArrayAsync(fileContent, 0);
            return fileContent;
        }

Add Comment