Skip to content

Commit a558633

Browse files
committed
Update quickstart-feature-flag-python.md
1 parent 324b3a4 commit a558633

File tree

1 file changed

+23
-10
lines changed

1 file changed

+23
-10
lines changed

articles/azure-app-configuration/quickstart-feature-flag-python.md

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,16 +45,18 @@ Add a feature flag called *Beta* to the App Configuration store and leave **Labe
4545

4646
```python
4747
from featuremanagement import FeatureManager
48+
from azure.identity import InteractiveBrowserCredential
4849
from azure.appconfiguration.provider import load
4950
import os
5051
from time import sleep
5152
52-
connection_string = os.environ["APP_CONFIGURATION_CONNECTION_STRING"]
53+
endpoint = os.environ["APP_CONFIGURATION_ENDPOINT"]
5354
54-
# Connecting to Azure App Configuration using a connection string
55+
# Connecting to Azure App Configuration using an endpoint
56+
# credential is used to authenticate the client, the InteractiveBrowserCredential is used for this sample. It will open a browser window to authenticate the user. For all credential options see [credential classes](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credential-classes).
5557
# feature_flag_enabled makes it so that the provider will load feature flags from Azure App Configuration
5658
# feature_flag_refresh_enabled makes it so that the provider will refresh feature flags from Azure App Configuration, when the refresh operation is triggered
57-
config = load(connection_string=connection_string, feature_flag_enabled=True, feature_flag_refresh_enabled=True)
59+
config = load(endpoint=endpoint, credential=InteractiveBrowserCredential(), feature_flag_enabled=True, feature_flag_refresh_enabled=True)
5860
5961
feature_manager = FeatureManager(config)
6062
@@ -68,14 +70,14 @@ Add a feature flag called *Beta* to the App Configuration store and leave **Labe
6870
print("Beta is ", feature_manager.is_enabled("Beta"))
6971
```
7072

71-
1. Set an environment variable named **APP_CONFIGURATION_CONNECTION_STRING**, and set it to the connection string to your App Configuration store. At the command line, run the following command and restart the command prompt to allow the change to take effect:
73+
1. Set an environment variable named **APP_CONFIGURATION_ENDPOINT**, and set it to the connection string to your App Configuration store. At the command line, run the following command and restart the command prompt to allow the change to take effect:
7274

7375
### [Windows command prompt](#tab/windowscommandprompt)
7476

7577
To build and run the app locally using the Windows command prompt, run the following command:
7678

7779
```console
78-
setx APP_CONFIGURATION_CONNECTION_STRING "connection-string-of-your-app-configuration-store"
80+
setx APP_CONFIGURATION_ENDPOINT "endpoing-of-your-app-configuration-store"
7981
```
8082

8183
Restart the command prompt to allow the change to take effect. Validate that it's set properly by printing the value of the environment variable.
@@ -85,15 +87,15 @@ Add a feature flag called *Beta* to the App Configuration store and leave **Labe
8587
If you use Windows PowerShell, run the following command:
8688

8789
```azurepowershell
88-
$Env:APP_CONFIGURATION_CONNECTION_STRING = "connection-string-of-your-app-configuration-store"
90+
$Env:APP_CONFIGURATION_ENDPOINT = "endpoing-of-your-app-configuration-store"
8991
```
9092

9193
### [macOS](#tab/unix)
9294

9395
If you use macOS, run the following command:
9496

9597
```console
96-
export APP_CONFIGURATION_CONNECTION_STRING='connection-string-of-your-app-configuration-store'
98+
export APP_CONFIGURATION_ENDPOINT='endpoing-of-your-app-configuration-store'
9799
```
98100

99101
Restart the command prompt to allow the change to take effect. Validate that it's set properly by printing the value of the environment variable.
@@ -103,7 +105,7 @@ Add a feature flag called *Beta* to the App Configuration store and leave **Labe
103105
If you use Linux, run the following command:
104106

105107
```console
106-
export APP_CONFIGURATION_CONNECTION_STRING='connection-string-of-your-app-configuration-store'
108+
export APP_CONFIGURATION_ENDPOINT='endpoing-of-your-app-configuration-store'
107109
```
108110

109111
Restart the command prompt to allow the change to take effect. Validate that it's set properly by printing the value of the environment variable.
@@ -130,7 +132,7 @@ Add a feature flag called *Beta* to the App Configuration store and leave **Labe
130132

131133
## Web applications
132134

133-
The following example shows how to update an existing web application, using Azure App Configuration with dynamic refresh to also use feature flags. See [Python Dynamic Configuration](./enable-dynamic-configuration-python.md) for a more detailed example of how to use dynamic refresh for configuration values.
135+
The following example shows how to update an existing web application, using Azure App Configuration with dynamic refresh to also use feature flags. See [Python Dynamic Configuration](./enable-dynamic-configuration-python.md) for a more detailed example of how to use dynamic refresh for configuration values. Before continuing, make sure you have the Beta feature flag enabled in your App Configuration store.
134136

135137
### [Flask](#tab/flask)
136138

@@ -142,6 +144,10 @@ from featuremanagement import FeatureManager
142144
...
143145

144146
global azure_app_config, feature_manager
147+
# Connecting to Azure App Configuration using an endpoint
148+
# credential is used to authenticate the client, the InteractiveBrowserCredential is used for this sample. It will open a browser window to authenticate the user. For all credential options see [credential classes](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credential-classes).
149+
# feature_flag_enabled makes it so that the provider will load feature flags from Azure App Configuration
150+
# feature_flag_refresh_enabled makes it so that the provider will refresh feature flags from Azure App Configuration, when the refresh operation is triggered
145151
azure_app_config = load(connection_string=os.environ.get("APP_CONFIGURATION_CONNECTION_STRING")
146152
refresh_on=[WatchKey("sentinel")],
147153
on_refresh_success=on_refresh_success,
@@ -179,6 +185,8 @@ Update your template `index.html` to use the new feature flags.
179185
</body>
180186
```
181187

188+
Once you have updated and run your application, you can see the feature flag in action, where the `Beta is enabled` message will appear on the page, but only if the feature flag is enabled in the App Configuration store.
189+
182190
> [!div class="mx-imgBorder"]
183191
> ![Enable feature flag beta enabled](media/manage-feature-flags/beta-enabled.png)
184192
@@ -192,7 +200,10 @@ Set up Azure App Configuration in your Django settings file, `settings.py` to lo
192200
from featuremanagement import FeatureManager
193201

194202
...
195-
203+
# Connecting to Azure App Configuration using an endpoint
204+
# credential is used to authenticate the client, the InteractiveBrowserCredential is used for this sample. It will open a browser window to authenticate the user. For all credential options see [credential classes](https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credential-classes).
205+
# feature_flag_enabled makes it so that the provider will load feature flags from Azure App Configuration
206+
# feature_flag_refresh_enabled makes it so that the provider will refresh feature flags from Azure App Configuration, when the refresh operation is triggered
196207
AZURE_APPCONFIGURATION = load(
197208
connection_string=os.environ.get("APP_CONFIGURATION_CONNECTION_STRING"),
198209
refresh_on=[WatchKey("sentinel")],
@@ -232,6 +243,8 @@ Update your template `index.html` to use the new configuration values.
232243
</body>
233244
```
234245

246+
Once you have updated and run your application, you can see the feature flag in action, where the `Beta is enabled` message will appear on the page, but only if the feature flag is enabled in the App Configuration store.
247+
235248
> [!div class="mx-imgBorder"]
236249
> ![Enable feature flag beta enabled](media/manage-feature-flags/beta-enabled.png)
237250

0 commit comments

Comments
 (0)