11

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

3 Answers 3

9

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:

Sign up to request clarification or add additional context in comments.

4 Comments

What about the situation where you have been granted access to a private GitHub repo that you yourself are not an owner of?
@IsaacAbraham it comes down to whether you are allowed to add WebHooks and Deploy Keys on the GitHub repo. If you're not, then there is simply no way to set up continuous deployment to anywhere (not an Azure specific thing).
OK, cheers - I'm sure that I can get that added (that's probably why it doesn't show up in Azure as a repo that I can "get to").
@DavidEbbo do you know how to make it work with AD application login?
5

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.

4 Comments

that sounds like a nice workaround, I'll give it a go!
I have the same problem with a public repo and I can't make this work, can you give more details pleasE?
Look at the comment of David above. But make sure that you are working under one user from everywhere.
What about things running under Managed Identities... where you can't "Go to the Portal"??
0

This error occurs due to connecting Github to multiple Azure accounts. To resolve it, simply revoke all Azure-related apps from the "Authorized OAuth Apps" section in Github settings (https://github.com/settings/applications), then re-authorize Github in Azure. This should allow you to save the deployment.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.