I can’t remember where I saw this, but I followed the advice on the blog when setting up my application configuration for my .NET Core MVC application. I created such a model to save some settings that I need for the application:
public class BasePathSettings
{
public string BaseImageFolder { get; set; }
public string BaseApiUrl { get; set; }
}
My StartUp has this ...
public void ConfigureServices(IServiceCollection services)
{
...
services.Configure<BasePathSettings>(Configuration.GetSection("BasePathSettings"));
....
}
And appsettings.json has this in it:
"BasePathSettings": {
"BaseImageFolder": "D:\\Images\\",
"BaseApiUrl": "http://localhost:50321/"
},
I insert controllers that need this information, for example ...
private readonly BasePathSettings _settings;
public ClientsController(IOptions<BasePathSettings> settings)
{
_settings = settings.Value;
_client = new HttpClient();
_client.BaseAddress = new Uri(_settings.BaseApiUrl);
}
Running this on my localhost is fine.
However, when I deploy this application to Azure, I suggested that I need to create an application setting in the general application service settings. So I made an application setup called BasePathSettings and copied the json for the parameter to the value:
{ "BaseImageFolder": "imagePath", "BaseApiUrl": "apiUrl" }
, Azure barfs, ConfigureServices, , web.config NTFS. , , json Azure.
json? , -?