Explore practical examples for interacting with Azure Storage services.
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.
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.
Learn how to upload files to a blob container and download them back to your local machine using the BlobServiceClient.
C# View SampleDiscover how to create, list, and delete blob containers within your storage account.
C# View SampleUnderstand how to set and retrieve metadata and system properties for your blobs.
C# View SampleAzure 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.
Demonstrates sending messages to a queue and dequeuing them for processing.
C# View SampleExamples for creating, listing, and clearing queues.
C# View SampleAzure 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.
Shows how to insert new entities and query existing ones based on partition and row keys.
C# View SampleLearn to update existing entities or insert new ones (upsert) and how to delete entities.
C# View SampleTo run these samples, you will need:
dotnet add package Azure.Storage.Blobs
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}'.");
}