8
votes

Using the portal:

Using the portal at https://manage.windowsazure.com/ this is easy. From a newly created azure web site:

  1. Go to the dashboard
  2. On the quick glance options on the right, click "Set up deployment from source control"
  3. On the "where is your source code?" option, select Github
  4. Authorize, then choose the repo name and branch.
  5. BINGO: now pushes to that branch will trigger a deployment of that branch onto the azure website. Lovely.

Here's the problem:

I cannot for the life of me see how to do this from the command line (using the xpat-cli installed using npm: "npm install azure-cli -g")

It seems like I should be typing something like:

azure site deployment github --verbose --githubusername [username] --githubrepository [username/reponame] [sitename]

Because the help for "azure site deployment github" says it will: "Link a website to a github account for deployment"

Doesn't seem to work though...

If I then type:

azure site show [sitename]

The output says the source control is "LocalGit" instead of github - which is what it says if I do it the portal way above.

Source Control
data:    --------------
data:    Type:            LocalGit 

Any ideas?

2
Alternatively, is this possible with the powershell modules instead? Fundamentally I just need this scripted so it's repeatable and automated. Don't care how that happens in the end!Nick Meldrum

2 Answers

1
votes

Depending on your use case the solution will be different.

  1. Assuming you have the same github source but want to deploy to multiple different Azure websites Potential Solution: Make use of the Deploy to Azure Button See details here: https://azure.microsoft.com/blog/2014/11/13/deploy-to-azure-button-for-azure-websites-2/

  2. Assuming you have various repositories that you want to deploy to Azure: Potential Solution: I am assuming that you will be the person deploying it. The workflow will be as follows:

    A. Download files from Github to local folder See here

    B. Publish your local folder into a new/existing Azure site. See here, or here. There are other github repositories to get some scripts right away

I understand this doesnt directly hook your system to do direct pull, but its one way to do it.
There is also:

http://www.imtraum.com/blog/streamline-git-with-powershell/ https://gallery.technet.microsoft.com/scriptcenter/a-GitHub-Repository-265c0b49

0
votes

Both documents I found describing how to set up continuous deployment from GitHub say that you can configure the repo and branch with an Azure Resource Manager template, but you have to enter your credentials and complete the authorization process in the portal.

The script used in this tutorial will automatically configure continuous publishing from your GitHub repository. This requires that your GitHub credentials are already stored in Azure, otherwise the scripted deployment will fail when attempting to configure source control settings for the web apps.

To store your GitHub credentials in Azure, create a web app in the Azure preview portal and configure GitHub deployment. You only need to do this once.

I'd also suggest posting your xpat-cli problem as an issue on their GitHub repo.