How to rename container name in azure windows?

Is there a way in which we can rename the blob container name to windows azure?

+4
source share
4 answers

No. You cannot rename a blob container in Windows Azure. You can create a new container with a new name and copy the drops from the old blob container to the new one. Once the drops are copied, you can delete the old blob container. Please note that if you make a copy of blob in Cloud, this operation is asynchronous. Therefore, make sure that the drops are fully copied before removing the blob container.

+9
source

Now you can rename containers with Microsoft "Microsoft Azure Storage Explorer" (after version 0.8.3). You can also rename azure tables and shared folders with this tool. See release notes here .

Please note that during use this function has the following disclaimer.

Renaming is done by copying to the new name and then deleting the source element. Renaming a blob container is currently losing container properties and metadata, and it may take some time if there are many blocks.

Therefore, this is not actual renaming behind the scenes, but the cost of reading / writing / transaction.

+6
source

This RenameBlob method will allow you to rename folders or files in the Azure container.

  • album1 / image1.jpg → album2 /image1.jpg
  • album1 / image1.jpg → album1 / image2.jpg

NTN

public class AzureStorageService { readonly CloudStorageAccount _storageAccount = CloudStorageAccount.Parse(ConfigurationManager.ConnectionStrings["StorageConnectionString"].ConnectionString); public void RenameBlob(string oldName, string newName) { var blobClient = _storageAccount.CreateCloudBlobClient(); var container = blobClient.GetContainerReference("MyContainer"); var blobs = container.GetDirectoryReference(oldName).ListBlobs(); foreach (var item in blobs) { string blobUri = item.Uri.ToString(); var oldBlob = container.GetBlockBlobReference(blobUri); var newBlob = container.GetBlockBlobReference(blobUri.Replace(oldName, newName)); newBlob.StartCopyFromBlob(oldBlob); oldBlob.Delete(); } } } 
0
source

Check out the listing container . You can list all the drops and easily copy them into a new container.

There is also more useful material.

-1
source

Source: https://habr.com/ru/post/1433582/


All Articles