title: Invalid character exception when adding Metadata to a CloudBlob
body: <h2>Task</h2>
  <p>Upload a file to <code>Azure Blob Storage</code> with the original filename and also assign the filename as <code>meta-data</code> to the <code>CloudBlob</code></p>
  <h2>Problem</h2>
  <p>These characters are not permitted in the <code>meta-data</code> but are acceptable as the <code>blob</code> name:</p>
  <pre><code>š Š ñ Ñ ç Ç ÿ Ÿ ž Ž Ð œ Œ « » éèëêð ÉÈËÊ àâä ÀÁÂÃÄÅ àáâãäå ÙÚÛÜ ùúûüµ òóôõöø ÒÓÔÕÖØ ìíîï ÌÍÎÏ
  </code></pre>
  <h2>Question</h2>
  <ul>
  <li>Is there a way to store these characters in the <code>meta-data</code>? Are we missing some setting that causes this exception?</li>
  <li>Most of these characters are standard glyphs in some languages, so how to handle that?</li>
  <li>Is there any documentation available that advises about this issue? I found <code>blob</code> and <code>meta-data</code> naming conventions, but none about the data itself!</li>
  </ul>
  <h2>Code</h2>
  <pre><code>var dirtyFileName      = file.FileName;
  var normalizedFileName = file.FileName.CleanOffDiacriticAndNonASCII();
  
  // Blob name accepts almost characters that are acceptable as filenames in Windows
  var blob = container.GetBlobReference(dirtyFileName);
  
  //Upload content to the blob, which will create the blob if it does not already exist.
  blob.Metadata[&quot;FileName&quot;] = normalizedFileName;
  blob.Attributes.Properties.ContentType = file.ContentType;
  
  // ERROR: Occurs here!
  blob.UploadFromStream(file.InputStream);
  
  blob.SetMetadata();
  blob.SetProperties();
  </code></pre>
  <h2>Error</h2>
  <p><a href="https://i.stack.imgur.com/qdlBm.png" rel="noreferrer"><img src="https://i.stack.imgur.com/qdlBm.png" alt="Exception" /></a></p>
  <h2>References</h2>
  <ul>
  <li><a href="http://msdn.microsoft.com/en-us/library/dd135715.aspx" rel="noreferrer">Naming and Referencing Containers, Blobs, and Metadata</a></li>
  <li><a href="https://stackoverflow.com/questions/8968585/how-to-support-other-languages-in-azure-blob-storage">How to support other languages in Azure blob storage?</a></li>
  <li><a href="https://stackoverflow.com/questions/249087/how-do-i-remove-diacritics-accents-from-a-string-in-net">How do I remove diacritics (accents) from a string in .NET?</a></li>
  <li><a href="https://stackoverflow.com/questions/6884073/azure-cloudblob-setmetadata-fails-with-the-metadata-specified-is-invalid-it-ha">Azure CloudBlob SetMetadata fails with &quot;The metadata specified is invalid. It has characters that are not permitted.&quot;</a></li>
  <li><a href="https://stackoverflow.com/questions/5459641/replacing-characters-in-c-sharp-ascii/13154805#13154805">Replacing characters in C# (ascii)</a></li>
  </ul>
  <hr />
  <h2>Workarounds</h2>
  <p>Illegal characters in filename is only the tip of the ice-berg, magnified only for the purpose of this question! The bigger picture is that we index these files using <a href="http://lucene.apache.org/core/" rel="noreferrer"><code>Lucene.net</code></a> and as such need a lot of <code>meta-data</code> to be stored on the <code>blob</code>. <em>Please don't suggest storing it all separately in a database, just don't!</em> Up until now we have been lucky to only have come across one file with diacritic characters!</p>
  <p>So, at the moment we are making the effort to avoid saving the filename in the <code>meta-data</code> as a workaround!</p>