Azure CDN Blob Storage Case Sensitive Issue


If you’ve done any work with Azure Blob storage, you already know that Blob storage is case sensitive.  If you’ve hooked the Azure CDN to blob storage, it is also case sensitive.

You are probably reading this article because you’ve already run into this problem.

We ran into this problem when we were moving a site from an existing CDN to Azure.  The current site was on domain A and the resources hosted by the CDN were on domain B.  But the URLs to those resources were in various cases.  To make matters worse, there were multiple sites.  So it wasn’t a simple matter of just fixing up the case of one site.

So we were looking for some way to make the CDN case insensitive, which you can’t do, when I finally thought, “Why don’t we make it so that it doesn’t matter with a response filter?”  I’ve done this before when I needed to make global changes and it worked well.

Then I remembered, the URL Rewriting module for IIS7 does this for us.  And since this module is installed by default on Azure, all we needed to do was:

  • Make everything in blob storage lowercase
  • Install the redirect rules in web.config

Here is the web.config rules:

    <rule name="CSCAssets" preCondition="IsHtml"
      <match filterByTags="Img"
         pattern="http://(www\.)?domain\.com/(.*)" />
      <action type="Rewrite"
         value="{ToLower:{R:2}}" />
            <conditions logicalGrouping="MatchAny" />
      <preCondition name="IsHtml">
         <add input="{RESPONSE_CONTENT_TYPE}"
            pattern="^text/html" />

This will force any URL pointing to or to point to and force it all to lowercase on the way back to the client’s browser.

Related Post

2 Responses to “Azure CDN Blob Storage Case Sensitive Issue”

Leave a Reply

Comment Policy:

  • You must verify your comment by responding to the automated email that is sent to your email address. Unverified comments will never show.Leave a good comment that adds to the conversation and I'll leave your link in.
  • Leave me pure spam and I'll delete it.
  • Leave a general comment and I'll remove the link but keep the comment.

Notify me of followup comments via e-mail