HI All,
We have requirement in Azure Data Lake Gen2 to Change file tier from Hot to cool or Hot to Archive using C#
based on file name.
For Example- we have a file name "test.csv" - tier - hot, how can we move this file in cool tier using C#
thanks
HI All,
We have requirement in Azure Data Lake Gen2 to Change file tier from Hot to cool or Hot to Archive using C#
based on file name.
For Example- we have a file name "test.csv" - tier - hot, how can we move this file in cool tier using C#
thanks
Thanks for using Microsoft Q&A!!
If I understand you correctly you want to change the tier of any specific file stored as a blob on Azure Data Lake Gen2 storage.
In order to work with blob files stored on Azure Data Lake Storage Gen2, you need to use Azure Blob Storage .NET package as documented over here and changing the tier of any blob stored on a container require you to use SetAccessTier/SetAccessTierAsync method of BlobClient or BlockBlobClient based on your blob type. Please see the below code which you can use to change the tier -
string containerName = "input";
string connectionString = $"DefaultEndpointsProtocol=https;AccountName={Account Name};AccountKey={Access Key};EndpointSuffix=core.windows.net";
BlobServiceClient blobServiceClient = new BlobServiceClient(connectionString);
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient(containerName);
BlobClient bc = containerClient.GetBlobClient("movies.csv");
var result = await bc.SetAccessTierAsync(AccessTier.Cool);
Here, you can get the Connection String from Access Keys blade of Storage account.
Additional documentation to know more about setting blobs tier is available at Setting or changing a blob's tier.
Please let me know if you have any questions.
Thanks
Saurabh
Please do not forget to "Accept the answer" wherever the information provided helps you to help others in the community.
Hi @manishverma-7371,
Please let me know if you find above reply useful. If yes, please 'Accept the answer' for the above reply. This will help other community members facing similar query to refer to this solution. Thanks.
Thanks
Saurabh
Thanks a lot for your replay. we will test and update you
I have not heard back from you. Did my answer solve your issue? If so, please mark as accepted answer. If not, please let me know how I may better assist.
Thanks
Saurabh
24 people are following this question.