You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: Workshop.md
+15-11Lines changed: 15 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -34,14 +34,14 @@ time with each exercise and don't hesitate to experiment!
34
34
35
35
- Navigate to `src/Garage.ServiceDefaults/Services/IFeatureFlags.cs`
36
36
- Review the `EnableStatsHeader` flag interface
37
-
- Look at `FeatureFlags.cs` to see the default implementation
37
+
- Look at `FeatureFlags.cs` to see the environment variable implementation
38
38
39
39
2. Toggle the Statistics Header
40
40
41
-
- Locate where `EnableStatsHeader` is used in the web application
42
-
- Change the default value from `true` to `false`
43
-
-Observe the behavior change in the web frontend
44
-
- Toggle it back to `true`
41
+
- Locate the environment variables in `src/Garage.AppHost/Properties/launchSettings.json`
42
+
- Change the `ENABLE_STATS_HEADER` environment variable from `"true"` to `"false"`
43
+
-Restart the application to see the behavior change in the web frontend
44
+
- Toggle it back to `"true"`
45
45
46
46
3. Verify the Changes
47
47
@@ -52,7 +52,8 @@ time with each exercise and don't hesitate to experiment!
52
52
4. Create a New Feature Flag
53
53
54
54
- Add a new boolean flag in `IFeatureFlags.cs` (`EnableTabs`) making sure it is `true`
55
-
- Implement it in `FeatureFlags.cs`
55
+
- Implement it in `FeatureFlags.cs` to read from environment variable `ENABLE_TABS`
56
+
- Add the environment variable to `launchSettings.json` with value `"true"`
56
57
- Use this flag in the `.collection-tabs` div in the `Home.razor` file
57
58
58
59
### Expected Outcome
@@ -62,6 +63,9 @@ You should see the statistics header toggle on and off based on your feature fla
62
63
### Learning Outcomes
63
64
64
65
- Understand that feature flags are an application development practice that can be implemented basically (but as we'll see, can also become quite powerful and complex).
66
+
- Learn how environment variables can be used to configure feature flags at application startup.
67
+
68
+
**Note**: In this initial exercise, feature flags are configured using environment variables in the `launchSettings.json` file. Changes require an application restart. Later exercises will introduce dynamic flag updates through OpenFeature.
65
69
66
70
---
67
71
@@ -88,7 +92,7 @@ You should see the statistics header toggle on and off based on your feature fla
88
92
3. Implement a Custom Provider
89
93
90
94
- Create a new class `CustomFeatureProvider` in `src/Garage.ServiceDefaults/Providers`
91
-
- Use the `FeatureProvider`flags. Tip: You can copy the dictionary from `FeatureFlags.cs` to start and use the dictionary key as the flag key
95
+
- Use the `FeatureProvider`base class. Tip: You can implement a dictionary with the same flag keys and default values as used in the environment variables
92
96
- Add the provider to the OpenFeature configuration in `Extensions.cs`
93
97
94
98
4. Replace the IFeatureFlags dependency injection
@@ -383,10 +387,10 @@ You will have integrated telemetry for feature flags, allowing you to monitor th
383
387
384
388
Congratulations! You've completed the OpenFeature .NET workshop. You should now understand:
0 commit comments