建立网站的请示,吉林网站开发,wordpress直接外链excel,公司设计一个网站团队开发中#xff0c;开发#xff0c;测试#xff0c;预发布#xff0c;生产#xff0c;不同的角色工作在不同的环境中#xff0c;不同的环境有不同的作用(有些公司的环境更多#xff0c;按照自己的交付流程设计)#xff0c;当然不同的环境#xff0c;配置也不能相同… 团队开发中开发测试预发布生产不同的角色工作在不同的环境中不同的环境有不同的作用(有些公司的环境更多按照自己的交付流程设计)当然不同的环境配置也不能相同特别生产数据是隔离的。那asp.net core怎么来对应呢asp.net core为了支持不同的环境可以把配置文件分为设置成appsettings.json,appsettings.Staging.json,appsettings.QA.json,appsettings.Development.json配置文件中可以放不同的配置项。常见的不同环境配置项1、数据库链接字符串2、外接存存储3、三方接口url4、本服务对外端口5、区分不同环境的标准信息等下面是三个环境的appsettings文件Productionappsettings.json{urls: https://*:5001;http://*:5000,Logging: {LogLevel: {Default: Information,Microsoft: Warning,Microsoft.Hosting.Lifetime: Information}},ConnectionStrings: {DefaultConnectionString: server123.1.1.1;databaseab_db;uidsa;pwd!fuzamimi20;},AllowedHosts: *
}Stagingappsettings.Staging.json{urls: https://*:7001;http://*:7000,Logging: {LogLevel: {Default: Information,Microsoft: Warning,Microsoft.Hosting.Lifetime: Information}},ConnectionStrings: {DefaultConnectionString: server123.1.1.2;databaseab_db;uidsa;pwdsa;}
}
Developmentappsettings.Development.json{urls: https://*:8001;http://*:8000,Logging: {LogLevel: {Default: Information,Microsoft: Warning,Microsoft.Hosting.Lifetime: Information}},ConnectionStrings: {DefaultConnectionString: server123.1.1.4;databaseab_db;uidsa;pwdsa;}
}
Developmentappsettings.Development.json{urls: https://*:9001;http://*:9000,Logging: {LogLevel: {Default: Information,Microsoft: Warning,Microsoft.Hosting.Lifetime: Information}},ConnectionStrings: {DefaultConnectionString: server123.1.1.3;databaseab_db;uidsa;pwdsa;}
}
在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的运行时环境dockerfileENV ASPNETCORE_ENVIRONMENTStaging