IsoplaneHosting.CreateBuilder method
Creates the application's builder. Use it in Program.cs in place of WebApplication.CreateBuilder.
public static WebApplicationBuilder CreateBuilder(string[] args)
| parameter | description |
|---|---|
| args | The arguments of Program.cs; pass args. Isoplane starts an application with none. |
Return Value
An ordinary WebApplicationBuilder, set up so that Isoplane delivers the application's requests and collects its logs.
Remarks
Finish Program.cs with await app.RunAsync(). The synchronous app.Run() would block, which an application on Isoplane cannot do, and the build rejects it.
builder.Configuration is layered as in any ASP.NET application, a later source overriding an earlier one: appsettings.json, then appsettings.{Environment}.json, then the settings Isoplane supplies. In local development the supplied settings are the project's User Secrets and the environmentVariables of its launch profile, and a sandbox test can add its own; the application sees none of the machine's environment variables. Supply local development settings describes each source. The environment name comes from the supplied ASPNETCORE_ENVIRONMENT or DOTNET_ENVIRONMENT setting, and is Production without one. The Logging configuration section sets log levels.
ILogger output goes to the application's log, which local development shows in the terminal running the application. The console logger works as written: after builder.Logging.AddConsole(), AddJsonConsole, AddSimpleConsole or AddSystemdConsole, each entry reaches the log as the chosen formatter writes it, in place of Isoplane's own record, and an entry the console logger sends to standard error is recorded at the log's error level. ClearProviders removes Isoplane's provider with the others, so an application that adds none after it logs nothing.
Isoplane runs Program.cs during template preparation, up to RunAsync, and saves the result as the template every instance starts from. The supplied settings are available while it runs, and they are the settings every instance has: when one changes, the application is prepared again with the new value. Program.cs can therefore read a connection string and use it, for example to warm a route that queries a database.
Some tools run Program.cs on your own machine rather than under Isoplane: dotnet ef, for one, and an in-process test host. The builder then behaves as WebApplication.CreateBuilder does. It reads the appsettings files, User Secrets in the Development environment and the machine's environment variables, and logs to the console.
See Also
- class IsoplaneHosting
- namespace Isoplane.AspNetCore