title: Azure, best way to store and deploy static content (e.g. images/css)?
body: <p>We're about to deploy our .NET web application to an Azure Web Role. I'm just wondering how others have handled their static content, specifically images and css? At the moment our application package is about 25mb but 18mb of that is derived purely from images, things like navigation buttons, icons and template components that rarely ever get updated. Would it be wise to partition this out of the deployment package and move it to blob storage?</p>
  
  <p>I have a few doubts about this approach that I'm wondering are valid...</p>
  
  <ol>
  <li><p>80% of our site runs in a HTTPS environment. Will accessing images in a blob store introduce cross-scripting problems?</p></li>
  <li><p>Vulnerability to money leakages, if someone tries to maliciously hammer our images (most are under 20kb)?</p></li>
  <li><p>I'm struggling to see how it's possible to upload files to a blob container (from VS2010 + Azure SDK) with directory naming convention so I don't need to rewrite 1000s of path references? I appreciate directories are an abstract concept in blob containers, but I can write files with a forward slash to imitate this in code. Obviously Windows does not allow me to do this before I upload in Visual Studio.</p></li>
  </ol>
  
  <p>Any thoughts or alternative strategies would be welcome. The goal really is to shrink our deployment package to speed up the deploy time. Also I quite like the idea of offloading the image serving to a dedicated node to improve the performance on the web server, maybe my image collection is so small that it's hardly worth bothering?</p>
  
  <p><strong>Update 16th May ------------------------------------------------------------------------</strong></p>
  
  <p>Here's what I did in the end:</p>
  
  <p>1.Transferred all images + css to blob storage containers. I maintained the structure of any sub-directories within the images and css folders.</p>
  
  <p>2.Applied a URL Rewrite rule in our web.config file as follows..</p>
  
  <pre><code>  &lt;rewrite&gt;
      &lt;rules&gt;
        &lt;rule name="imagestoazure"&gt;
        &lt;match url="images/(.*)" /&gt;
        &lt;action type="Redirect" url="https://xxxxx.vo.msecnd.net/images/{R:1}" /&gt;
      &lt;/rule&gt;
    &lt;/rules&gt;
    &lt;/rewrite&gt;
  </code></pre>
  
  <p>3.Excluded the images + css folders from the application and deployed.</p>
  
  <p>My deployment is now much smaller and the images are running off a CDN freeing up bandwidth, improving downloads speeds and releasing some load off the web-server.</p>
  
  <p><strong>Update: September 2015</strong></p>
  
  <p>When reviewing this recently I came across the following guide from Microsoft. It goes into more detail about how you can automate the deployment of your assets and cache bust using querystrings.</p>
  
  <p><a href="https://azure.microsoft.com/en-us/documentation/articles/cdn-serve-content-from-cdn-in-your-web-application/" rel="noreferrer">Serve Content from Azure CDN in Your Web Application</a></p>