Azure Storage APIs for .NET

Overview

Read and write files, blob (object) data, key-value pairs, and messages from your .NET applications with Azure Storage.

To get started with Azure Storage, see Get started with Azure Blob storage using .NET.

Client library

Use connection strings to connect to an Azure Storage account, then use the client libraries' classes and methods to work with blob, table, file, or queue storage.

Install the NuGet package directly from the Visual Studio Package Manager console or with the .NET Core CLI.

Visual Studio Package Manager

Install-Package WindowsAzure.Storage

.NET Core CLI

dotnet add package WindowsAzure.Storage

Code Example

This example creates a new blob to a new container in an existing storage account.

/* Include these "using" directives...
using Microsoft.WindowsAzure.Storage;
using Microsoft.WindowsAzure.Storage.Blob;
*/

string storageConnectionString = "DefaultEndpointsProtocol=https;"
    + "AccountName=[Storage Account Name]"
    + ";AccountKey=[Storage Account Key]"
    + ";EndpointSuffix=core.windows.net";

CloudStorageAccount account = CloudStorageAccount.Parse(storageConnectionString);
CloudBlobClient serviceClient = account.CreateCloudBlobClient();

// Create container. Name must be lower case.
Console.WriteLine("Creating container...");
var container = serviceClient.GetContainerReference("mycontainer");
container.CreateIfNotExistsAsync().Wait();

// write a blob to the container
CloudBlockBlob blob = container.GetBlockBlobReference("helloworld.txt");
blob.UploadTextAsync("Hello, World!").Wait();

Management APIs

Create and manage Azure Storage accounts and connection keys with the management API.

Install the NuGet package directly from the Visual Studio Package Manager console or with the .NET Core CLI.

Visual Studio package manager

Install-Package Microsoft.Azure.Management.Storage.Fluent

.NET Core CLI

dotnet add package Microsoft.Azure.Management.Storage.Fluent

Code Example

This example creates a storage account.

/* Include this "using" directive...
using Microsoft.Azure.Management.Storage.Fluent
*/

IStorageAccount storage = azure.StorageAccounts.Define(storageAccountName)
    .WithRegion(Region.USEast)
    .WithNewResourceGroup(rgName)
    .Create();

Samples

View the complete list of Azure Storage samples.