One of the great features of the Windows Azure Websites is that you can directly connect the site to your source control repository. When you change your source code, it will be automatically deployed to the Azure cloud.
It is only a few clicks to set it up, just start the New –> Compute –> Web Site –> Custom create wizard:
Enter a URL for your website and don’t forget to check the Publish from source control checkbox:
This activates the second step of the wizard where you can select your preferred source control provider, for example GitHub:
In case of GitHub you have to authenticate yourself via OAuth, then you can select which repository and which branch you want to publish (master is the default, but you can change that to any branch name!):
Within a few seconds your website will be up and running, and Azure will start deploying your application to it.
But what if you have a Visual Studio solution which contains multiple web projects or websites, which one will be deployed? The first one.
Well, that’s great for most cases, but sometimes you want to change that behavior.
If you always want to deploy the same project/site to the cloud, you can create a .deployment file in the root of your repo, in which you define which project you want to deploy:
[config] project = MySolution/MyWebProject.csproj
But if you have multiple Azure websites, you may want to deploy different projects of your solution to them. In this case you cannot hardwire the setting into the repo, instead you have to set on the Azure management portal. Navigate to the CONFIGURE page and scroll down to the app settings section. Create a new setting with the name Project and set the repo-root relative path to the .csproj or the folder of the website as its value:
Just save the setting and voila, next time when you change your source code only the preset project will be deployed to this website.