Deploying TWO websites to Windows Azure from one Git Repository
Deploying to Windows Azure is very easy from Git. I use the Azure Cross-Platform Command Line (open source on github, written in node) that I get from npm via "npm install azure-cli --g" to make the sites.
When you make a new site with the Azure command line, you'll usually do this:
azure site create --location "West US" MyFirstSite --git
And the tool will not only make the site, but also add a git remote for you, something like https://username@MyFirstSite.scm.azurewebsites.net:443/MyFirstSite.git. When you push to that git remote, Azure deploys the site. You can git push sites with PHP, node, ASP.NET, and Python.
You may have multiple remotes with your git repository, of course:
C:\MyCode>git remote show
When you push a folder with code to Azure via Git, unless you're pushing binaries, Azure is going to compile the whole thing for you when it gets pushed. It will restore npm modules or restore NuGet packages, and then build and deploy your app.
If your repository has a lot of .NET projects, you usually only want one project to be the actual deployed website, so you can add a .deployment file to specify which project contains website you're git deploying:
project = WebProject/MyFirstSiteWebProject.csproj
However, in lieu of a .deployment file, you can also set an application configuration setting with the Azure Portal to to the same thing.
Or, of course, set the configuration values for each site using the Azure Command Line:
c:\MyCode>azure site config add Project=WebProject/MyFirstSiteWebProject.csproj [sitename]
What's nice about setting the "Project" setting via site configuration rather than via a .deployment file is that you can now push the same git repository containing two different web sites to two remote Azure web sites. Each Azure website should have a different project setting and will end up deploying the two different sites.
I do this by setting the git remotes manually like this, using the correct git remote URLs I get from the Azure Portal:
C:\MyCode> git remote add azureweb1 https://firstname.lastname@example.org:443/website1.git
C:\MyCode> git remote add azureweb2 https://email@example.com:443/website2.git
C:\MyCode> git remote show
C:\MyCode> git push azureweb1 master
I have a number of solutions with two or more web sites, or in one case, a web site I want separate from my web api, and I deploy them just like this.
Hope this helps!
Sponsor: Big Thanks to Aspose for sponsoring the blog this week! Aspose.Total for .NET has all the APIs you need to create, manipulate and convert Microsoft Office documents and a host of other file formats in your applications. Curious? Start a free trial today.