简体   繁体   English

通过Git使用私有凭据部署Azure Web应用

[英]Deploy Azure web app with private credentials via Git

I would like to deploy my Node.js app via GitHub to Azure. 我想将我的Node.js应用程序通过GitHub部署到Azure。

I intend to make the app open source, thus no private info would be published in the repo; 我打算将该应用程序开源,因此不会在仓库中发布任何私人信息。 however, I still need to push the necessary credentials, API keys, etc. for the app to connect to other services. 但是,我仍然需要推送必要的凭据,API密钥等,以使该应用程序连接到其他服务。

How can I deploy the app without resorting to the private Git endpoint, and then awkward copy-pasting between the repos? 如何部署应用程序而无需求助于私有Git端点,然后在存储库之间进行笨拙的复制粘贴?

Typically you'll want to utilize an npm module like nconf to load environment variables from either a file or environment variables. 通常,您将需要利用nconf类的npm模块从文件或环境变量中加载环境变量。 在此处输入图片说明

config.json is just a JSON document listing your key:value pairs. config.json只是一个列出您的key:value对的JSON文档。 You'll want to add config.json to your .gitignore file to ensure you don't share your credentials publically. 您需要将config.json添加到.gitignore文件中,以确保您不公开共享凭据。 在此处输入图片说明

Within the Azure Portal , you'll want to add your credentials as key:value pairs under Application Settings. Azure门户内 ,您需要在“应用程序设置”下将凭据作为key:value对添加。 在此处输入图片说明

Note: You may be wondering what will happen if config.json is not found. 注意:您可能想知道如果找不到config.json会发生什么。 nconf will simply move on to the next chained option. nconf只会继续进入下一个链接选项。 You could continue to chain config options together as in the following code snippet: 您可以继续将配置选项链接在一起,如以下代码片段所示:

var nconf = require('nconf');

// Create nconf environtment 
nconf 
    .file({ file: 'config.json' })  // Committed to repo; public settings
    .file({file: 'local_config.json'})  // Not committed to repo; private or dev environment settings
    .env();

Persistent data can be stored under d:\\home , so I would recommend placing your private customizations there. 持久性数据可以存储在d:\\home ,因此我建议将您的私有自定义项放在此处。 If they need to be applied to the site in some way, you should do this by writing a deployment hook . 如果需要以某种方式将它们应用于站点,则应通过编写一个Deployment hook来做到这一点。

Set configuration as environment variables found in the "App Settings" section under Settings->Application Settings. 将配置设置为环境变量,可在“设置”->“应用程序设置”下的“应用程序设置”部分中找到。 Rationale here . 这里的理由。

Your issue seems to be continuous deployment for Web App via Git from GitHub repo. 您的问题似乎是从GitHub存储库通过Git连续部署Web App。 So I think @Dark Falcon 's answer is correct. 所以我认为@Dark Falcon的答案是正确的。

Azure continuous deployment support GitHub just need to do OAuth authentication in Azure Portal. Azure连续部署支持GitHub只需在Azure Portal中进行OAuth身份验证。

Find out the link "set up deployment from source control" at Azure WebApp Dashboard page and do it step by step, as the pictures below. 在Azure WebApp仪表板页面上找到“从源代码控制设置部署”链接,并逐步进行操作,如下图所示。

在此处输入图片说明 在此处输入图片说明 在此处输入图片说明

There is some blogs and vedio tutorials for details of helping you. 有关帮助您的详细信息,有些博客和视频教程。

The blog explains how to use continuous deployment support for repo hosted on GitHub http://azure.microsoft.com/en-us/blog/using-app-service-web-apps-continuous-deployment-with-github-organizations/ . 该博客介绍了如何对托管在GitHub http://azure.microsoft.com/en-us/blog/using-app-service-web-apps-continuous-deployment-with-github-organizations/上的仓库使用持续部署支持。

You also can follow these vedio tutorials to try to do it, as the references below. 您也可以按照以下视频教程尝试进行操作,如以下参考所示。

  1. http://azure.microsoft.com/en-us/documentation/videos/create-a-nodejs-site-deploy-from-github/ http://azure.microsoft.com/zh-CN/documentation/videos/create-a-nodejs-site-deploy-from-github/
  2. http://azure.microsoft.com/en-us/documentation/videos/deploying-to-azure-from-github/ http://azure.microsoft.com/zh-CN/documentation/videos/deploying-to-azure-from-github/
  3. https://channel9.msdn.com/Series/Windows-Azure-Web-Sites-Tutorials/Github-Continuous-Delivery-in-the-Preview-Portal . https://channel9.msdn.com/Series/Windows-Azure-Web-Sites-Tutorials/Github-Continuous-Delivery-in-the-Preview-Portal

Best Regards. 最好的祝福。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM