IIS has allowed you to configure multiple virtual directories and applications within a single website. There are a bunch of situations where this is useful. This blog will explain how we can create virtual directory in azure website
Situation
In my last project I faced an issue, the project had two versions and I wanted to publish this version under one website like below.
www.samplewebsite.comversion1
www.samplewebsite.comversion2
In IIS we can easily solve this issue using virtual directory. But here my project is a cloud-based one (Azure website). After a couple of detailed searching on Google I found that azure is supporting virtual directory.
Implementation
- Create an Azure web site.
Go to the Azure management portal, and create an Azure website
- Set up the Virtual Directory or Application
Now comes the important part. Select your azure website and go to configure tab. You need to specify the name of the directory, the file system location, and whether you want to mark it as an IIS application. Be sure to save your settings to apply the changes to Azure.
- Publishing application in Virtual directory
Once the solution is ready to deploy, the next step is to publish the project to Azure virtual directory. After choosing the appropriate subscription and website, I kept all the defaults in the Publish dialog
The same way you can publish the second version. ie the difference is to change version1 to version2.
Conclusion
Using virtual directory we can easily publish multiple websites in a single azure web site. It also has an advantage of allowing you to share things like cookies and certain configuration between the two projects.