How to rename the container name in windows azure?
Asked Answered
C

5

20

Is there any way by which we can rename the blob container name in windows azure ?

Concubinage answered 11/9, 2012 at 13:18 Comment(1)
See https://mcmap.net/q/293618/-azure-storage-blob-renameGraveyard
C
24

UPDATE

Please see answer from Nuri Tasdemir below.


No. You can't rename a blob container in Windows Azure. What you could do is create a new blob container with the new name and copy blobs from old blob container to the new one. Once the blobs are copied, you can delete the old blob container. Please note that if you're doing the copy blob in Cloud, this operation is asynchronous. So ensure that the blobs are copied completely before deleting the blob container.

Corlisscorly answered 11/9, 2012 at 13:22 Comment(11)
It is now possible to do this with "Microsoft Azure Storage Explorer". Please see Nuri Tasdemir's answer.Shortening
@Shortening This is a tool feature and not a platform feature.Corlisscorly
It is a solution to the problem.Shortening
On that I agree with you :).Corlisscorly
@Ofer Zelig. I rolled back your edit. IMHO, if you are not happy with an answer, instead of editing it to something completely different, you can always cast vote or add your own answer.Costumier
@NuriTasdemir first time ever that I encounter this behavior in Stack Overflow. My edit was for the best of the Stack Overflow community. It is the most correct answer, and certainly doesn't send the wrong message to the reader of your accepted answer who will wrongfully conclude that there is no feasible option to do it and work hard. Editing this (accepted) answer is the right thing to do as it serves as the canonical answer one reads when they search for this matter.Imogen
@NuriTasdemir also, except for saying you rolled back my answer, you didn't say what's wrong with it. Yes, I did edit it but if you read my edit carefully you'll see that I was fair and covered the original scheme of your answer (which is right to some degree: the API doesn't let you do that. But there's absolutely an easy way to do it via a tool, and if the developer goes down the path of implementing it programatically, I left the caution you originally put there).Imogen
@OferZelig Sorry, I could not add a note to edit. I guess because it was a rollback, it has only the default description. Therefore I added the comment addressed to you. You mistook me as the owner of this answer. This is not my answer. My answer is the second one which mentions the tool. In your edit you are modifying the answer completely and while doing that you are using my answer.Costumier
@OferZelig I understand your point of view. You made the change in order to make the accepted answer more complete and true. However, if that was the way to go, IMHO there should be just one answer for each question. And everyone should cooperatively edit that answer. But it is not the case. It is not required that the accepted answer is the most complete one. A new answer may outperform an accepted answer over time. That's why we have upvotes and downvotes. And we have badges such as stackoverflow.com/help/badges/62/populist. IMHO this is the way SO works.Costumier
@NuriTasdemir correct, I mistook you as the owner of the answer. Now that I see that your answer is here below, I understand your motives of keeping this accepted answer as wrong. You want people to scroll down, find yours and upvote it. Which I find a bit awkward... because people who won't read through will be misled to think they can't accomplish this task at all. BTW I didn't copy from you. I think this debate is a matter for Meta: is it OK to keep a clearly wrong accepted answer for the sake of other answers to gain upvotes, rather than correcting the wrong answer.Imogen
@OferZelig... Interesting discussion! I have updated my answer and informed folks to look for Nuri's answer. Hope this helps.Corlisscorly
C
27

This answer is not valid any more. It seems they removed this feature from "Microsoft Azure Storage Explorer"


Now, you can rename containers with Microsoft's "Microsoft Azure Storage Explorer" (after version 0.8.3). You can also rename azure tables and file shares with this tool. See the release notes here.

Note that this feature has the following disclaimer during usage.

Renaming works by copying to the new name, then deleting the source item. Renaming a blob container currently loses the container's properties and metadata, and may take a while if there are lots of blobs.

Therefore this is not an actual renaming behind the scenes and incurs read/write/transaction costs.

Costumier answered 16/8, 2016 at 11:4 Comment(1)
I cannot confirm when the feature was removed, but as of January 16, 2023, this functionality is no longer supported by Azure Storage Explorer.Zanze
C
24

UPDATE

Please see answer from Nuri Tasdemir below.


No. You can't rename a blob container in Windows Azure. What you could do is create a new blob container with the new name and copy blobs from old blob container to the new one. Once the blobs are copied, you can delete the old blob container. Please note that if you're doing the copy blob in Cloud, this operation is asynchronous. So ensure that the blobs are copied completely before deleting the blob container.

Corlisscorly answered 11/9, 2012 at 13:22 Comment(11)
It is now possible to do this with "Microsoft Azure Storage Explorer". Please see Nuri Tasdemir's answer.Shortening
@Shortening This is a tool feature and not a platform feature.Corlisscorly
It is a solution to the problem.Shortening
On that I agree with you :).Corlisscorly
@Ofer Zelig. I rolled back your edit. IMHO, if you are not happy with an answer, instead of editing it to something completely different, you can always cast vote or add your own answer.Costumier
@NuriTasdemir first time ever that I encounter this behavior in Stack Overflow. My edit was for the best of the Stack Overflow community. It is the most correct answer, and certainly doesn't send the wrong message to the reader of your accepted answer who will wrongfully conclude that there is no feasible option to do it and work hard. Editing this (accepted) answer is the right thing to do as it serves as the canonical answer one reads when they search for this matter.Imogen
@NuriTasdemir also, except for saying you rolled back my answer, you didn't say what's wrong with it. Yes, I did edit it but if you read my edit carefully you'll see that I was fair and covered the original scheme of your answer (which is right to some degree: the API doesn't let you do that. But there's absolutely an easy way to do it via a tool, and if the developer goes down the path of implementing it programatically, I left the caution you originally put there).Imogen
@OferZelig Sorry, I could not add a note to edit. I guess because it was a rollback, it has only the default description. Therefore I added the comment addressed to you. You mistook me as the owner of this answer. This is not my answer. My answer is the second one which mentions the tool. In your edit you are modifying the answer completely and while doing that you are using my answer.Costumier
@OferZelig I understand your point of view. You made the change in order to make the accepted answer more complete and true. However, if that was the way to go, IMHO there should be just one answer for each question. And everyone should cooperatively edit that answer. But it is not the case. It is not required that the accepted answer is the most complete one. A new answer may outperform an accepted answer over time. That's why we have upvotes and downvotes. And we have badges such as stackoverflow.com/help/badges/62/populist. IMHO this is the way SO works.Costumier
@NuriTasdemir correct, I mistook you as the owner of the answer. Now that I see that your answer is here below, I understand your motives of keeping this accepted answer as wrong. You want people to scroll down, find yours and upvote it. Which I find a bit awkward... because people who won't read through will be misled to think they can't accomplish this task at all. BTW I didn't copy from you. I think this debate is a matter for Meta: is it OK to keep a clearly wrong accepted answer for the sake of other answers to gain upvotes, rather than correcting the wrong answer.Imogen
@OferZelig... Interesting discussion! I have updated my answer and informed folks to look for Nuri's answer. Hope this helps.Corlisscorly
I
5

I couldn't find the rename functionality in the storage explorer v1.15.1 but I did use the clone option to create a copy and delete the old container.

Screenshot Microsoft Azure Storage Explorer

Irenics answered 16/9, 2020 at 9:38 Comment(0)
H
1

No. You can't rename a blob container in Windows Azure.

Code to copy from the old storage to the new storage

AzCopy /Source:https://oldstorage.blob.core.windows.net/oldstorage /Dest:https://newstorage.blob.core.windows.net/newstorage /SourceKey:sourcekey /DestKey:destkey /S /XO

Has answered 14/11, 2018 at 4:15 Comment(0)
F
-4

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

  • album1/image1.jpg -> album2/image1.jpg
  • album1/image1.jpg -> album1/image2.jpg

HTH

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();
        }
    }
}
Farlee answered 3/10, 2013 at 13:17 Comment(2)
This method renames only foldersCornet
Also, I don't know if it's a good idea to delete the old blob while the cop operation is in progress. Just because you returned from StartCopyFromBlob doesn't mean the operation completed.Selfsupporting

© 2022 - 2024 — McMap. All rights reserved.