Deploying website from private Github repository using ARM Templates

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-18 13:14:28

问题


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


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/33239397/deploying-website-from-private-github-repository-using-arm-templates

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!