Azure SDK for .NET - Storage Samples

Explore practical examples for interacting with Azure Storage services.

Introduction to Azure Storage Samples

This section provides a curated collection of code samples demonstrating how to use the Azure SDK for .NET to interact with various Azure Storage services. These samples cover common scenarios, from basic operations like uploading and downloading blobs to more advanced configurations for queues and tables.

Storage Service Categories

Blob Storage

Azure Blob Storage is an object storage solution for the cloud. It's optimized for storing massive amounts of unstructured data, such as text or binary data.

Queue Storage

Azure Queue Storage is a service that stores large numbers of messages that can be accessed from anywhere in the world. Use Queue Storage to build applications that require reliable message processing.

Table Storage

Azure Table Storage stores large amounts of structured, non-relational data. It's a NoSQL key-attribute store that can be a cost-effective way to store and access data.

Getting Started with the Samples

To run these samples, you will need:

Example: Blob Upload (Conceptual Snippet)

Here's a glimpse of how a blob upload might look:


using Azure.Storage.Blobs;

// Your connection string
string connectionString = "YOUR_AZURE_STORAGE_CONNECTION_STRING";
BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);

// Get a reference to a container
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient("my-sample-container");
containerClient.CreateIfNotExists(); // Create the container if it doesn't exist

// Get a reference to a blob
string blobName = "my-sample-blob.txt";
BlobClient blobClient = containerClient.GetBlobClient(blobName);

// Upload a file
using (var fileStream = File.OpenRead("path/to/your/local/file.txt"))
{
    blobClient.UploadAsync(fileStream, overwrite: true);
    Console.WriteLine($"Uploaded blob '{blobName}' to container '{containerClient.Name}'.");
}
        

Further Resources