部署通过Git的私有证书Azure的Web应用程序 [英] Deploy Azure web app with private credentials via Git

查看:151
本文介绍了部署通过Git的私有证书Azure的Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过我的GitHub的Node.js的应用程序部署到Azure上。

I would like to deploy my Node.js app via GitHub to Azure.

我打算使应用程序开源,因此没有私人信息将在回购公布;不过,我仍然需要推动必要的凭证,API密钥等,为应用程序连接到其他服务。

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.

我如何部署应用程序,而不诉诸私人Git的端点和回购之间的尴尬,然后复制粘贴?

How can I deploy the app without resorting to the private Git endpoint, and then awkward copy-pasting between the repos?

推荐答案

通常你会希望利用像 nconf中的NPM模块,从文件加载环境变量或环境变量。

Typically you'll want to utilize an npm module like nconf to load environment variables from either a file or environment variables.

config.json 只是一个JSON文件,列出你的键:值对。你要添加 config.json 你的的.gitignore 文件,以确保您不会公开分享您的凭据。

config.json is just a JSON document listing your key:value pairs. You'll want to add config.json to your .gitignore file to ensure you don't share your credentials publically.

的Azure门户,你要添加凭据的关键:应用程序设置下值对。

Within the Azure Portal, you'll want to add your credentials as key:value pairs under Application Settings.

注意:您可能会想,如果没有找到config.json会发生什么。 nconf中将只需移动到下一个链接选项。你可以继续链的配置选项一起作为在以下code片断:

Note: You may be wondering what will happen if config.json is not found. nconf will simply move on to the next chained option. 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();

这篇关于部署通过Git的私有证书Azure的Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆