【发布时间】:2021-11-29 17:33:38
【问题描述】:
我的应用设置中有复杂的层级设置。 当我从 Visual Studio 部署(使用发布)我的应用程序时,我想知道它是否确实将 appsetting 复制到 Azure,因为我收到与其中一项设置相关的错误,该设置在 azure 上不可用但存在于 appsetting 中。
我是否必须在 Azure 应用服务中再次手动创建所有设置。 另外,由于 Azure App 服务是键值对,我如何适应分层设置?
{
"ConnectionStrings": {
"DatabaseConsString": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
},
"ApplicationInsights": {
/*XXXXXXXXXXXXXXX*/
"InstrumentationKey": "XXXXXXXXXXXXXXXXXXXXXXXXXXX"
},
"RedisCache": {
"ConnectionString": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
},
"sendGrid": {
"ApiKey": "SG.XXXXXXXXXXXXXXXXXX",
"FromEmail": "XXXXXXXX@XXXXXXXXXX.net",
"FromEmailName": "XXXXXXXXXXXXXXXX"
},
"Twilio": {
"AccountSID": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"AuthToken": "XXXXXXXXXXXXXXXXXXXXXXXXX",
"FromNumber": "+XXXXXXXX"
},
"Jwt": {
"key": "MyApplicationKey",
"Issuer": "MyAppName",
"Audience": "MyAppAudience"
},
"Serilog": {
"Properties": {
"ApplicationName": "XXXXXXXXXXXXXXXXXXXXXX",
"Serilog": "AppInsightFromSerilog"
},
"MinimumLevel": { //https://docs.datalust.co/v2/docs/logging-levels (Verbose,Debug,Information,Warning,Error,Fatal)
"Default": "Information",
"Override": {
"Microsoft": "Warning",
"Microsoft.Hosting.Lifetime": "Information"
}
},
"Using": [ "XXXXXXXXXXXX.Server", "Serilog.Sinks.ApplicationInsights", "Serilog.Sinks.Console" ],
"Enrich": [
"FromLogContext",
"WithUserName",
"WithIPAddress"
],
"Filter": [
{
"Name": "ByExcluding",
"Args": {
"expression": "RequestPath like '%swagger%' or RequestPath like '%_framework%' or Contains(@m, 'Hosting environment:') or Contains(@m, 'Now listening on:') or Contains(@m, 'HTTP') or Contains(@m, 'Application started. Press Ctrl+C to shut down.') or Contains(@m, 'Content root path:')"
//https://github.com/serilog/serilog-expressions
}
}
],
"WriteTo": [
{
"Name": "Console"
//"Args": {
// "levelSwitch": "$consoleSwitch"
//}
},
//{
// "Name": "File",
// "Args": {
// "path": "./logs/log-.txt",
// "rollingInterval": "Day"
// }
//},
{
"Name": "ApplicationInsights",
"Args": {
"restrictedToMinimumLevel": "Information",
"telemetryConverter": "Serilog.Sinks.ApplicationInsights.Sinks.ApplicationInsights.TelemetryConverters.TraceTelemetryConverter, Serilog.Sinks.ApplicationInsights"
}
},
{
"Name": "MSSqlServer",
"Args": {
"connectionString": "XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX",
"sinkOptionsSection": {
"tableName": "SeriLog",
"formatter": "Serilog.Formatting.Compact.CompactJsonFormatter, Serilog.Formatting.Compact",
"schemaName": "dbo",
"autoCreateSqlTable": true
},
"columnOptionsSection": {
//https://github.com/serilog/serilog-sinks-mssqlserver#custom-property-columns
"additionalColumns": [
{
"ColumnName": "InstanceId",
"PropertyName": "InstanceId",
"DataType": "varchar",
"DataLength": 80
},
{
"ColumnName": "ConnectionId",
"PropertyName": "ConnectionId",
"DataType": "varchar",
"DataLength": 80
},
{
"ColumnName": "RequestId",
"PropertyName": "RequestId",
"DataType": "varchar",
"DataLength": 80
},
{
"ColumnName": "ActionId",
"PropertyName": "ActionId",
"DataType": "varchar",
"DataLength": 80
},
{
"ColumnName": "OperationId",
"PropertyName": "OperationId",
"DataType": "varchar",
"DataLength": 80
},
{
"ColumnName": "ActionName",
"PropertyName": "ActionName",
"DataType": "varchar",
"DataLength": 5000
},
{
"ColumnName": "EnvironmentName",
"PropertyName": "EnvironmentName",
"DataType": "varchar",
"DataLength": 50
},
{
"ColumnName": "ApplicationName",
"PropertyName": "ApplicationName",
"DataType": "varchar",
"DataLength": 5000
},
{
"ColumnName": "UserName",
"PropertyName": "UserName",
"DataType": "varchar",
"DataLength": 1000
},
{
"ColumnName": "IPAddress",
"PropertyName": "IPAddress",
"DataType": "varchar",
"DataLength": 50
},
{
"ColumnName": "Source",
"PropertyName": "Source",
"DataType": "varchar",
"DataLength": 50
},
{
"ColumnName": "SourceContext",
"PropertyName": "SourceContext",
"DataType": "varchar",
"DataLength": 1000
},
{
"ColumnName": "Origin",
"PropertyName": "Origin",
"DataType": "varchar",
"DataLength": 100
},
{
"ColumnName": "OperationType",
"PropertyName": "OperationType",
"DataType": "varchar",
"DataLength": 1000
},
{
"ColumnName": "RequestPath",
"PropertyName": "RequestPath",
"DataType": "varchar",
"DataLength": 1000
},
{
"ColumnName": "MethodName",
"PropertyName": "MethodName",
"DataType": "varchar",
"DataLength": 1000
}
],
"addStandardColumns": [ "LogEvent" ],
"removeStandardColumns": [ "MessageTemplate", "Properties" ],
"logEvent": {
"excludeAdditionalProperties": true,
"excludeStandardColumns": true
}
},
"restrictedToMinimumLevel": "Information" // (Verbose,Debug,Information,Warning,Error,Fatal)
}
}
]
},
"AllowedHosts": "*"
}
【问题讨论】:
标签: azure-web-app-service azure-appservice azure-app-service-envrmnt