Deploying an Azure Website from a local Git Repo

facebooktwittergoogle_pluslinkedin

Azure offers you the ability to host a website under your Azure account in minutes.  The site doesn’t have to be ASP.NET, you can use HTML5/JavaScript, a static HTML page, PHP, Python, Classic ASP and others.  This is a great way to get your site hosted, especially if you already have an Azure account and you don’t need access to other Azure offerings such as Web Role, Worker Role, Table/Blob Storage, and more.

Just like any other web hosts out there, you are able to FTP your files using your favorite FTP client.  But Azure offers you other options which make our life a lot easier, one of them is by configuring your Azure hosted directory as a Git repository.  This allows you to push files to it from any other Git repo such as Visual Studio Online, TFS 2013, GitHub, and even a local repo.  This is how you configure your deployments from your local Git repo using Visual Studio 2013:

Create an Azure Website and Configure Git Deployment

Go to your Azure Portal, then click on the Websites, then click on New and select “Custom Create”.  This will allow you to configure a database (if any) and specify your deployment source.

image

Enter your URL, Region, Database, and check the “Publish from Source Control” checkbox:
image

Then select Local Git Repository as your source:
image

As of this moment, the list of sources is: Visual Studio Online, Local Git repository, GitHub, Dropbox, Bitbucket, CodePlex, or any externally accessible Git or Mercurial repository.

Click on next, and the site is created.  Back from the Azure portal, you can click on your newly-created site, and select “Deployments”.  Here you can see instructions on what you need to do to get your site deployed:
image

Before you can deploy, you’ll need to create credentials that will be used by Git:
image

Now time to create a website and deploy to Azure.

Create your new Website locally

From Visual Studio 2013, create a new website: File –> New –> Website. I selected an ASP.NET Empty Website, with a very simple default.html page:
image

Create a local repo and commit your files

Right-click on your solution and select “Add to Source Control” and select Git
image

Then Right-click on your solution and select Commit, which will bring up the Commit tab in Team Explorer:
image

Configure the remote repo

Once your files a committed to your local Git repository, you can use the information provided by Azure to configure the remote repository.  Clicking on the Unsynced Commits link shows you that your remote repository is not configured yet:

image

So in my case, I will enter this URL in the remote repo textbox: https://EstebanFtp@estebanblogdemo.scm.azurewebsites.net:443/estebanblogdemo.git, then click on Publish.  You will be prompted for your credentials that you configured earlier.  And a few short seconds later, you will get a message letting you know that it was all successful:
image

image

And here is awesome new site!
image

Now every time I push to my remote repo, my site will get automatically deployed!

Interested in learning more about Git?  Check out my new Pluralsight course on Git for Visual Studio Developers!


2 thoughts on “Deploying an Azure Website from a local Git Repo

  1. Pingback: Wednesday, January 8, 2014 on #WindowsAzure | Alexandre Brisebois

  2. It means that Clash of Clans Cheats is the place to fulfil that very specific fantasy.
    Fight in the building game clash of clans hack and defend yourself against virtual goblins
    and real players. When it comes to Clash of Clans Hack Tool?
    How to Use Clash of Clans is strategy game. Not sure,
    but we are going to briefly examine about them. If we end up working together, with a
    dictionary definition — there are lots of people who
    support it, so, just ignore them.

Leave a Reply

Your email address will not be published. Required fields are marked *


2 + = five

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>