One of the new features that comes with Windows Azure Web Sites is the ability to publish your web site using Git (a distributed version control system). The advantage of using Git to publish your Windows Azure Web Sites is two fold. First you have a distributed version control system, with one of the repository hosted in Azure. Which means that if you lose the code on your machine, you don’t have to worry, a copy is in the cloud! Second, Git was designed to be fast, no, really fast, no, really, really fast, no…ok, you get the idea. Publishing updates to your site can take just a few seconds*.
If you’re interested in kicking the tires with Git on Windows Azure here’s what you need to do.
The first thing you need to do is install Git. You can download Git from http://git-scm.com/downloads.
Next you’ll need to do, if you haven’t already done so, is to enable the new Windows Azure Web Sites features for you Azure subscription. You can do so by logging into http://account.windowsazure.com.
Once Windows Azure Web Sites are enabled for your subscription, log in to the management portal at http://manage.windowsazure.com
Click on the +NEW button on the bottom of the page
Click on WEB SITE
Click QUICK CREATE
Enter a URL for your web site, select a REGION (aka data center) where you want the web site to run, and select the SUBSCRIPTION you want to associated with the web site. Then click the CREATE WEB SITE button on the bottom of the page. (Note: during the preview period on the East US region supports Windows Azure web sites.)
Wait for your web site to have a STATUS of running. It took two minutes for the site I created along with this blog post get up and running, but your mileage may vary.
Once the site is running click on the NAME of the site. This will bring you to the site’s DASHBOARD. On the right hand side of the dashboard there is a *quick glance* section. Click on the *Set up Git publishing link*.
If this is your first time setting up a Git repository in Azure, you will be prompted for a USER NAME and PASSWORD you can use for publishing. Enter your credentials and click the checkmark button on the bottom right hand side of the page.
While your Git repository is being created you will see this message.
Once your Git repository is ready, copy the GIT URL on the page.
Launch Git bash (aka Git command line) on your machine in the directory where you want to create the web site and initialize a Git repository by issuing the following command in Git bash:
git init
Add any files your site requires to the directory. For the case of this site I’ll just add a default.htm file.
Add and commit the file(s) the local repository by issuing the following commands in Git bash:
git add .
git commit -m ‘initial commit’ commands
Add the remote (Windows Azure) repository by issuing the following command in Git bash:
git remote add azure [URL COPIED FROM THE WINDOWS AZURE GIT CONFIGURATION PAGE]
Push your changes to the Windows Azure repository by issuing the following command in Git bash:
git push Azure master
(When prompted, enter the password you specified as part of the repository set up in the Windows Azure management portal.)
Go back to the Windows Azure management portal and go to the DASHBOARD for your site by clicking the DASHBOARD link on the top of the page.
On the right hand site of the page is the SITE URL for your web site.
Click on the link and you will be redirected to your site.
I also created a screencast of this process. Just click on the picture below to start watching.
*Publishing times will vary depending on the number/size of files being pushed, network speed, phase of the moon, and the mood of the internet unicorns. Your mileage will vary.
ag








































Hey there! My name is Adam, and I'm a Technical Evangelist at Microsoft where I spend time focusing on Windows, Windows Phone, and Windows Azure.