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: articles/azure-app-configuration/quickstart-dotnet-core-app.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -31,7 +31,7 @@ Add the following key-value to the App Configuration store and leave **Label** a
31
31
32
32
## Create a .NET console app
33
33
34
-
You use the [.NET command-line interface (CLI)](/dotnet/core/tools/) to create a new .NET console app project. The advantage of using the .NET CLI over Visual Studio is that it's available across the Windows, macOS, and Linux platforms. Alternatively, use the preinstalled tools available in the [Azure Cloud Shell](https://shell.azure.com).
34
+
You can use the [.NET command-line interface (CLI)](/dotnet/core/tools/) to create a new .NET console app project. The advantage of using the .NET CLI over Visual Studio is that it's available across the Windows, macOS, and Linux platforms. Alternatively, use the preinstalled tools available in the [Azure Cloud Shell](https://shell.azure.com).
#Customer intent: As a .NET Framework developer, I want to use feature flags to control feature availability quickly and confidently.
12
+
ms.date: 2/19/2024
13
+
ms.author: zhiyuanliang
14
+
#Customer intent: As a .NET developer, I want to use feature flags to control feature availability quickly and confidently.
14
15
---
15
-
# Quickstart: Add feature flags to a .NET Framework console app
16
+
# Quickstart: Add feature flags to a .NET/.NET Framework console app
16
17
17
-
In this quickstart, you incorporate Azure App Configuration into a .NET Framework app to create an end-to-end implementation of feature management. You can use the App Configuration service to centrally store all your feature flags and control their states.
18
+
In this quickstart, you incorporate Azure App Configuration into a .NET console app to create an end-to-end implementation of feature management. You can use the App Configuration service to centrally store all your feature flags and control their states.
18
19
19
20
The .NET Feature Management libraries extend the framework with feature flag support. These libraries are built on top of the .NET configuration system. They integrate with App Configuration through its .NET configuration provider.
20
21
21
22
## Prerequisites
22
23
23
24
- An Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free/).
24
25
- An App Configuration store. [Create a store](./quickstart-azure-app-configuration-create.md#create-an-app-configuration-store).
25
-
-[Visual Studio 2019](https://visualstudio.microsoft.com/vs)
1. In **Create a new project**, filter on the **Console** project type and click on **Console App (.NET Framework)**. Click **Next**.
43
+
1. In **Create a new project**, filter on the **Console** project type and select **Console App**. If you want to create a .NET Framework app, please select **Console App (.NET Framework)** instead. Click **Next**.
40
44
41
-
1. In **Configure your new project**, enter a project name. Under **Framework**, select **.NET Framework 4.8** or higher. Click **Create**.
45
+
1. In **Configure your new project**, enter a project name. If you are creating a .NET Framework app, please select **.NET Framework 4.7.2** or higher under **Framework**. Click **Create**.
42
46
43
-
## Connect to an App Configuration store
47
+
## Use the feature flag
44
48
45
49
1. Right-click your project, and select **Manage NuGet Packages**. On the **Browse** tab, search and add the following NuGet packages to your project.
46
50
@@ -49,61 +53,108 @@ Add a feature flag called *Beta* to the App Configuration store and leave **Labe
49
53
Microsoft.FeatureManagement
50
54
```
51
55
52
-
1. Open *Program.cs* and add the following statements:
56
+
Make sure that the version of `Microsoft.FeatureManagement` is greater than 3.1.0.
57
+
58
+
1. Open *Program.cs* and add the following statements.
53
59
54
60
```csharp
55
61
using Microsoft.Extensions.Configuration;
56
62
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
57
63
using Microsoft.FeatureManagement;
58
-
using System.Threading.Tasks;
59
64
```
60
65
61
-
1. Update the `Main` method to connect to App Configuration, specifying the `UseFeatureFlags` option so that feature flags are retrieved. Create a `ConfigurationFeatureDefinitionProvider` to provide feature flag definitions from the configuration and a `FeatureManager` to evaluate feature flags' state. Then display a message if the `Beta` feature flag is enabled.
66
+
1. Connect to App Configuration, specifying the `UseFeatureFlags` option so that feature flags are retrieved. Create a `ConfigurationFeatureDefinitionProvider` to provide feature flag definition from the configuration and a `FeatureManager` to evaluate feature flags' state. Then display a message if the `Beta` feature flag is enabled.
67
+
68
+
### [.NET](#tab/dotnet)
62
69
63
70
```csharp
64
-
public static async Task Main(string[] args)
65
-
{
66
-
IConfiguration configuration = new ConfigurationBuilder()
IFeatureDefinitionProvider featureDefinitionProvider = new ConfigurationFeatureDefinitionProvider(configuration);
83
105
84
-
Console.WriteLine("Hello World!");
85
-
Console.WriteLine("Press any key to continue ...");
86
-
Console.Read();
106
+
IFeatureManager featureManager = new FeatureManager(
107
+
featureDefinitionProvider,
108
+
new FeatureManagementOptions());
109
+
110
+
if (await featureManager.IsEnabledAsync("Beta"))
111
+
{
112
+
Console.WriteLine("Welcome to the beta!");
87
113
}
114
+
115
+
Console.WriteLine("Hello World!");
116
+
}
88
117
```
89
118
119
+
---
120
+
90
121
## Build and run the app locally
91
122
92
-
1. Set an environment variable named **ConnectionString** to the connection string of your App Configuration store. If you use the Windows command prompt, run the following command:
123
+
1. Set an environment variable named **ConnectionString** to the connection string of your App Configuration store.
1. Restart Visual Studio to allow the change to take effect.
105
146
106
-
1. Press Ctrl + F5 to build and run the console app.
147
+
1. Press Ctrl + F5 to build and run the application.
148
+
149
+
1. You should see the following outputs in the console.
150
+
151
+

152
+
153
+
1. Sign in to the [Azure portal](https://portal.azure.com). Select **All resources**, and select the App Configuration store that you created previously.
154
+
155
+
1. Select **Feature manager** and locate the **Beta** feature flag. Enable the flag by selecting the checkbox under **Enabled**.
156
+
157
+
1. Run the application again. You should see the Beta message in the console.
107
158
108
159

109
160
@@ -113,7 +164,12 @@ Add a feature flag called *Beta* to the App Configuration store and leave **Labe
113
164
114
165
## Next steps
115
166
116
-
In this quickstart, you created a feature flag in App Configuration and used it with a .NET Framework console app. To learn how to dynamically update feature flags and other configuration values without restarting the application, continue to the next tutorial.
167
+
In this quickstart, you created a feature flag in App Configuration and used it with a console app. To learn how to dynamically update feature flags and other configuration values without restarting the application, continue to the next tutorial.
0 commit comments