Search code examples
escapingazure-blob-storageazcopy

azcopy metadata with a value that has a semicolon


This is probably a simple question but for some reason I can't find the answer I'm trying to upload a file to our blob storage and in the process setting the metadata properly for reading it afterwards.

So currently I have the following command:
azcopy copy "<local file path>" "<blob file path>?<sas token>" --metadata "demo=2;5"
this doesn't work and it's because of the semicolon
azcopy copy "<local file path>" "<blob file path>?<sas token>" --metadata "demo=25"
this however works but beats the purpose of what I want to achieve.


Solution

  • I don't think it is possible. I looked up the source code for azcopy and it is using ; as the delimiter to separate multiple metadata key/value pairs.

    metadataString := string(dstData.Metadata[:dstData.MetadataLength])
    jpm.metadata = common.Metadata{}
    if len(metadataString) > 0 {
        for _, keyAndValue := range strings.Split(metadataString, ";") { // key/value pairs are separated by ';'
            kv := strings.Split(keyAndValue, "=") // key/value are separated by '='
            jpm.metadata[kv[0]] = kv[1]
        }
    }
    

    You may want to open up an issue here: https://github.com/Azure/azure-storage-azcopy/issues and let the team know about the problem.