日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

持续交付一:从开发到上线的环境

發(fā)布時(shí)間:2023/12/4 编程问答 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 持续交付一:从开发到上线的环境 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

團(tuán)隊(duì)開發(fā)中,開發(fā),測(cè)試,預(yù)發(fā)布,生產(chǎn),不同的角色工作在不同的環(huán)境中,不同的環(huán)境有不同的作用(有些公司的環(huán)境更多,按照自己的交付流程設(shè)計(jì)),當(dāng)然不同的環(huán)境,配置也不能相同,特別生產(chǎn)數(shù)據(jù)是隔離的。那asp.net core怎么來對(duì)應(yīng)呢?

asp.net core為了支持不同的環(huán)境,可以把配置文件分為設(shè)置成appsettings.json,appsettings.Staging.json,appsettings.QA.json,appsettings.Development.json,配置文件中,可以放不同的配置項(xiàng)。

常見的不同環(huán)境配置項(xiàng):

1、數(shù)據(jù)庫鏈接字符串

2、外接存存儲(chǔ)

3、三方接口url

4、本服務(wù)對(duì)外端口

5、區(qū)分不同環(huán)境的標(biāo)準(zhǔn)信息等

下面是三個(gè)環(huán)境的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中,項(xiàng)目屬性下,可以查詢環(huán)境變量

對(duì)應(yīng)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"}} }

對(duì)于Staging環(huán)境,如果使用DevOpt,可以在對(duì)應(yīng)工具中來配置Staging或Production環(huán)境變量

Jenkins

配置全局環(huán)境變量,來配置對(duì)應(yīng)asp.net core ASPNETCORE_ENVIRONMENT的運(yùn)行時(shí)環(huán)境

dockerfile

ENV ASPNETCORE_ENVIRONMENT="Staging"

總結(jié)

以上是生活随笔為你收集整理的持续交付一:从开发到上线的环境的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。