Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Deploying website from private Github repository using ARM Templates

I am trying to create a website through Azure Resource Manager and then deploy from a private Github repository.

I have an ARM Template that works for a public repository. if I then make the repository private, connect to it through the Portal it all works fine.

If I redeploy the ARM Template it will fail with the message

"Cannot find SourceControlToken with name GitHub."

It seems that when the portal connects to a private repo it will create an ssh key that is used to authenticate.

The ssh key appears to come from kudu which can be gotten once the site is deployed.

I have also tried using access tokens, but couldn't get these to work with the repourl

So the simple question is, how do I deploy a private repo via ARM template

like image 512
Michael B Avatar asked Oct 20 '15 14:10

Michael B


People also ask

Can you deploy a private GitHub repo?

To register the repository SSH key with your private repository on GitHub, go to the Settings for the repository. On GitHub the repository SSH key is referred to by the term Deploy key. Search down the settings page and find the Deploy keys section and select it. Click on the Add deploy key button.

Can you deploy a private repository?

If you want to deploy a private repo, you have to make it public first. However, you can deploy projects directly from your machine using the Vercel CLI. For more information, you can go through this documentation.


2 Answers

In order to use this via ARM template, you need to first do it at least once using the Preview Portal (https://portal.azure.com/). You can do this on any site, and with any repo. It just needs to happen once to set up the GitHub relationship. Doing it via the old portal won't work.

Then, to check that things are set up properly:

  • Go to https://resources.azure.com/
  • Go under /providers/Microsoft.Web/sourcecontrols/GitHub
  • Make sure the token is set
like image 70
David Ebbo Avatar answered Sep 20 '22 13:09

David Ebbo


It seems that when the portal connects to a private repo it will create an ssh key that is used to authenticate.

Thats right.

Solve same problem by changing GitHub repository to External Git.

  • Create new GitHub account and shared read access to private repo

  • Generate access token

  • And use next url in templates, in portal, azure rest api, etc.

    https://{github-username}:{access-token}@github.com/{organisation-acount}/{repo}.git

Besides, this will help to avoid GitHub limitation for 20 connections, and you can use your repository in more than 20 Azure WebApps.

like image 43
Maksim Skutin Avatar answered Sep 16 '22 13:09

Maksim Skutin