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

  • DataSets, TableAdapters, and Transient Retry Logic For SqlAzureDataSets, TableAdapters, and Transient Retry Logic For SqlAzure The main project I’m working on these days is moving several web sites to Azure.  It is something I’ve wanted to be able to try for a while.  I’m working with several other agencies on this project...
  • Programming SEO – Tags and KeywordsProgramming SEO – Tags and Keywords Last week I started a series on SEO from a programming perspective.  Today we want to look at one of the topics I discussed in that post in a little more detail.  Tags. Strictly speakin...
  • ASP.NET Authentication – Multiple Domains w/ Same ApplicationASP.NET Authentication – Multiple Domains w/ Same Application In our series about ASP.NET authentication so far we’ve covered all the rather normal cases where you’d want to have the ability to log into different domains attached to the same application.&#...
  • ASP.NET Session Variables Not StickingASP.NET Session Variables Not Sticking I’ve stumbled across this problem twice in the last couple of months so I figure it is about time I blogged about it. The situation is that you have  a page on your web site that sets a sessi...
  • DotNetNuke Response.End() Doesn’t EndDotNetNuke Response.End() Doesn’t End OK.  This one is just plain annoying! For some reason that I’ve yet to be able to track down, Response.End() seems to have no impact at all under DotNetNuke. I tried various hacks.  Including...
  • Fren Dee Bee

    Thanks for sharing this solution. I’ve been wondering about this case sensitive issue before.

  • Ved

    Thanks for the great solution .