1,151 questions
3
votes
1
answer
107
views
IConfiguration Bind doesn't work with arrays
I have to set a string array in the configuration when starting an ASP.NET Core web application. I get the string array from Azure Key Vault, and it works fine. It's only included in the code below ...
1
vote
1
answer
66
views
In VS (2022) how do I get appsetting.{environment}.json under appsetting.json when "envionment" has a dot in it
If I add an appsetting.{environment}.json to the project, normal it will automatically show up under the appsetting.json.
For example I added one for environment "Test".
But if I add one ...
0
votes
1
answer
167
views
Values are coming as null from appsettings.json , but configuration values like connection string are working fine
I'm working on an ASP.NET Core Web API project that used to work fine with IOptions<ApplicationSettings> to bind values from appsettings.json.
But suddenly, appSettings.Value is returning null, ...
2
votes
1
answer
101
views
Tell appsettings.json to just use the default but without deleting the key outright
I have an int setting in appsettings.json that I read from C#:
const int HardCodedDefault = 42;
int settingValue = configuration.GetValue<int>("myKey", HardCodedDefault);
...
0
votes
0
answers
41
views
Using Dev instance Minio url
1. ObjectStorageFramework Extension:
using ASobjectstorage.Interface;
using ASobjectstorage.Models;
using ASobjectstorage.Services;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions....
0
votes
1
answer
81
views
Serilog exclude database query log
I used to hide my SQL database logs from Console/Debug by adding this line of code in the Program.cs:
builder.Host.UseSerilog((builderContext, config) =>
{
config.ReadFrom.Configuration(...
0
votes
2
answers
179
views
Migrating from .NET Framework to .NET 9.0, How to access ConnectionStrings from a static class? (web.config vs appsettings.json)
I am in the process of migrating a large solution from .NET Framework 4.8 to .NET 9.0. I used .NET Upgrade Assistant to get started. I have a long way to go.
All of the projects in the solution have ...
0
votes
2
answers
56
views
.NET command line dependency injection fails when called from path
I have a command line app that uses .NET's dependency injection.
It works fine when called in its directory, like C:\GitHub\MyProject\bin\Debug\net9.0>MyApp
However, when I add it to the Path ...
0
votes
1
answer
93
views
How to get nested appSettings value(s) strongly typed?
I have this configuration in an ASP.NET Core MVC app:
"CustomSite": {
"Management": {
"Confined": {
"DefaultUILanguage": "en-GB&...
0
votes
2
answers
136
views
Set Const or static readonly field value from appsettings.json through dependency injection in .net core 9
I have this MagicSgtrings class that holds some constants which I'm using in my worker service.
internal class MagicStrings
{
public const string HttpClientName = "X_HttpClient";
...
}
...
-1
votes
1
answer
79
views
How to get the sasl.username & sasl.password in Dockerized ,net core application
i have a .net core application that uses event hub to consume & produce messages. it uses azure event hub & i configured sasl.username as "$ConnectionString" & sasl.password as &...
0
votes
3
answers
209
views
How can I set an app setting for configuring the logging filter for a category containing periods "." in an Azure Function app?
I have an Azure Function app that is configured with a "Information" logging filter for the MyCompany.IAM.AssetGovernance category:
appsettings.json
{
"Logging": {
"...
-1
votes
1
answer
350
views
Azure function app with SQL Trigger not working after deployment
I have an Azure Function app created locally using Python code, SQL Server change tracking that tracks any operation and triggers the SQL Server trigger for further process.
app = func.FunctionApp() ...
0
votes
0
answers
74
views
IConfiguration.GetRequiredSection("...").Get<> doesn't overwrite array property default value
Context:
I have a .net 8 console app and I have a poco mapped to a section of the appsetting.json file.
Code to deserialize the appsetting.json AppSettings section to the Poco:
_settings = ...
0
votes
1
answer
72
views
Can't load options from appsettings in ASP.NET Core site using IOptions
I'm trying to load data from my appsettings file in an ASP.NET Core project. I've done it before, but now I can't get it to work.
Furthermore, I'm trying to configure a section names Images and bind ...
0
votes
2
answers
598
views
Azure Function Servicebus Queue Trigger Parameters From Azure App Configuration Service
I'm trying to get my Function App Servicebus Queue Trigger to be used with the parameters for queue name and connection string fetched from App configuration Service in Azure.
My setup works for ...
0
votes
0
answers
62
views
GitLab CI/CD variables in appsettings.json for .NET Projects
Is there a simple way to simulate Azure DevOps Replace Token task in GitLab CI/CD?
I have the following secret (with many others) in appsettings.Testing.json that I need to replace in deploy stage:
&...
-1
votes
1
answer
137
views
Can I modify config values from appSettings in the app start up?
I have a .NET 8 application that uses the Options pattern for configuration: https://learn.microsoft.com/en-us/aspnet/core/fundamentals/configuration/options?view=aspnetcore-8.0
In my appSettings file ...
0
votes
0
answers
20
views
How to add a collection element in appsettings.production.json without overwriting the collection from appsettings.json
I want to add a collection element to application configuration for certain environments like production or development, without overwriting already present collection elements added earlier through ...
0
votes
1
answer
62
views
Set value in appsettings based on publish profile in .NET Core
I'm using .NET 6.0, my appsettings.json looks like this:
{
"Logging": {
"LogLevel": {
"Default": "Debug",
"System":...
2
votes
1
answer
66
views
How to use appsettings.json in program.cs without warning "ASP0000 Calling 'BuildServiceProvider' from application code results in an copy ..."
I am building a .net minimal api with a lot of settings defined via appsettings.json.
But how to use this setting classes in program.cs without the compiler generating the warning:
ASP0000 Calling '...
0
votes
1
answer
76
views
Get all FeatureFlags with a filter
I'm using a FeatureManager to handle all my feature and some of them have a filter that will query my Db.
It allows me to have something similar to Azure AppConfiguration but without spending anything....
0
votes
0
answers
66
views
.NET Core Appsettings get wrong values
I have appsettings storing different blob storage config. However, API occasionally will retrieve wrong blob storage config although it set to read the correct config.
Here's my code - Startup.cs:
...
0
votes
1
answer
679
views
Change ASP.NET Core application configuration sources order of precedence
I understand what the default order of preference is for ASP.NET Core as mentioned here MS Docs | Default application configuration sources. However I would like to know if it is possible to change ...
0
votes
0
answers
105
views
A good and simple way to set the connection string depending on whether we are testing the application or pushing it to production
I was tasked with upgrading the application version from .net core 2.0 to .net 8, since I'm doing it for the first time, I had to fix the code a bit. I noticed that in my company the connection string ...
0
votes
1
answer
84
views
Converting keys in appsettings.json to Azure Portal App Settings
My appsettings.json file looks like this:
{
"sqlDatabase": {
"name": "my-sql-db",
"connectionString": "my-connection-string-for-my-sql-db&...
0
votes
2
answers
84
views
How to access appsettings param inside .html file
In my .NET 6.0 / C# project, I have variable defined as
{
"Address": {
"AddressLine1": "220 E. Yut Drive Suite 20",
"AddressLine2": "...
0
votes
1
answer
137
views
Having difficulties including appsettings.override.json file in Blazor WebAssembly
Program.cs of Blazor Client
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.Configuration.AddJsonFile("appsettings.override.json", optional: false, reloadOnChange: false);
...
-1
votes
1
answer
89
views
Can i "outsource" the NLog-portion of appsettings.json?
I have a bunch of different appsettings.json for a number of customers. However, the nLog-portion of these appsettings never changes, so I'd love to have one single json-File for the nLog-config.
So I ...
0
votes
1
answer
380
views
Azure App Service - Why App Service environment variables doesn't work for virtual directory?
I have two web apps deployed in a single Azure App Service instance:
The first one has a home directory in "site\wwwroot".
The second (api) has a home directory in "site\wwwroot\...
0
votes
1
answer
51
views
How to read development settings when running in-memory test server?
I have an ASP.NET Core 8 Web API project which contains the following setting files:
appsettings.json
appsettings.Local.json
Following the instructions here, I also have a test project to run an in-...
0
votes
1
answer
82
views
Blazor Wasm Appsettings Base Url gets cut off after /
I am working with Blazor Wasm on .NET 8. I am attempting to publish my app to the dev server and QA server for the first time. I am running into an issue where all my API calls are failing. Looking at ...
0
votes
0
answers
298
views
Kestrel not using default certificate from appsettings.json
I've been using the default certificate from appSettings.json in a bunch of ASP.NET Core applications without any issues.
"Kestrel": {
"Certificates": {
"Default": {...
1
vote
1
answer
2k
views
.NET Core 8 appsettings.json not defaulted when env specific file is used
I've been working in Java the past few years and starting back into .NET now. I'm struggling with getting my configs working as I'd like.
I want to have this structure:
appsettings.json: default ...
0
votes
0
answers
158
views
Variable substitution in appsettings.json Not Working
I have a GitHub Actions workflow where I'm trying to substitute a connection string in the appsettings.json file before deploying to Kubernetes. However, the substitution step doesn't seem to be ...
0
votes
1
answer
267
views
ASP.NET Core 8 Blazor Server App - A suitable constructor could not be located
I have tried numerous approaches, unsuccessfully, to get the connection string from appsettings.json. If this is not the best approach, what approach would work?
Runtime error:
System....
0
votes
1
answer
76
views
Need to exclude checksiteNode parameter specified in the appsettings.json while releasing in the azure devops
We have a DTAP (DEv, Test, Acc and Prod) environments, and when we do a release in the env's for node specific. (In Acc and PROD I have 3 nodes), while trying to create a release in Azure DevOps,the ...
0
votes
1
answer
109
views
Issue with azure app service (linux) environment variable in ASP.NET Core app
I have an ASP.NET Core app with following setting files:
appsettings.json:
...
"AzureOpenAI": {
"EndPoint": "https://PRODUCTION.openai.azure.com/",
"ApiKey&...
0
votes
1
answer
489
views
Azure Function App .Net 8 version not able to bind the ServiceBusTrigger connection string value from appsettings.json
I have my servicebustrigger connection string in the appsettings.json file. function app 8 version can't able to bind the value.
Here is appsettings.json file
approach 1:
`{
"keyVault": &...
0
votes
1
answer
62
views
.NET Core configuration URL ampersand encoding
I have a URL that I'd like to keep in appsettings.json :
"MapLookupURL": "https://www.google.com/maps/search/?api=1&query=",
I then retrieve this string via:
window.open("...
0
votes
1
answer
45
views
Programmatically specify a value within appsettings.json
I am trying to set up a logging system that adds log files to subfolders based on the year. However I've been unable to programmatically specify the year. I can hardcode it and it works fine, but I ...
0
votes
1
answer
83
views
How to replace/expand environmental variables in AppSettings.json/DbContext for resolving local paths to SQLite while allowing overwrites of the path?
I have basically followed two docs. This simple here just explains a very simple EF SqLite configuration where DbContext just hardcodes .UseSqlite with a local path to "local application data&...
0
votes
2
answers
485
views
In YAML is it possible to supply a template json file for appsettings
I am adding some appsettings for a function app in YAML:
steps:
- download: current
displayName: Download app artifact
artifact: app
- task: AzureAppServiceSettings@1
displayName: Azure App ...
0
votes
1
answer
274
views
C# ASP.NET Core : support both appsettings.json and app.config
I have a shared the library that needs some input from the config file, let's say a database helper class with IConfiguration injected in the constructor.
I have an ASP.NET Core app that uses ...
0
votes
2
answers
286
views
How to fetch a key from appsettings.json to JavaScript page in .Net8
I wanted to fetch a key from appsettings.json file to javascript code in .net 8 MVC project.
i have added the key in appsetting.json in the below manner.
appsettings.json
{
"RequestCountlimit&...
2
votes
1
answer
494
views
Setup appsettings.json with transformation in Console Application of .net framework(4.8) and Reading in POCO Models
I have a .net framework based Solution which is having Console Application as the Entry point along with multiple dependent Class Library projects.
Console Application provides XML based configuration ...
2
votes
1
answer
242
views
Reading variables from app settings another time in Azure Function App
I have a function app, the app settings has several different PATs
One of the function is an HTTP trigger, the request body will contain a specific name
and that name should be used to retrieve the ...
0
votes
1
answer
891
views
Issues reading appsettings.(environment).json in singleton .NET Core 8
I am creating a Windows service in C# on .NET Core 8. This is my first attempt. The service works, but I now want to remove some hardcoded elements and move the settings into my appsettings.json file.
...
0
votes
1
answer
666
views
How to access connection string with python
I have this local.settings.json in my local Azure function (Timer trigger)
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"...
2
votes
1
answer
1k
views
How to access Azure Key Vault secrets as *configuration values transparently* in a ASP.NET Core Web App which is deployed to Azure App Services?
My question is about C# code reading secrets stored in KeyVault as configuration transparently. For example currently I have this appsettings.json:
"AzureAd": {
"Instance": &...