title: Map subdomain to virtual directory Azure WebApps
body: <p>I am attempting to host multiple websites in a single Azure WebApp rather than having multiple web apps each hosting a site.  Each of these sites is rather small, but in order to meet the requirements of the SLA with Azure, we need to have the server scaled with more than one instance for our Production environment, thus the reasoning for combining sites.</p>
  
  <p>After researching this topic, I have got the following setup with our Azure account.</p>
  
  <ol>
  <li>Created the proper CNAME DNS records in our zone manager (complete and works).</li>
  <li>Setup the Azure WebApp to respond to the subdomains (complete and works).</li>
  <li>Setup a virtual directory for the second web application (complete and works)</li>
  </ol>
  
  <p>At this point, both web applications function correctly and both subdomains are pointing at our Azure instance.  We now have the following setup:</p>
  
  <ul>
  <li>both www.mydomain.com and app.mydomain.com bring up the root application that I deployed.</li>
  <li>going to www.mydomain.com/app2 and app.mydomain.com/app2 bring up the second application that I deployed to the virtual directory</li>
  </ul>
  
  <p>What I would like to achieve:</p>
  
  <ul>
  <li>Going to app.mydomain.com would bring up the application in the virtual directory.  </li>
  <li>Going to www.mydomain.com would bring up the application at the root of the azure instance.</li>
  </ul>
  
  <p>However, what I cannot figure out is how to map a subdomain to a specific virtual directory.  I have tried to update the Site URL to be the subdomain I want the application to respond to, however, the subdomain still brings up whatever I have in the root of the WebApp deployment. </p>
  
  <p>Should I have some HttpHandler that sits in the site root and directs traffic to the proper virtual directory?  Is there a setting in the portal that I am missing?  Previously, we did this with Web Roles and tinkering with the <code>ServiceDefinition</code> file, but the tool sets for the Azure Web Apps in regards to publishing, integration with Source Control, etc seem to be a bit further along.  </p>