Skip to content

Commit 2cf11c0

Browse files
committed
quickstartaad
1 parent 749cd99 commit 2cf11c0

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

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

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,44 @@ In this section, you will create a console application and load data from your A
5757

5858
1. Create a new file called *app-configuration-quickstart.py* in the *app-configuration-quickstart* directory and add the following code:
5959

60+
### [Microsoft Entra ID (recommended)](#tab/entra-id)
61+
You use the `DefaultAzureCredential` to authenticate to your App Configuration store. Follow the [instructions](./concept-enable-rbac.md#authentication-with-token-credentials) to assign your credential the **App Configuration Data Reader** role. Be sure to allow sufficient time for the permission to propagate before running your application.
62+
63+
```python
64+
from azure.appconfiguration.provider import (
65+
load,
66+
SettingSelector
67+
)
68+
from azure.identity import DefaultAzureCredential
69+
import os
70+
71+
endpoint = os.environ.get("AZURE_APPCONFIG_ENDPOINT")
72+
73+
# Connect to Azure App Configuration using a connection string.
74+
config = load(endpoint=endpoint, credential=credential)
75+
credential = DefaultAzureCredential()
76+
77+
# Find the key "message" and print its value.
78+
print(config["message"])
79+
# Find the key "my_json" and print the value for "key" from the dictionary.
80+
print(config["my_json"]["key"])
81+
82+
# Connect to Azure App Configuration using a connection string and trimmed key prefixes.
83+
trimmed = {"test."}
84+
config = load(endpoint=endpoint, credential=credential, trim_prefixes=trimmed)
85+
# From the keys with trimmed prefixes, find a key with "message" and print its value.
86+
print(config["message"])
87+
88+
# Connect to Azure App Configuration using SettingSelector.
89+
selects = {SettingSelector(key_filter="message*", label_filter="\0")}
90+
config = load(endpoint=endpoint, credential=credential, selects=selects)
91+
92+
# Print True or False to indicate if "message" is found in Azure App Configuration.
93+
print("message found: " + str("message" in config))
94+
print("test.message found: " + str("test.message" in config))
95+
```
96+
97+
### [Connection string](#tab/connection-string)
6098
```python
6199
from azure.appconfiguration.provider import (
62100
load,

0 commit comments

Comments
 (0)