博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
持续交付一:从开发到上线的环境
阅读量:4033 次
发布时间:2019-05-24

本文共 2545 字,大约阅读时间需要 8 分钟。

团队开发中,开发,测试,预发布,生产,不同的角色工作在不同的环境中,不同的环境有不同的作用(有些公司的环境更多,按照自己的交付流程设计),当然不同的环境,配置也不能相同,特别生产数据是隔离的。那asp.net core怎么来对应呢?

asp.net core为了支持不同的环境,可以把配置文件分为设置成appsettings.json,appsettings.Staging.json,appsettings.QA.json,appsettings.Development.json,配置文件中,可以放不同的配置项。

常见的不同环境配置项:

1、数据库链接字符串

2、外接存存储

3、三方接口url

4、本服务对外端口

5、区分不同环境的标准信息等

下面是三个环境的appsettings文件

Production:appsettings.json

{  "urls": "https://*:5001;http://*:5000",  "Logging": {    "LogLevel": {      "Default": "Information",      "Microsoft": "Warning",      "Microsoft.Hosting.Lifetime": "Information"    }  },  "ConnectionStrings": {    "DefaultConnectionString": "server=123.1.1.1;database=ab_db;uid=sa;pwd=!fuzamimi20;"  },  "AllowedHosts": "*"}

 Staging:appsettings.Staging.json

{  "urls": "https://*:7001;http://*:7000",  "Logging": {    "LogLevel": {      "Default": "Information",      "Microsoft": "Warning",      "Microsoft.Hosting.Lifetime": "Information"    }  },  "ConnectionStrings": {    "DefaultConnectionString": "server=123.1.1.2;database=ab_db;uid=sa;pwd=sa;"  }}

Development:appsettings.Development.json

{  "urls": "https://*:8001;http://*:8000",  "Logging": {    "LogLevel": {      "Default": "Information",      "Microsoft": "Warning",      "Microsoft.Hosting.Lifetime": "Information"    }  },  "ConnectionStrings": {    "DefaultConnectionString": "server=123.1.1.4;database=ab_db;uid=sa;pwd=sa;"  }}

Development:appsettings.Development.json

{  "urls": "https://*:9001;http://*:9000",  "Logging": {    "LogLevel": {      "Default": "Information",      "Microsoft": "Warning",      "Microsoft.Hosting.Lifetime": "Information"    }  },  "ConnectionStrings": {    "DefaultConnectionString": "server=123.1.1.3;database=ab_db;uid=sa;pwd=sa;"  }}

在Visual Studio中,项目属性下,可以查询环境变量

对应UI的配置文件在Properties下的launchSettings.json

{  "iisSettings": {    "windowsAuthentication": false,    "anonymousAuthentication": true,    "iisExpress": {      "applicationUrl": "http://localhost:55263",      "sslPort": 44313    }  },  "$schema": "http://json.schemastore.org/launchsettings.json",  "profiles": {      "AspNetCoreEnvironment": {      "commandName": "Project",      "launchBrowser": true,      "launchUrl": "swagger",      "environmentVariables": {        "ASPNETCORE_ENVIRONMENT": "Development"      },      "dotnetRunMessages": "true",      "applicationUrl": "https://localhost:9001;http://localhost:9000"    }  }}

对于Staging环境,如果使用DevOpt,可以在对应工具中来配置Staging或Production环境变量

Jenkins

配置全局环境变量,来配置对应asp.net core ASPNETCORE_ENVIRONMENT的运行时环境

dockerfile

ENV ASPNETCORE_ENVIRONMENT="Staging"

转载地址:http://zakdi.baihongyu.com/

你可能感兴趣的文章
小谈python 输出
查看>>
Django objects.all()、objects.get()与objects.filter()之间的区别介绍
查看>>
python:如何将excel文件转化成CSV格式
查看>>
Django 的Error: [Errno 10013]错误
查看>>
机器学习实战之决策树(一)
查看>>
[LeetCode By Python] 2 Add Two Number
查看>>
机器学习实战之决策树二
查看>>
[LeetCode By Python]7 Reverse Integer
查看>>
[LeetCode By Python]9. Palindrome Number
查看>>
[leetCode By Python] 14. Longest Common Prefix
查看>>
[LeetCode By Python]108. Convert Sorted Array to Binary Search Tree
查看>>
[leetCode By Python]111. Minimum Depth of Binary Tree
查看>>
[LeetCode By Python]118. Pascal's Triangle
查看>>
[LeetCode By Python]121. Best Time to Buy and Sell Stock
查看>>
[LeetCode By Python]122. Best Time to Buy and Sell Stock II
查看>>
[LeetCode By Python]125. Valid Palindrome
查看>>
[LeetCode By Python]136. Single Number
查看>>
[LeetCode By Python]172. Factorial Trailing Zeroes
查看>>
[LeetCode By MYSQL] Combine Two Tables
查看>>
python jieba分词模块的基本用法
查看>>