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
In this section, you will create a console application and load data from your App Configuration store.
37
38
39
+
### Connect to App Configuration
38
40
1. Create a new directory for the project named *app-configuration-quickstart*.
39
41
40
42
```console
@@ -87,35 +89,35 @@ Add the following key-values to the App Configuration store. For more informatio
87
89
print("test.message found: " + str("test.message" in config))
88
90
```
89
91
90
-
## Configure your App Configuration connection string
92
+
### Run the application
91
93
92
94
1. Set an environment variable named **AZURE_APPCONFIG_CONNECTION_STRING**, and set it to the connection string of your App Configuration store. At the command line, run the following command:
To build and run the app locally using the Windows command prompt, run the following command and replace `<app-configuration-store-connection-string>` with the connection string of your app configuration store:
If you use Windows PowerShell, run the following command and replace `<app-configuration-store-connection-string>` with the connection string of your app configuration store:
If you use macOS, run the following command and replace `<app-configuration-store-connection-string>` with the connection string of your app configuration store:
If you use Linux, run the following command and replace `<app-configuration-store-connection-string>` with the connection string of your app configuration store:
121
123
@@ -125,31 +127,31 @@ Add the following key-values to the App Configuration store. For more informatio
125
127
126
128
1. Restart the command prompt to allow the change to take effect. Print out the value of the environment variable to validate that it is set properly with the command below.
Using the Windows command prompt, run the following command:
131
133
132
134
```cmd
133
135
printenv AZURE_APPCONFIG_CONNECTION_STRING
134
136
```
135
137
136
-
### [PowerShell](#tab/powershell)
138
+
#### [PowerShell](#tab/powershell)
137
139
138
140
If you use Windows PowerShell, run the following command:
139
141
140
142
```azurepowershell
141
143
$Env:AZURE_APPCONFIG_CONNECTION_STRING
142
144
```
143
145
144
-
### [macOS](#tab/unix)
146
+
#### [macOS](#tab/unix)
145
147
146
148
If you use macOS, run the following command:
147
149
148
150
```console
149
151
echo "$AZURE_APPCONFIG_CONNECTION_STRING"
150
152
```
151
153
152
-
### [Linux](#tab/linux)
154
+
#### [Linux](#tab/linux)
153
155
154
156
If you use Linux, run the following command:
155
157
@@ -172,6 +174,41 @@ Add the following key-values to the App Configuration store. For more informatio
172
174
test.message found: False
173
175
```
174
176
177
+
## Web applications
178
+
The App Configuration provider loads data into a `Mapping` object, accessible as a dictionary, which can be used in combination with the existing configuration of various Python frameworks. This section shows how to use the App Configuration provider in popular web frameworks like Flask and Django.
179
+
180
+
### [Flask](#tab/flask)
181
+
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`:
To access individual configuration settings in the Django views, you can reference them from the provider object created in Django settings. For example, in `views.py`:
201
+
```python
202
+
# Import Django settings
203
+
from django.conf import settings
204
+
205
+
# Access a configuration setting from Django settings instance.
206
+
MESSAGE= settings.CONFIG.get("message")
207
+
```
208
+
---
209
+
210
+
Full code samples on how to use Azure App Configuration in Python web applications can be found in the [Azure App Configuration](https://github.com/Azure/AppConfiguration/tree/main/examples/Python) GitHub repo.
0 commit comments