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*.

While Git is a great tool, its command line nature isn’t for everyone. An alternative to using the command line is to use the GitHub for Windows app created by GitHub. While the app is primarily intended to be used with repositories hosted on GitHub, you can use it with repositories hosted elsewhere, including on Windows Azure Web Sites. Here’s what you need to do to get up and running:

The first thing you need to do is install GitHub for Windows. You can download it from http://windows.github.com/.

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

azure-github-01

Click on the +NEW button on the bottom of the page

azure-github-02

Click on WEB SITE

azure-github-03

Click QUICK CREATE

azure-github-04

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.)

azure-github-05

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.

azure-github-06

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*.

azure-github-07

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 righ hand side of the page.

azure-github-08

While your Git repository is being created you will see this message.

azure-github-09

Once your Git repository is ready, copy the GIT URL on the page.

azure-github-10

When you installed GitHub for Windows two shortcuts should have been placed on your desktop. One for GitHub and the other for Git Shell. Double-click the Git Shell short cut.

azure-github-11

This will launch a command line (don’t be afraid). Change to the directory where you want to keep the repository on your local machine.

azure-github-12

Clone the Windows Azure repostiory by issuing the following command in the shell:

git clone [GIT URL COPIED FROM WINDOWS AZURE MANAGEMENT PORTAL]

azure-github-13

(When prompted, enter the password you specified as part of the repository set up in the Windows Azure management portal.)

Close the Git Shell command prompt and double-click the GitHub icon on your desktop to open the GitHub for Windows app. Drag the folder where you cloned the Windows Azure repository onto the GitHub app.

azure-github-14

Add any files your site requires to the directory. For the case of this site I’ll just add a default.htm file. The GitHub app picks up the changes. Commit the changes by entering a message and pressing the COMMIT button.

azure-github-15

All that needs to be done is to push the changes to Windows Azure by clicking the sync button.

azure-github-16

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.

azure-github-17

On the right hand site of the page is the SITE URL for your web site.

azure-github-18

Click on the link and you will be redirected to your site.

azure-github-19

I also created a screencast of this process. Just click on the picture below to start watching.

azure-github-20

*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

Author

RBA Author

Leave a Reply