Server Version: 2018-11-09
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 | Product documentation
Install the Azure Storage Blobs client library for .NET with NuGet:
Install-Package Azure.Storage.Blobs
Prerequisites: You must have an Azure subscription, and a Storage Account to use this package.
To create a Storage Account, you can use the Azure Portal, Azure PowerShell or Azure CLI:
Blob storage is designed for:
- Serving images or documents directly to a browser.
- Storing files for distributed access.
- Streaming video and audio.
- Writing to log files.
- Storing data for backup and restore, disaster recovery, and archiving.
- Storing data for analysis by an on-premises or Azure-hosted service.
string connectionString = <connection_string>;
var service = new BlobServiceClient(connectionString);
var container = service.GetBlobContainerClient("mycontainer");
await container.CreateAsync();
var blob = container.GetBlockBlobClient("myblob");
using (var data = File.OpenRead("Samples/SampleSource.txt"))
{
await blob.UploadAsync(data);
}
string connectionString = <connection_string>;
var service = new BlobServiceClient(connectionString);
var container = service.GetBlobContainerClient("mycontainer");
var blob = container.GetBlockBlobClient("myblob");
var download = await blob.DownloadAsync();
using (var file = File.Create("BlockDestination.txt"))
{
await download.Value.Content.CopyToAsync(file);
}
string connectionString = <connection_string>;
var service = new BlobServiceClient(connectionString);
var container = service.GetBlobContainerClient("mycontainer");
string marker;
do
{
var response = await container.ListBlobsFlatSegmentAsync(marker);
foreach (var blob in response.Value.BlobItems)
{
Console.WriteLine(blob.Name);
}
marker = response.Value.NextMarker;
}
while (!string.IsNullOrEmpty(marker));
All Blob service operations will throw a
StorageRequestFailedException on failure with
helpful ErrorCode
s.
Get started with our Blob samples.
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 https://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 [email protected] with any additional questions or comments.