Skip to content

Commit 25257dc

Browse files
authored
Addressing comments.
1 parent 025b5db commit 25257dc

File tree

1 file changed

+13
-10
lines changed

1 file changed

+13
-10
lines changed

articles/azure-app-configuration/quickstart-python-provider.md

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -174,32 +174,35 @@ Add the following key-values to the App Configuration store. For more informatio
174174
175175
## Web app usage
176176
177-
You can use Azure App Configuration in your existing python Web Apps by adding the following lines of code into your `settings.py` (For Django) or `app.py` (for Flask) files.
177+
### [Django](#tab/django)
178+
You can use Azure App Configuration in your existing Django web apps by adding the following lines of code into your `settings.py` file
179+
178180
```python
179181
selects = {SettingSelector(key_filter="<your-key-filter>")}
180-
config = load(connection_string=os.environ.get("AZURE_APPCONFIG_CONNECTION_STRING"),
181-
selects=selects,
182-
trim_prefixes=["<prefix-to-trim>"])
182+
CONFIG = load(connection_string=os.environ.get("AZURE_APPCONFIG_CONNECTION_STRING"), selects=selects)
183183
```
184184

185-
### Configuration settings in Django
186-
187185
To update individual configuration settings in the Django `settings.py` file, you can reference them from the provider object. For example:
188186
```python
189-
MESSAGE = config.get("message")
187+
MESSAGE = CONFIG.get("message")
190188
```
191189

192-
### Configuration settings in Flask
190+
### [Flask](#tab/flask)
191+
You can use Azure App Configuration in your existing Flask web apps by updating its in-built configuration. You can do this by passing your App Configuration Provider object to the `update` function of your flask app instance in `app.py`:
193192

194-
You can update the in-built configuration object in Flask by passing your App Configuration Provider object to the `update` function of your flask app instance in `app.py`:
195193
```python
194+
selects = {SettingSelector(key_filter="<your-key-filter>")}
195+
azure_app_config = load(connection_string=os.environ.get("AZURE_APPCONFIG_CONNECTION_STRING"), selects=selects)
196+
196197
# NOTE: This will override all existing configuration settings with the same key name.
197-
app.update(config)
198+
app.config.update(azure_app_config)
198199

199200
# Access a configuration setting directly from within flask configuration
200201
json_value = app.config.get("my_json")
201202
```
202203

204+
---
205+
203206
Full code samples on how Azure App Configuration is used in python web apps can be found in the [Azure App Configuration Python Samples](https://github.com/Azure/AppConfiguration/tree/main/examples/Python) repo.
204207

205208
## Clean up resources

0 commit comments

Comments
 (0)