Is there any way by which we can rename the blob container name in windows azure ?
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
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.
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.
This RenameBlob method will allow you to rename folders or files in an Azure container.
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();
}
}
}
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.