IMollov
IMollov

Reputation: 301

How to rename file/directory (not Blob file) in Azure Storage (not Blob storage)?

I thought that this would be very easy job to do, but as I have researched, I found nothing on how to rename a file or directory in Azure Storage.

I don't want to do a copy/delete (the size of files/directories is very large), I just want to change the name of a given file/directory programmatically through C#.

Edit: I'm talking about CloudFile/CloudFileDirectory objects.

Can someone help me?

Upvotes: 16

Views: 35067

Answers (3)

Alex Klaus
Alex Klaus

Reputation: 8954

A straightforward solution through the SDK won't work. The renaming functionality isn't supported on the REST API, so all the wrappers (Azure CLI, SDK, etc.) don't have it. The Azure Storage Explorer tool can "rename" but under the hood it clones folders/files rather than renaming (again, it's working via API)

The Wailing Wall on the Azure Feedback portal is here, please upvote:

FileShare mapping

Though, if you have some flexibility, you can mount an Azure File Share with SMB on Windows, Linux, or macOS. It does true renaming over SM. And for your app it would be just normal disk I/O operations.

Upvotes: 1

Vijai
Vijai

Reputation: 2507

If you want to rename an Azure blob folder manually you can download the Azure Storage Explorer tool given below, connect to your blob storage and you can rename the blob folders, you can clone the blob files also.

Azure storage explorer tool

Upvotes: 0

Martin Brandl
Martin Brandl

Reputation: 59001

You talk about Azure Files. Similar to Azure Blob Storage, there is no rename / move feature thus you have to copy the file (e. g. using StartCopyAsync) and then delete it using the CloudFile.DeleteAsync method.

I wrote a blog article about how to Rename Azure Storage Blob using PowerShell (same probably applies to Azure Files)

Upvotes: 9

Related Questions