c# Azure Cannot set the blob tier

I think the method is exactly what you need: CloudBlockBlob.SetStandardBlobTier. Maybe you were not checking the latest version of Azure Storage Client Library?


Is their any way to change the blob tier in code from hot to cold in C# with azure storage?

As ZhaoXing Lu mentioned that we could use CloudBlockBlob.SetStandardBlobTier.

Note: The operation is allowed on a page blob in a premium storage account and on a block blob in a blob storage account

The following code works correctly on my side. I use the library WindowsAzure.Storage 9.1.1

var cloudBlobClient = storageAccount.CreateCloudBlobClient();
var container = cloudBlobClient.GetContainerReference("container");
var blob = container.GetBlockBlobReference("blob name");
blob.SetStandardBlobTier(StandardBlobTier.Cool);
blob.FetchAttributes();
var tier = blob.Properties.StandardBlobTier;

enter image description here


Using Azure Blob storage client library v12 for .NET, replace myaccount with the name of your storage account, mycontainer with your container name and myblob with the blob name for which the tier is to be changed:

var sharedKeyCredential = new StorageSharedKeyCredential("myaccount", storageAccountKey);
var baseBlobContainerUrl = string.Format("{0}.blob.core.windows.net", "myaccount");
var blobServiceClient = new BlobServiceClient(new Uri($"https://{baseBlobContainerUrl}"), sharedKeyCredential);
var containerClient = blobServiceClient.GetBlobContainerClient("mycontainer");
BlobClient blobClient = containerClient.GetBlobClient("myblob");
// Set access tier to cool.
await blobClient.SetAccessTierAsync(AccessTier.Cool);

If you are working with Azure Gov, use this url insteadl "{0}.blob.core.usgovcloudapi.net"

Keep in mind, your storage account should support Cool Storage.