Skip to content

Commit 49fdd24

Browse files
use vs for .net app
1 parent 3ac2182 commit 49fdd24

File tree

2 files changed

+56
-134
lines changed

2 files changed

+56
-134
lines changed

articles/azure-app-configuration/index.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,9 +136,7 @@ landingContent:
136136
links:
137137
- text: ASP.NET Core app
138138
url: quickstart-feature-flag-aspnet-core.md
139-
- text: .NET app
140-
url: quickstart-feature-flag-dotnet.md
141-
- text: .NET Framework app
139+
- text: .NET/.NET Framework app
142140
url: quickstart-feature-flag-dotnet.md
143141
- text: Spring Boot app
144142
url: quickstart-feature-flag-spring-boot.md
Lines changed: 55 additions & 131 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
---
2-
title: Quickstart for adding feature flags to .NET apps
2+
title: Quickstart for adding feature flags to .NET/.NET Framework apps
33
titleSuffix: Azure App Configuration
4-
description: A quickstart for adding feature flags to .NET apps and managing them in Azure App Configuration.
4+
description: A quickstart for adding feature flags to .NET/.NET Framework apps and managing them in Azure App Configuration.
55
services: azure-app-configuration
6-
author: maud-lv
6+
author: zhiyuanliang
77
ms.service: azure-app-configuration
88
ms.devlang: csharp
99
ms.custom: devx-track-csharp, mode-other, devx-track-dotnet
@@ -23,12 +23,9 @@ The .NET Feature Management libraries extend the framework with feature flag sup
2323

2424
- An Azure account with an active subscription. [Create one for free](https://azure.microsoft.com/free/).
2525
- An App Configuration store. [Create a store](./quickstart-azure-app-configuration-create.md#create-an-app-configuration-store).
26-
- [.NET SDK 6.0 or later](https://dotnet.microsoft.com/download) - also available in the [Azure Cloud Shell](https://shell.azure.com).
27-
28-
If you want to use .NET Framework, please install the following things.
29-
3026
- [Visual Studio](https://visualstudio.microsoft.com/vs)
31-
- [.NET Framework 4.7.2 or later](https://dotnet.microsoft.com/download/dotnet-framework)
27+
- [.NET SDK 6.0 or later](https://dotnet.microsoft.com/download) for .NET console app.
28+
- [.NET Framework 4.7.2 or later](https://dotnet.microsoft.com/download/dotnet-framework) for .NET Framework console app.
3229

3330
## Add a feature flag
3431

@@ -37,82 +34,19 @@ Add a feature flag called *Beta* to the App Configuration store and leave **Labe
3734
> [!div class="mx-imgBorder"]
3835
> ![Enable feature flag named Beta](media/add-beta-feature-flag.png)
3936
40-
## Create a .NET console app
37+
## Create a console app
4138

4239
### [.NET](#tab/dotnet)
4340

44-
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).
45-
46-
1. Create a new folder for your project.
47-
48-
1. In the new folder, run the following command to create a new .NET console app project:
49-
50-
```dotnetcli
51-
dotnet new console
52-
```
53-
54-
### [.NET Framework](#tab/dotnet-framework)
55-
56-
You can use Visual Studio to create a new .NET Framework console app project.
41+
You can use Visual Studio to create a new console app project.
5742

5843
1. Start Visual Studio, and select **File** > **New** > **Project**.
5944

60-
1. In **Create a new project**, filter on the **Console** project type and click on **Console App (.NET Framework)**. Click **Next**.
61-
62-
1. In **Configure your new project**, enter a project name. Under **Framework**, select **.NET Framework 4.8** or higher. Click **Create**.
63-
64-
---
65-
66-
## Use feature flag
67-
68-
### [.NET](#tab/dotnet)
69-
70-
1. Add references to the `Microsoft.Extensions.Configuration.AzureAppConfiguration` and `Microsoft.FeatureManagement` NuGet packages by running the following commands.
71-
72-
```dotnetcli
73-
dotnet add package Microsoft.Extensions.Configuration.AzureAppConfiguration
74-
dotnet add package Microsoft.FeatureManagement
75-
```
76-
77-
1. Run the following command to restore packages for your project.
78-
79-
```dotnetcli
80-
dotnet restore
81-
```
82-
83-
1. Open *Program.cs* and add the following statements.
45+
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**.
8446

85-
```csharp
86-
using Microsoft.Extensions.Configuration;
87-
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
88-
using Microsoft.FeatureManagement;
89-
```
90-
91-
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.
92-
93-
```csharp
94-
IConfiguration configuration = new ConfigurationBuilder()
95-
.AddAzureAppConfiguration(options =>
96-
{
97-
options.Connect(Environment.GetEnvironmentVariable("ConnectionString"))
98-
.UseFeatureFlags();
99-
}).Build();
47+
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**.
10048

101-
IFeatureDefinitionProvider featureDefinitionProvider = new ConfigurationFeatureDefinitionProvider(configuration);
102-
103-
IFeatureManager featureManager = new FeatureManager(
104-
featureDefinitionProvider,
105-
new FeatureManagementOptions());
106-
107-
if (await featureManager.IsEnabledAsync("Beta"))
108-
{
109-
Console.WriteLine("Welcome to the beta!");
110-
}
111-
112-
Console.WriteLine("Hello World!");
113-
```
114-
115-
### [.NET Framework](#tab/dotnet-framework)
49+
## Use the feature flag
11650

11751
1. Right-click your project, and select **Manage NuGet Packages**. On the **Browse** tab, search and add the following NuGet packages to your project.
11852

@@ -127,19 +61,18 @@ You can use Visual Studio to create a new .NET Framework console app project.
12761
using Microsoft.Extensions.Configuration;
12862
using Microsoft.Extensions.Configuration.AzureAppConfiguration;
12963
using Microsoft.FeatureManagement;
130-
using System.Threading.Tasks;
13164
```
13265
133-
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.
13467
135-
```csharp
136-
public static async Task Main(string[] args)
137-
{
68+
### [.NET](#tab/dotnet)
69+
70+
```csharp
13871
IConfiguration configuration = new ConfigurationBuilder()
13972
.AddAzureAppConfiguration(options =>
14073
{
14174
options.Connect(Environment.GetEnvironmentVariable("ConnectionString"))
142-
.UseFeatureFlags();
75+
.UseFeatureFlags();
14376
}).Build();
14477
14578
IFeatureDefinitionProvider featureDefinitionProvider = new ConfigurationFeatureDefinitionProvider(configuration);
@@ -154,18 +87,44 @@ You can use Visual Studio to create a new .NET Framework console app project.
15487
}
15588
15689
Console.WriteLine("Hello World!");
157-
}
158-
```
90+
```
15991
160-
---
92+
### [.NET Framework](#tab/dotnet-framework)
93+
94+
```csharp
95+
public static async Task Main(string[] args)
96+
{
97+
IConfiguration configuration = new ConfigurationBuilder()
98+
.AddAzureAppConfiguration(options =>
99+
{
100+
options.Connect(Environment.GetEnvironmentVariable("ConnectionString"))
101+
.UseFeatureFlags();
102+
}).Build();
103+
104+
IFeatureDefinitionProvider featureDefinitionProvider = new ConfigurationFeatureDefinitionProvider(configuration);
105+
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!");
113+
}
114+
115+
Console.WriteLine("Hello World!");
116+
}
117+
```
118+
119+
---
161120
162121
## Build and run the app locally
163122
164-
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.
165124
166125
### [Windows command prompt](#tab/windowscommandprompt)
167126
168-
To build and run the app locally using the Windows command prompt, run the following command:
127+
If you use the Windows command prompt, run the following command.
169128
170129
```console
171130
setx ConnectionString "connection-string-of-your-app-configuration-store"
@@ -181,51 +140,11 @@ You can use Visual Studio to create a new .NET Framework console app project.
181140
$Env:ConnectionString = "connection-string-of-your-app-configuration-store"
182141
```
183142
184-
### [macOS](#tab/unix)
185-
186-
If you use macOS, run the following command.
187-
188-
```console
189-
export ConnectionString='connection-string-of-your-app-configuration-store'
190-
```
191-
192-
Restart the command prompt to allow the change to take effect. Print the value of the environment variable to validate that it's set properly.
193-
194-
### [Linux](#tab/linux)
195-
196-
If you use Linux, run the following command.
197-
198-
```console
199-
export ConnectionString='connection-string-of-your-app-configuration-store'
200-
```
201-
202-
Restart the command prompt to allow the change to take effect. Print the value of the environment variable to validate that it's set properly.
203-
204143
---
205144
206-
1. Build and run the application.
145+
1. Restart Visual Studio to allow the change to take effect.
207146
208-
### [.NET](#tab/dotnet)
209-
210-
- Run the following command to build the console app.
211-
212-
```dotnetcli
213-
dotnet build
214-
```
215-
216-
- After the build successfully completes, run the following command to run the app locally.
217-
218-
```dotnetcli
219-
dotnet run
220-
```
221-
222-
### [.NET Framework](#tab/dotnet-framework)
223-
224-
- Restart Visual Studio to allow the change to take effect.
225-
226-
- Press Ctrl + F5 to build and run the console app.
227-
228-
---
147+
1. Press Ctrl + F5 to build and run the application.
229148
230149
1. You should see the following outputs in the console.
231150
@@ -245,7 +164,12 @@ You can use Visual Studio to create a new .NET Framework console app project.
245164
246165
## Next steps
247166
248-
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.
168+
249169
250170
> [!div class="nextstepaction"]
251-
> [Enable dynamic configuration](./enable-dynamic-configuration-dotnet.md)
171+
> [Enable dynamic configuration in a .NET app](./enable-dynamic-configuration-dotnet-core.md)
172+
173+
> [!div class="nextstepaction"]
174+
> [Enable dynamic configuration in a .NET Framework app](./enable-dynamic-configuration-dotnet.md)
175+

0 commit comments

Comments
 (0)