Can I rename a Azure Storage Blob?

+1 vote
Can one possibly rename a Storage Blob by using the Azure Storage API from a Web Role? For now, the only solution I have come across is to copy the blob to a new blob with the correct name and delete the old one. Can someone let me know there's any other way?

Thanks in advance!
May 10, 2018 in Azure by null_void
• 3,220 points
831 views

1 answer to this question.

+3 votes
Best answer

Though the approach I'm about to share is quite old, still it standsout among other ways, as it is easy and automative. The blog http://dotnetfriendly.blogspot.com/2012/01/how-to-rename-blob-on-azure.html will  show you a very quick method to rename blobs which are uploaded. Following is the set of cmdlets which are perform the required "rename" functionality:

//set the azure container
string blobContainer = "myContainer";
//azure connection string
string dataCenterSettingKey = string.Format("DefaultEndpointsProtocol=https;AccountName={0};AccountKey={1}", "xxxx",
                                            "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx");
//setup the container object
CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(dataCenterSettingKey);
CloudBlobClient blobClient = cloudStorageAccount.CreateCloudBlobClient();
CloudBlobContainer container = blobClient.GetContainerReference(blobContainer);

// Set permissions on the container.
BlobContainerPermissions permissions = new BlobContainerPermissions();
permissions.PublicAccess = BlobContainerPublicAccessType.Blob;
container.SetPermissions(permissions);

//grab the blob
CloudBlob existBlob = container.GetBlobReference("myBlobName");
CloudBlob newBlob = container.GetBlobReference("myNewBlobName");
//create a new blob
newBlob.CopyFromBlob(existBlob);
//delete the old
existBlob.Delete();

answered May 10, 2018 by club_seesharp
• 3,450 points

selected Aug 3, 2018 by Priyaj
Thanks a ton. It was helpful!
I had the same issue..this works for me though:)

Related Questions In Azure

0 votes
4 answers

How can I rename a SQL Azure database?

This command serves the purpose ALTER DATABASE [oldname] ...READ MORE

answered Nov 30, 2018 in Azure by Abhinav
365 views
0 votes
2 answers

How can I download a .vhd image to my local machine from azure and upload the same to a different azure account?

From the Windows Azure Portal you can ...READ MORE

answered Aug 20, 2018 in Azure by Priyaj
• 56,520 points
2,217 views
0 votes
1 answer

How can I copy SQL Azure database to a local development server?

There are certain ways to do this: Using SSIS ...READ MORE

answered Jun 26, 2018 in Azure by null_void
• 3,220 points
65 views
+1 vote
1 answer

Can I have a shared drive between Azure Virtual Machines?

In Azure Resource Manager "Storage Account" you ...READ MORE

answered Jul 26, 2018 in Azure by cloudie_crank
• 1,610 points
1,202 views
0 votes
1 answer

How can I use “Azure File Storage” with Web App Service?

If you're looking for mapping a drive ...READ MORE

answered Aug 10, 2018 in Azure by null_void
• 3,220 points
1,187 views
0 votes
1 answer

How can we load a list of Azure blob files recursively?

Actually, there's a simpler way to do ...READ MORE

answered Aug 13, 2018 in Azure by null_void
• 3,220 points
2,116 views
0 votes
1 answer
0 votes
1 answer

How do I stream videos from Azure Blob Storage?

What you are missing is a Shared Access ...READ MORE

answered Apr 25 in Azure by Prerna
• 1,940 points
334 views
0 votes
1 answer

How can i upload to Azure Blob storage with Shared Access key?

For GetBlobReferenceFromServer to work, the blob must be present ...READ MORE

answered Jun 12, 2018 in Azure by club_seesharp
• 3,450 points
770 views
0 votes
1 answer

How to upload a file on to Azure Blob storage without writing a code?

You can find the below tools useful ...READ MORE

answered Apr 13, 2018 in Azure by club_seesharp
• 3,450 points
131 views