Syncfusion AI Assistant

How can I help you?

Open PDF document from Azure Blob Storage

18 Jun 20261 minute to read

To load a PDF file from Azure Blob Storage, follow these steps:

Step 1: Create a simple console application

Project configuration window

Step 3: Install the Microsoft.Azure.Storage.Blob NuGet package as a reference to your project from the NuGet.org.

NuGet package installation

Step 4: Include the following namespaces in the Program.cs file.

using Microsoft.Azure.Storage;
using Microsoft.Azure.Storage.Blob;

Step 5: Add the below code example to load a PDF from Azure blob storage.

// Parse the connection string to your Azure Storage Account.
CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString);

// Create a client to interact with Blob storage.
CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();

// Get a reference to the container name.
CloudBlobContainer container = blobClient.GetContainerReference(containerName);

// Get a reference to the block blob name.
CloudBlockBlob blockBlob = container.GetBlockBlobReference(blobName);
    
// Open a file stream to save the downloaded blob content.
using (var fileStream = File.OpenWrite("sample.pdf"))
{
    // Download the blob's content to the file stream.
    blockBlob.DownloadToStream(fileStream);
}

You can download a complete working sample from GitHub.