Where can I find some documentation regarding which options are available on the hosting.json
file? Right now I'm using the server.ulrs
but I'm wondering if I can add the https certificate path/password on it.
My hosting.json
:
{
"server.urls": "http://0.0.0.0:80;https://0.0.0.0:443"
}
Where I'm using it:
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("hosting.json", optional: true) // <<<<<<<<< LOADING FILE
.Build();
var host = new WebHostBuilder()
.UseKestrel()
.UseConfiguration(config) // <<<<<<<<<<< USING IT
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()
.Build();
host.Run();
}
The host. json file is a configuration file containing the values that affect all the functions of a function app. This file is created as soon as we add an Azure Function project. This file will have at least one field to begin with, indicating the runtime version of Azure Functions.
The host. json metadata file contains configuration options that affect all functions in a function app instance. This article lists the settings that are available starting with version 2. x of the Azure Functions runtime.
I'm wondering if can I add the https certificate path/password on it.
Out of the box, you cannot use hosting.json to set up your HTTPs certificate and credentials. You can, though, write custom code to support that scenario. There is a GitHub issue about that with a sample project by the Tratcher.
Where can I find ... documentation regarding ... options ... available in the hosting.json file?
The hosting.json file usually passes its options to the WebHostBuilder.UseConfiguration
method.
This is that static class:
public static class WebHostDefaults
{
public static readonly string ApplicationKey = "applicationName";
public static readonly string StartupAssemblyKey = "startupAssembly";
public static readonly string DetailedErrorsKey = "detailedErrors";
public static readonly string EnvironmentKey = "environment";
public static readonly string WebRootKey = "webroot";
public static readonly string CaptureStartupErrorsKey = "captureStartupErrors";
public static readonly string ServerUrlsKey = "urls";
public static readonly string ContentRootKey = "contentRoot";
}
For instance, the following hosting.json file...
{
"urls": "http://localhost:12345;http://localhost:54321",
"contentRoot": "C:\\foobar",
"environment": "QualityAssurance"
}
...and the following entry point...
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
public class Program
{
public static void Main(string[] args)
{
var config = new ConfigurationBuilder()
.AddJsonFile("hosting.json", optional: false)
.Build();
var host = new WebHostBuilder()
.UseConfiguration(config)
.UseKestrel()
.UseStartup<Startup>()
.Build();
host.Run();
}
}
...leads to the following output...
PS C:\temp> dotnet run
Hosting environment: QualityAssurance
Content root path: C:\foobar
Now listening on: http://localhost:12345
Now listening on: http://localhost:54321
Application started. Press Ctrl+C to shut down.
urls
instead of server.urls
. The latter is listed as the DeprecatedServerUrlsKey
in the GitHub.com/aspnet/hosting repository.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With