Is there any way by which we can rename the blob container name in windows azure ?
5 Answers
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.
-
1I cannot confirm when the feature was removed, but as of January 16, 2023, this functionality is no longer supported by Azure Storage Explorer.– CrayonsJan 16 at 5:45
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.
-
6It is now possible to do this with "Microsoft Azure Storage Explorer". Please see Nuri Tasdemir's answer.– tmuttonMar 6, 2017 at 10:43
-
2
-
5
-
2@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. Nov 12, 2018 at 3:52
-
3@OferZelig... Interesting discussion! I have updated my answer and informed folks to look for Nuri's answer. Hope this helps. Nov 13, 2018 at 5:38
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.
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
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();
}
}
}
-
-
2Also, 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. Mar 8, 2016 at 8:46