none
metadata : can I update an existing metadata entry or add an existing metadata entry?

    Question

  • hi there,

    I'm new to Azure and writing a DLL to allow a couple of applications to use Azure Storage for file(s)

    My questions:

    (1) I notice on uploads, you can add Metadata to the blob.   I want to add another Metadata entry to an existing blob?  I notice if I use the "blob.Metadata["mynewMD"]=value will wipe out all the existing Metadata entries and add this new only.

    I can write something to retrieve the list of metadata entries and readd them but I would like to see if I can do a straight add.

    (2) I would like to edit the value of Metadata that already exists on the blob.  Can somebody show some sample code on how to change the value of existing Metadata?  Again, i could write something that would get all the metadata values and modify it that way but I would like to see if there is alreayd a method that would edit the existing value of a metadata entry.

    (3) finally....can I delete a metadata entry on an existing blob?

     

    Thanks in advance for your response.

     

    Friday, April 22, 2011 9:59 PM

Answers

  • Hi,

    (1) I notice on uploads, you can add Metadata to the blob.   I want to add another Metadata entry to an existing blob?  I notice if I use the "blob.Metadata["mynewMD"]=value will wipe out all the existing Metadata entries and add this new only.

    I can write something to retrieve the list of metadata entries and readd them but I would like to see if I can do a straight add.

    This is correct. So to add additional metadata, first you'll need to fetch existing metadata and then add a new entry to that and save it using SetMetadata() function (http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storageclient.cloudblob.setmetadata.aspx).

    (2) I would like to edit the value of Metadata that already exists on the blob.  Can somebody show some sample code on how to change the value of existing Metadata?  Again, i could write something that would get all the metadata values and modify it that way but I would like to see if there is alreayd a method that would edit the existing value of a metadata entry.

    Again you would need to get the metadata first. Find the metadata name and update it's value and save it using SetMetadata() function.

    (3) finally....can I delete a metadata entry on an existing blob?

    To delete a single metadata name/value pair is similar to updating a metadata entry (similar to #2 above). What you would do is fetch the existing metadata, remove the desired item from the collection and save it back using SetMetadata() function.

    Hope this helps.

    Thanks

    Gaurav Mantri

    Cerebrata Software

    http://www.cerebrata.com

     

    • Marked as answer by clay28 Saturday, April 23, 2011 3:16 AM
    Saturday, April 23, 2011 2:33 AM

All replies

  • Hi,

    (1) I notice on uploads, you can add Metadata to the blob.   I want to add another Metadata entry to an existing blob?  I notice if I use the "blob.Metadata["mynewMD"]=value will wipe out all the existing Metadata entries and add this new only.

    I can write something to retrieve the list of metadata entries and readd them but I would like to see if I can do a straight add.

    This is correct. So to add additional metadata, first you'll need to fetch existing metadata and then add a new entry to that and save it using SetMetadata() function (http://msdn.microsoft.com/en-us/library/microsoft.windowsazure.storageclient.cloudblob.setmetadata.aspx).

    (2) I would like to edit the value of Metadata that already exists on the blob.  Can somebody show some sample code on how to change the value of existing Metadata?  Again, i could write something that would get all the metadata values and modify it that way but I would like to see if there is alreayd a method that would edit the existing value of a metadata entry.

    Again you would need to get the metadata first. Find the metadata name and update it's value and save it using SetMetadata() function.

    (3) finally....can I delete a metadata entry on an existing blob?

    To delete a single metadata name/value pair is similar to updating a metadata entry (similar to #2 above). What you would do is fetch the existing metadata, remove the desired item from the collection and save it back using SetMetadata() function.

    Hope this helps.

    Thanks

    Gaurav Mantri

    Cerebrata Software

    http://www.cerebrata.com

     

    • Marked as answer by clay28 Saturday, April 23, 2011 3:16 AM
    Saturday, April 23, 2011 2:33 AM
  • thanks for the quick response.  that answers my questions...

     

    Saturday, April 23, 2011 3:17 AM
  • Hi,

    You're welcome. I just wanted to mention one more thing: If you're planning on writing your own tool (outside of your code), then please take a look at tools available which will do this for you for example our Cloud Storage Studio (http://www.cerebrata.com/Products/CloudStorageStudio) or CloudXplorer from Clumsyleaf (http://clumsyleaf.com). Both of these tools provide a nice GUI for manipulating blob metadata. There are other tools available as well but I am not sure if all of them have this capability.

    Hope this helps.

    Thanks

    Gaurav

    Saturday, April 23, 2011 4:29 AM