![]() |
VOOZH | about |
dotnet add package Azure.Storage.Blobs --version 12.29.0
NuGet\Install-Package Azure.Storage.Blobs -Version 12.29.0
<PackageReference Include="Azure.Storage.Blobs" Version="12.29.0" />
<PackageVersion Include="Azure.Storage.Blobs" Version="12.29.0" />Directory.Packages.props
<PackageReference Include="Azure.Storage.Blobs" />Project file
paket add Azure.Storage.Blobs --version 12.29.0
#r "nuget: Azure.Storage.Blobs, 12.29.0"
#:package Azure.Storage.Blobs@12.29.0
#addin nuget:?package=Azure.Storage.Blobs&version=12.29.0Install as a Cake Addin
#tool nuget:?package=Azure.Storage.Blobs&version=12.29.0Install as a Cake Tool
Server Version: 2021-02-12, 2020-12-06, 2020-10-02, 2020-08-04, 2020-06-12, 2020-04-08, 2020-02-10, 2019-12-12, 2019-07-07, and 2019-02-02
Azure Blob storage is Microsoft's object storage solution for the cloud. Blob storage is optimized for storing massive amounts of unstructured data. Unstructured data is data that does not adhere to a particular data model or definition, such as text or binary data.
Source code | Package (NuGet) | API reference documentation | REST API documentation | Product documentation
Install the Azure Storage Blobs client library for .NET with NuGet:
dotnet add package Azure.Storage.Blobs
You need an Azure subscription and a Storage Account to use this package.
To create a new Storage Account, you can use the Azure Portal, Azure PowerShell, or the Azure CLI. Here's an example using the Azure CLI:
az storage account create --name MyStorageAccount --resource-group MyResourceGroup --location westus --sku Standard_LRS
In order to interact with the Azure Blobs Storage service, you'll need to create an instance of the BlobServiceClient class. The Azure Identity library makes it easy to add Azure Active Directory support for authenticating Azure SDK clients with their corresponding Azure services.
// Create a BlobServiceClient that will authenticate through Active Directory
Uri accountUri = new Uri("https://MYSTORAGEACCOUNT.blob.core.windows.net/");
BlobServiceClient client = new BlobServiceClient(accountUri, new DefaultAzureCredential());
Learn more about enabling Azure Active Directory for authentication with Azure Storage in our documentation and our samples.
Blob storage is designed for:
Blob storage offers three types of resources:
BlobServiceClientBlobContainerClientBlobClientLearn more about options for authentication (including Connection Strings, Shared Key, Shared Key Signatures, Active Directory, and anonymous public access) in our samples.
We guarantee that all client instance methods are thread-safe and independent of each other (guideline). This ensures that the recommendation of reusing client instances is always safe, even across threads.
Client options | Accessing the response | Long-running operations | Handling failures | Diagnostics | Mocking | Client lifetime
// Get a connection string to our Azure Storage account. You can
// obtain your connection string from the Azure Portal (click
// Access Keys under Settings in the Portal Storage account blade)
// or using the Azure CLI with:
//
// az storage account show-connection-string --name <account_name> --resource-group <resource_group>
//
// And you can provide the connection string to your application
// using an environment variable.
string connectionString = "<connection_string>";
string containerName = "sample-container";
string blobName = "sample-blob";
string filePath = "sample-file";
// Get a reference to a container named "sample-container" and then create it
BlobContainerClient container = new BlobContainerClient(connectionString, containerName);
container.Create();
// Get a reference to a blob named "sample-file" in a container named "sample-container"
BlobClient blob = container.GetBlobClient(blobName);
// Upload local file
blob.Upload(filePath);
// Get a temporary path on disk where we can download the file
string downloadPath = "hello.jpg";
// Download the public MacBeth copy at https://www.gutenberg.org/cache/epub/1533/pg1533.txt
new BlobClient(new Uri("https://www.gutenberg.org/cache/epub/1533/pg1533.txt")).DownloadTo(downloadPath);
// Get a connection string to our Azure Storage account.
string connectionString = "<connection_string>";
string containerName = "sample-container";
string filePath = "hello.jpg";
// Get a reference to a container named "sample-container" and then create it
BlobContainerClient container = new BlobContainerClient(connectionString, containerName);
container.Create();
// Upload a few blobs so we have something to list
container.UploadBlob("first", File.OpenRead(filePath));
container.UploadBlob("second", File.OpenRead(filePath));
container.UploadBlob("third", File.OpenRead(filePath));
// Print out all the blob names
foreach (BlobItem blob in container.GetBlobs())
{
Console.WriteLine(blob.Name);
}
We fully support both synchronous and asynchronous APIs.
// Get a temporary path on disk where we can download the file
string downloadPath = "hello.jpg";
// Download the public MacBeth copy at https://www.gutenberg.org/cache/epub/1533/pg1533.txt
await new BlobClient(new Uri("https://www.gutenberg.org/cache/epub/1533/pg1533.txt")).DownloadToAsync(downloadPath);
All Blob service operations will throw a
RequestFailedException on failure with
helpful ErrorCodes. Many of these errors are recoverable.
If multiple failures occur, an AggregateException will be thrown,
containing each failure instance.
// Get a connection string to our Azure Storage account.
string connectionString = "<connection_string>";
string containerName = "sample-container";
// Try to delete a container named "sample-container" and avoid any potential race conditions
// that might arise by checking if the container is already deleted or is in the process
// of being deleted.
BlobContainerClient container = new BlobContainerClient(connectionString, containerName);
try
{
container.Delete();
}
catch (RequestFailedException ex)
when (ex.ErrorCode == BlobErrorCode.ContainerBeingDeleted ||
ex.ErrorCode == BlobErrorCode.ContainerNotFound)
{
// Ignore any errors if the container being deleted or if it has already been deleted
}
Get started with our Blob samples:
For more advanced scenarios like transferring blob virtual directories, we recommend looking into our Azure.Storage.DataMovement and Azure.Storage.DataMovement.Blob packages. Get started with our DataMovement Blob Samples.
Upload a local directory to the root of the BlobContainerClient.
TransferOperation transfer = await container.UploadDirectoryAsync(WaitUntil.Started, localPath);
await transfer.WaitForCompletionAsync();
Upload a local directory to a virtual blob directory in the BlobContainerClient by specifying a directory prefix
TransferOperation transfer = await container.UploadDirectoryAsync(WaitUntil.Started, localPath, blobDirectoryPrefix);
await transfer.WaitForCompletionAsync();
Upload a local directory to a virtual blob directory in the BlobContainerClient specifying more advanced options
BlobContainerClientTransferOptions options = new BlobContainerClientTransferOptions
{
BlobContainerOptions = new BlobStorageResourceContainerOptions
{
BlobPrefix = blobDirectoryPrefix
},
TransferOptions = new TransferOptions()
{
CreationMode = StorageResourceCreationMode.OverwriteIfExists,
}
};
TransferOperation transfer = await container.UploadDirectoryAsync(WaitUntil.Started, localPath, options);
await transfer.WaitForCompletionAsync();
Download the entire BlobContainerClient to a local directory
TransferOperation transfer = await container.DownloadToDirectoryAsync(WaitUntil.Started, localDirectoryPath);
await transfer.WaitForCompletionAsync();
Download a virtual blob directory in the BlobContainerClient by specifying a directory prefix
TransferOperation transfer = await container.DownloadToDirectoryAsync(WaitUntil.Started, localDirectoryPath2, blobDirectoryPrefix);
await transfer.WaitForCompletionAsync();
Download from the BlobContainerClient specifying more advanced options
BlobContainerClientTransferOptions options = new BlobContainerClientTransferOptions
{
BlobContainerOptions = new BlobStorageResourceContainerOptions
{
BlobPrefix = blobDirectoryPrefix
},
TransferOptions = new TransferOptions()
{
CreationMode = StorageResourceCreationMode.OverwriteIfExists,
}
};
TransferOperation transfer = await container.DownloadToDirectoryAsync(WaitUntil.Started, localDirectoryPath2, options);
await transfer.WaitForCompletionAsync();
See the Storage CONTRIBUTING.md for details on building, testing, and contributing to this library.
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit cla.microsoft.com.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact with any additional questions or comments.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 is compatible. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 5 NuGet packages that depend on Azure.Storage.Blobs:
| Package | Downloads |
|---|---|
|
Microsoft.Azure.WebJobs.Host.Storage
This package contains Azure Storage based implementations of some WebJobs SDK component interfaces. For more information, please visit https://go.microsoft.com/fwlink/?linkid=2279708. |
|
|
Microsoft.PowerBI.Api
.NET Client library for Microsoft Power BI public REST endpoints providing access to your Workspaces, Reports, Datasets and more. |
|
|
Azure.Extensions.AspNetCore.DataProtection.Blobs
Microsoft Azure Blob storage support as key store (https://docs.microsoft.com/aspnet/core/security/data-protection/implementation/key-storage-providers). |
|
|
Microsoft.Azure.DurableTask.AzureStorage
Azure Storage provider extension for the Durable Task Framework. |
|
|
Snowflake.Data
Snowflake Connector for .NET |
Showing the top 20 popular GitHub repositories that depend on Azure.Storage.Blobs:
| Repository | Stars |
|---|---|
|
bitwarden/server
Bitwarden infrastructure/backend (API, database, Docker, etc).
|
|
|
duplicati/duplicati
Store securely encrypted backups in the cloud!
|
|
|
abpframework/abp
Open-source web application framework for ASP.NET Core! Offers an opinionated architecture to build enterprise software solutions with best practices on top of the .NET. Provides the fundamental infrastructure, cross-cutting-concern implementations, startup templates, application modules, UI themes, tooling and documentation.
|
|
|
dotnet/AspNetCore.Docs
Documentation for ASP.NET Core
|
|
|
aspnetboilerplate/aspnetboilerplate
ASP.NET Boilerplate - Web Application Framework
|
|
|
microsoft/garnet
Garnet is a remote cache-store from Microsoft Research that offers strong performance (throughput and latency), scalability, storage, recovery, cluster sharding, key migration, and replication features. Garnet can work with existing Redis clients.
|
|
|
dotnet/orleans
Cloud Native application framework for .NET
|
|
|
nopSolutions/nopCommerce
ASP.NET Core eCommerce software. nopCommerce is a free and open-source shopping cart.
|
|
|
OrchardCMS/OrchardCore
Orchard Core is an open-source modular and multi-tenant application framework built with ASP.NET Core, and a content management system (CMS) built on top of that framework.
|
|
|
MassTransit/MassTransit
Distributed Application Framework for .NET
|
|
|
microsoft/FASTER
Fast persistent recoverable log and key-value store + cache, in C# and C++.
|
|
|
microsoft/aspire
Aspire is the tool for code-first, extensible, observable dev and deploy.
|
|
|
actions/runner
The Runner for GitHub Actions :rocket:
|
|
|
danielgerlag/workflow-core
Lightweight workflow engine for .NET Standard
|
|
|
kurrent-io/KurrentDB
KurrentDB is a database that's engineered for modern software applications and event-driven architectures. Its event-native design simplifies data modeling and preserves data integrity while the integrated streaming engine solves distributed messaging challenges and ensures data consistency.
|
|
|
ChilliCream/graphql-platform
Welcome to the home of the Hot Chocolate GraphQL server for .NET, the Strawberry Shake GraphQL client for .NET and Nitro the awesome Monaco based GraphQL IDE.
|
|
|
ServiceStack/ServiceStack
Thoughtfully architected, obscenely fast, thoroughly enjoyable web services for all
|
|
|
Azure/azure-powershell
Microsoft Azure PowerShell
|
|
|
simplcommerce/SimplCommerce
A simple, cross platform, modulith ecommerce system built on .NET
|
|
|
Xabaril/AspNetCore.Diagnostics.HealthChecks
Enterprise HealthChecks for ASP.NET Core Diagnostics Package
|
| Version | Downloads | Last Updated |
|---|---|---|
| 12.29.0 | 624,844 | 6/4/2026 |
| 12.29.0-beta.1 | 21,974 | 3/24/2026 |
| 12.28.0 | 2,173,976 | 5/13/2026 |
| 12.28.0-beta.1 | 39,900 | 1/20/2026 |
| 12.27.0 | 18,943,715 | 1/8/2026 |
| 12.27.0-beta.1 | 50,270 | 11/17/2025 |
| 12.26.0 | 21,877,027 | 10/13/2025 |
| 12.26.0-beta.1 | 279,009 | 6/9/2025 |
| 12.25.1 | 3,946,301 | 9/24/2025 |
| 12.25.0 | 17,144,616 | 7/15/2025 |
| 12.25.0-beta.1 | 68,834 | 5/6/2025 |
| 12.24.1 | 11,837,082 | 6/10/2025 |
| 12.24.0 | 30,088,473 | 3/11/2025 |
| 12.24.0-beta.1 | 137,685 | 2/11/2025 |
| 12.23.0 | 47,904,417 | 11/12/2024 |
| 12.23.0-beta.2 | 51,319 | 10/10/2024 |
| 12.23.0-beta.1 | 6,247 | 10/8/2024 |
| 12.22.2 | 16,250,753 | 10/11/2024 |
| 12.22.1 | 7,781,653 | 9/25/2024 |
| 12.22.0 | 3,574,876 | 9/19/2024 |