Azure CLI Day 8 – site create with GitHub
The Cloud Zone is brought to you in partnership with Iron.io. Discover how Microservices have transformed the way developers are building and deploying applications in the era of modern cloud infrastructure.
In my last post I showed you how to create a Windows Azure web site that is integrated with Git from the command line. The benefit of this approach its that you can modify your web site locally, and once you’re happy with it you can push it to Azure using Git. In this post I’ll show you how to use the popular site GitHub to do the same thing.
Once again, just a reminder that I’m using the command line tools on a MacBook Air with OSX (Mountain Lion) installed, and I’m using Google Chrome as my default browser. However, the experience should be identical on Windows and Linux as well.
To follow along with this post you’ll need the following:
- A GitHub account(http://github.com).
- An empty GitHub repository.
- A Windows Azure account. If you don’t already have one, you can get a free 30 day trial account athttp://aka.ms/thecloud.
Since I’m currently working on a Mac, I thought I’d also use the GitHub for Mac client (http://mac.github.com). If you’re on Windows you can use the GitHub for Windows client (http://windows.github.com). Alternatively you can use the Git CLI as I did in my last post.
Open an instance of your command line (Terminal, Bash, Command Prompt, etc.) and type the following:
azure site create -h
This should look very familiar as we’ve seen this command in my previous two posts. This time we’re going to use a couple of different options when creating our web site.
- –github. This will configure the site to use GitHub for deployments.
- –githubusername <username>. Your GitHub username.
- –githubpassword <password>. Your GitHub password.
- –githubrepository <repository>. The full name of your GitHub repository. The full name of your repository is [username]/[repository name]. For example, my GitHub username is agrocholski and the repository I’m using is called antares101, so the repository’s full name is agrocholski/antares101.
Next type the following, making the appropriate substitutions:
azure site create –location “[YOUR LOCATION]” –github –githubusername “[YOUR GITHUB USER NAME]” –githubpassword “[YOUR GITHUB PASSWORD]” –githubreposrity “[FULL PATH TO YOUR GITHUB REPOSITORY]” “[YOUR WEB SITE NAME]“
In my case I entered:
azure site create –location “West US” –github –githubusername “agrocholski” –githubpassword=”[MY GITHUB PASSWORD]” –githubrepository “agrocholski/antares101 “antares101″
(No “[MY GITHUB PASSWORD]” is not my actual GitHub password.)
I won’t bore you with screenshots since you’ve seen them before in previous posts, but if you browse to the portal you can see the newly created site, and if you browse to the site itself you can see the default page that an Azure web site gets out of the box.
The next thing to do is to open the GitHub client for your system, in my case a Mac, and clone your empty repository to your local machine.
If you navigate to the directory on the file system where the repository was cloned, you will see there is nothing in it. Now, open your favorite text/web editor and create a basic html page. Here’s what mine looks like.
Save this as index.html in the directory where you cloned your web site’s Git repository.
Go back to your repository in the GitHub client and you should see the file you just created. Enter a commit comment and press the commit button.
At this point your file has been committed to your local version of the repository. To push this to Windows Azure, you simply need to publish your branch to the repository on GitHub by pressing the Publish Branchbutton in the upper right-hand corner.
If the publishing action is successful you should sees a No unsynced commits message. You can also go to your repository on GitHub and you should see the file.
Go back to your web site’s dashboard in the Windows Azure management portal and click DEPLOYMENTS
Check that out! Your changes we’re deployed as soon as you published your changes to GitHub! You can verify this by navigating to your web site. You should now see the following page:
In my next post I’ll show you how you can get a list of all the Windows Azure web sites you have running.
Did you know you can try Windows Azure for free for 30 days? Just go to http://aka.ms/thecloud and sign up.