@@ -6,11 +6,12 @@ footer: 'https://chris-ayers.com'
66
77<!-- _footer: 'https://github.com/codebytes/dotnet-configuration-in-depth' -->
88
9- ![ bg left] ( ./img/dotnet-logo.png )
10-
119# .NET Configuration in Depth
10+
1211## Chris Ayers
1312
13+ ![ bg left] ( ./img/dotnet-logo.png )
14+
1415---
1516
1617![ bg left:40%] ( ./img/portrait.png )
@@ -23,14 +24,15 @@ footer: 'https://chris-ayers.com'
2324<i class =" fa-brands fa-linkedin " ></i > LinkedIn: - [ chris\- l\- ayers] ( https://linkedin.com/in/chris-l-ayers/ )
2425<i class =" fa fa-window-maximize " ></i > Blog: [ https://chris-ayers\.com/ ] ( https://chris-ayers.com/ )
2526<i class =" fa-brands fa-github " ></i > GitHub: [ Codebytes] ( https://github.com/codebytes )
26- <i class =" fa-brands fa-mastodon " ></i > Mastodon: @Chrisayers @hachyderm.io
27+ <i class =" fa-brands fa-mastodon " ></i > Mastodon: [ @Chrisayers @hachyderm.io] ( https://hachyderm.io/@Chrisayers )
2728~~ <i class =" fa-brands fa-twitter " ></i > Twitter: @Chris_L_Ayers~~
2829
2930---
3031
3132![ bg right:40% auto] ( ./img/dotnet-logo.png )
3233
3334# Agenda
35+
3436- What is configuration?
3537- How does .NET Framework handle configuration?
3638- How does .NET and ASP.NET handle configuration?
@@ -47,22 +49,25 @@ footer: 'https://chris-ayers.com'
4749<div >
4850
4951## <i class =" fa fa-sliders " ></i > Settings
50- * Retry Times
51- * Queue Length
52+
53+ - Retry Times
54+ - Queue Length
5255
5356</div >
5457<div >
5558
5659## <i class =" fa-sharp fa-solid fa-flag " ></i > Feature Flags
57- * Per User
58- * Percentage
60+
61+ - Per User
62+ - Percentage
5963
6064</div >
6165<div >
6266
6367## <i class =" fa fa-key " ></i > Secrets
64- * Connection Strings
65- * App Registration
68+
69+ - Connection Strings
70+ - App Registration
6671
6772</div >
6873</div >
@@ -98,13 +103,13 @@ footer: 'https://chris-ayers.com'
98103
99104# Web.Config
100105
101- * Limited to Key\- Value string pairs
102- * Accessed through a static ConfigurationManager Class
103- * Dependency Injection was not provided out of the box
104- * Transformation through difficult syntax
105- * Slow Cheetah
106- * Hard to unit test
107- * Easy to leak secrets
106+ - Limited to Key\- Value string pairs
107+ - Accessed through a static ConfigurationManager Class
108+ - Dependency Injection was not provided out of the box
109+ - Transformation through difficult syntax
110+ - Slow Cheetah
111+ - Hard to unit test
112+ - Easy to leak secrets
108113
109114---
110115
@@ -141,7 +146,6 @@ footer: 'https://chris-ayers.com'
141146
142147```
143148
144-
145149``` csharp
146150 private string greeting = " " ;
147151 private int majorDotNetVersion = 0 ;
@@ -160,7 +164,6 @@ footer: 'https://chris-ayers.com'
160164
161165# .NET Core/5/6/7/8 <br /> ASP.NET Configuration
162166
163-
164167![ bg left fit 90%] ( ./img/gears.png )
165168
166169---
@@ -173,7 +176,6 @@ footer: 'https://chris-ayers.com'
173176
174177# Order Matters
175178
176-
177179![ center width:980] ( ./img/configuration-source.png )
178180
179181---
@@ -230,6 +232,7 @@ Settings? settings =
230232---
231233
232234# Hierarchical Configuration Data
235+
233236## Keys are Flattened
234237
235238<div class =" columns " >
@@ -252,14 +255,14 @@ Settings? settings =
252255</div >
253256<div >
254257
255-
256258``` json
257259{
258260 "Parent:FavoriteNumber" : 7 ,
259261 "Parent:Child:Name" : " Example" ,
260262 "Parent:Child:GrandChild:Age" : 3
261263}
262264```
265+
263266</div >
264267</div >
265268
@@ -271,12 +274,14 @@ Settings? settings =
271274<div >
272275
273276## <i class =" fa fa-terminal " ></i > Console
274- - No Configuration
277+
278+ - No Configuration
275279
276280</div >
277281<div >
278282
279283## .NET Generic Host
284+
280285- JSON
281286 - appsettings.json
282287 - appsettings.{Environment}.json
@@ -288,6 +293,7 @@ Settings? settings =
288293<div >
289294
290295## <i class =" fa-regular fa-window-maximize " ></i > ASP.NET
296+
291297- JSON
292298 - appsettings.json
293299 - appsettings.{Environment}.json
@@ -302,27 +308,27 @@ Settings? settings =
302308
303309# Configuration Providers
304310
305-
306311<div class =" columns " >
307312<div >
308313
309314## File-based
310- * JSON
311- * XML
312- * INI
313- * Key-per-file
315+
316+ - JSON
317+ - XML
318+ - INI
319+ - Key-per-file
314320
315321</div >
316322<div >
317323
318324## Others
319325
320- * Environment variables
321- * Command-line
322- * In-Memory
323- * User Secrets
324- * Azure Key Vault
325- * Azure App Configuration
326+ - Environment variables
327+ - Command-line
328+ - In-Memory
329+ - User Secrets
330+ - Azure Key Vault
331+ - Azure App Configuration
326332
327333</div >
328334</div >
@@ -337,6 +343,7 @@ Settings? settings =
337343``` xml
338344<PackageReference Include =" Microsoft.Extensions.Configuration.Json" Version =" 8.0.0" />
339345```
346+
340347``` csharp
341348IHostEnvironment env = builder .Environment ;
342349
@@ -378,6 +385,7 @@ builder.Configuration
378385``` xml
379386<PackageReference Include =" Microsoft.Extensions.Configuration.Xml" Version =" 8.0.0" />
380387```
388+
381389``` csharp
382390IHostEnvironment env = builder .Environment ;
383391
@@ -419,6 +427,7 @@ builder.Configuration
419427``` xml
420428<PackageReference Include =" Microsoft.Extensions.Configuration.Ini" Version =" 8.0.0" />
421429```
430+
422431``` csharp
423432IHostEnvironment env = builder .Environment ;
424433
@@ -483,7 +492,7 @@ set TransientFaultHandlingOptions__AutoRetryDelay="00:00:13"
483492<div class =" columns " >
484493<div >
485494
486- - There are built-in prefixes, like
495+ - There are built-in prefixes, like
487496 - ASPNETCORE_ for ASP.NET Core
488497 - DOTNET_ for .NET Core
489498- You can provide your own prefix
@@ -495,12 +504,14 @@ set TransientFaultHandlingOptions__AutoRetryDelay="00:00:13"
495504builder .Configuration .AddEnvironmentVariables (
496505 prefix : " MyCustomPrefix_" );
497506```
507+
498508``` bash
499509set MyCustomPrefix_MyKey=" My key with MyCustomPrefix_"
500510set MyCustomPrefix_Position__Title=Editor_with_custom
501511set MyCustomPrefix_Position__Name=Environment
502512dotnet run
503513```
514+
504515</div >
505516</div >
506517
@@ -535,7 +546,6 @@ dotnet run
535546- Must be non-abstract with a public parameterless constructor
536547- Contain public read-write properties to bind (fields are not bound)
537548
538-
539549</div >
540550<div >
541551
@@ -576,11 +586,13 @@ public class FileOptions
576586
577587## Resources
578588
579- #### GitHub Repo
580- #### https://github.com/codebytes/dotnet-configuration-in-depth
589+ ### GitHub Repo
581590
582- #### Blog
583- #### https://chris-ayers.com
591+ - [ https://github.com/codebytes/dotnet-configuration-in-depth ] ( https://github.com/codebytes/dotnet-configuration-in-depth )
592+
593+ ### Docs
594+
595+ - [ .NET Configuration Docs] ( https://learn.microsoft.com/en-us/dotnet/core/extensions/configuration )
584596
585597</div >
586598
@@ -594,8 +606,8 @@ public class FileOptions
594606<i class =" fa-brands fa-linkedin " ></i > LinkedIn: - [ chris\- l\- ayers] ( https://linkedin.com/in/chris-l-ayers/ )
595607<i class =" fa fa-window-maximize " ></i > Blog: [ https://chris-ayers\.com/ ] ( https://chris-ayers.com/ )
596608<i class =" fa-brands fa-github " ></i > GitHub: [ Codebytes] ( https://github.com/codebytes )
597- <i class =" fa-brands fa-mastodon " ></i > Mastodon: @Chrisayers @hachyderm.io
609+ <i class =" fa-brands fa-mastodon " ></i > Mastodon: [ @Chrisayers @hachyderm.io] ( https://hachyderm.io/@Chrisayers )
598610~~ <i class =" fa-brands fa-twitter " ></i > Twitter: @Chris_L_Ayers~~
599611
600612</div >
601- </div >
613+ </div >
0 commit comments