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 11, 2018 in Azure by null_void
• 3,220 points
11,304 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. 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();

Hope this helps!!

If you need to know more about Azure, then you should join Microsoft Azure certification course today.

Thank you!!

answered May 11, 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:)

Yes blob file can be ranamed  you can always use Clone with New Name feature in Azure storage explorer to rename any blob

explained here follow https://github.com/microsoft/AzureStorageExplorer/issues/2440

image

Unfortunately these classes are retired in Java Blob SDK v12.

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
2,379 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
• 58,020 points
14,011 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
1,195 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
8,029 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 11, 2018 in Azure by null_void
• 3,220 points
4,281 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 14, 2018 in Azure by null_void
• 3,220 points
19,590 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, 2019 in Azure by Prerna
• 1,960 points
7,398 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
3,601 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
1,602 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP