Windows Azure : How to define Virtual Directories in Service Definition (CSDEF) for your site?

In Windows Azure SDK 1.3 you have ability to setup multiple sites
within your full IIS role as well as Virtual directories.

When you are developing your application and needed to setup
Virtual Directories, here I will explain how you can configure VirtualDirectory
for specified Site in ServiceDefinition.csdef file.

So if you have your VS2010 Solution is located at:  

         C:\App\Enterprise\Release\Service_Name\1.0.0

And your Cloud Project is:

         C:\App\Enterprise\Release\Service_Name\1.0.0\PHYSICAL_DIRECTORY

In that case the Service Definition (CSDEF) should be constructed
for Virtual Directories as below:

<ServiceDefinition name="Service_Name" xmlns="https://schemas.microsoft.com/ServiceHosting/2008/10/ServiceDefinition">

 
<WebRole name=" Services.WebRole_Name">

     
<Sites>

      
<Site name="Web" physicalDirectory="..\..\1.0.0\PHYSICAL_DIRECTORY">

        
<VirtualDirectory name="VersionDir" physicalDirectory="..\..\1.0.0">

          
<VirtualApplication name="AppDir" physicalDirectory="." />

        
</VirtualDirectory>

        
<Bindings>

         
 <Binding name="Endpoint1" endpointName="Endpoint1" />

        
</Bindings>

       
</Site>

      </Sites>

      <Endpoints>

         <InputEndpoint name="Endpoint1" protocol="http" port="80" />

      </Endpoints>

      <Imports>

          
<Import moduleName="Diagnostics" />

      </Imports>

   </WebRole>

</ServiceDefinition>

 

You need to control TWO important things:

1. Please be sure to keep the total path size under 260
characters otherwise you will get another error.

2. The directory name must be
under 248 characters which could also cause another error.