Utility API Appsettings
Below is a detailed documentation for the provided appsettings.json
configuration file. This document aims to explain each section for an ASP.NET Core application, assisting you in understanding and managing the settings effectively.
Overview
The appsettings.json
file specifies configuration settings for database connections, Azure services integration, API parameters, authentication, host settings, and logging via Serilog. These settings are crucial for the application's connectivity, security, and logging capabilities.
1. ConnectionStrings
{
"ConnectionStrings": {
"DefaultConnection": "{Your connection string comes here}"
}
}
Docker-compose form of environment variables.
environment:
ConnectionStrings__DefaultConnection:"{Your connection string comes here}"
- DefaultConnection: This is a placeholder for your database connection string. This string is necessary for the application to connect to a database and perform data operations.
2. Azure
{
"Azure": {
"ConnectionString": "{Your Azure connection string here}",
"CDN": "{Your CDN URL here}",
"MapscaleCadsFolder": "mapscale-cads",
"FeatureImagesFolder": "feature-images",
"MapscaleResultsFolder": "mapscale-results",
"GeojsonToPngFolder": "geojson-to-png",
"CadToGeojsonFolder": "cad-to-geojson",
"IMDFFolder": "imdf",
"SasToken": {
"ReadPermissionExpireDays": 365,
"WritePermissionExpireHours": 1
}
}
}
Docker-compose form of environment variables.
environment:
Azure__ConnectionString: "{Your Azure connection string here}"
Azure__CDN: "{Your CDN URL here}"
Azure__MapscaleCadsFolder: "mapscale-cads"
Azure__FeatureImagesFolder: "feature-images"
Azure__MapscaleResultsFolder: "mapscale-results"
Azure__GeojsonToPngFolder: "geojson-to-png"
Azure__CadToGeojsonFolder: "cad-to-geojson"
Azure__IMDFFolder: "imdf"
Azure__SasToken__ReadPermissionExpireDays: "365"
Azure__SasToken__WritePermissionExpireHours: "1"
- ConnectionString: Connection string for accessing Azure resources.
- CDN: The URL for the Content Delivery Network (CDN) to facilitate distributed and fast access to web resources.
- MapscaleCadsFolder, FeatureImagesFolder, MapscaleResultsFolder, GeojsonToPngFolder, CadToGeojsonFolder, IMDFFolder: Azure Blob container names used for various content and data types.
- SasToken:
- ReadPermissionExpireDays: Defines the expiration period for read permissions in days (365 days).
- WritePermissionExpireHours: Sets the expiration period for write permissions in hours (1 hour).
3. Parameters
{
"Parameters": {
"MCSSecret": "{Your MCS Secret here}",
"MCSUrl": "{Your MCD URL here}",
"IMDFUrl": "{Your IMDF URL here}",
"PointrCloudUrl" : "{Your Pointr Cloud URL here}"
}
}
Docker-compose form of environment variables.
environment:
Parameters__MCSSecret: "{Your MCS Secret here}"
Parameters__MCSUrl: "{Your MCD URL here}"
Parameters__IMDFUrl: "{Your IMDF URL here}"
Parameters__PointrCloudUrl: "{Your Pointr Cloud URL here}"
- MCSSecret: A secret key for accessing MCS (Mapscale or Mapping Cloud Service).
- MCSUrl: The URL endpoint for the MCS service.
- IMDFUrl: URL for accessing the Indoor Mapping Data Format (IMDF) service.
- PointrCloudUrl: URL for accessing the Pointr Cloud services.
4. Auth
{
"Auth": {
"JWT": {
"PointrClientSecret": "{Your JWT client secret here}"
}
}
}
Docker-compose form of environment variables.
environment:
Auth__JWT__PointrClientSecret: "{Your JWT client secret here"
- JWT: Configuration for JSON Web Token (JWT) authentication.
- PointrClientSecret: Secret key used for generating and validating JWT tokens, ensuring secure communication and access control in the application.
5. Serilog
{
"Serilog": {
"Using": [ "Serilog.Sinks.Console" ],
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"System": "Information",
"Microsoft.EntityFrameworkCore.Database.Command": "Warning",
"Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor": "Warning"
}
},
"WriteTo": [
{
"Name": "Console",
"Args": {
"theme": "Serilog.Sinks.SystemConsole.Themes.SystemConsoleTheme::Literate, Serilog.Sinks.Console",
"outputTemplate": "[{Level} {@Timestamp:yyyy-MM-dd HH:mm:ss}] [Message: {Message} {Exception}]{NewLine}"
}
},
{
"Name": "CustomFile",
"Args": {
"path": "logs/log-.txt"
}
}
],
"Enrich": ["FromLogContext", "WithMachineName", "WithProcessId", "WithThreadId"],
"Destructure": [
{
"Name": "ToMaximumDepth",
"Args": { "maximumDestructuringDepth": 20 }
},
{
"Name": "ToMaximumStringLength",
"Args": { "maximumStringLength": 5000 }
},
{
"Name": "ToMaximumCollectionCount",
"Args": { "maximumCollectionCount": 20 }
}
],
"Properties": {
"Application": "Pointr.Microservice.Utility.API"
}
}
}
Docker-compose form of environment variables.
environment:
Serilog__Using__0: "Serilog.Sinks.Console"
Serilog__MinimumLevel__Default: "Information"
Serilog__MinimumLevel__Override__Microsoft: "Information"
Serilog__MinimumLevel__Override__System: "Information"
Serilog__MinimumLevel__Override__Microsoft.EntityFrameworkCore.Database.Command: "Warning"
Serilog__MinimumLevel__Override__Microsoft.AspNetCore.Mvc.Infrastructure.ObjectResultExecutor: "Warning"
Serilog__WriteTo__0__Name: "Console"
Serilog__WriteTo__0__Args__theme: "Serilog.Sinks.SystemConsole.Themes.SystemConsoleTheme::Literate, Serilog.Sinks.Console"
Serilog__WriteTo__0__Args__outputTemplate: "[{Level} {@Timestamp:yyyy-MM-dd HH:mm:ss}] [Message: {Message} {Exception}]{NewLine}"
Serilog__WriteTo__1__Name: "CustomFile"
Serilog__WriteTo__1__Args__path: "logs/log-.txt"
Serilog__Enrich__0: "FromLogContext"
Serilog__Enrich__1: "WithMachineName"
Serilog__Enrich__2: "WithProcessId"
Serilog__Enrich__3: "WithThreadId"
Serilog__Destructure__0__Name: "ToMaximumDepth"
Serilog__Destructure__0__Args__maximumDestructuringDepth: "20"
Serilog__Destructure__1__Name: "ToMaximumStringLength"
Serilog__Destructure__1__Args__maximumStringLength: "5000"
Serilog__Destructure__2__Name: "ToMaximumCollectionCount"
Serilog__Destructure__2__Args__maximumCollectionCount: "20"
Serilog__Properties__Application: "Pointr.Microservice.Utility.API"
- Using: Specifies the Serilog sinks in use, such as
"Serilog.Sinks.Console"
for console logging. - MinimumLevel: Sets the minimum logging level to
Warning
, with specific overrides available for Microsoft and System namespaces. - WriteTo: Defines where log output is sent, using a compact JSON formatter for console output.
- Enrich: Add contextual data to logs, such as machine name and process ID.
- Destructure: Configures destructuring with limits on depth, string length, and collection count to manage log size and detail.
- Properties: Additional properties to include in every log, like specifying the application name.
Notes:
This documentation is designed to make the configuration more comprehensible and guide you in making necessary adjustments where needed. It includes explanations of what each setting is for and important considerations when making changes.