Skip to content

Commit f36165e

Browse files
authored
Fixing App Configuration Provider Readme (#46611)
* Updating readme * removing aad * fixing a few entra id items * updating snippets and samples * review items * Update test_azureappconfigurationproviderbase.py * Update README.md * fixing readme * fix snippets * Update README.md
1 parent 0d065a8 commit f36165e

16 files changed

Lines changed: 573 additions & 124 deletions

sdk/appconfiguration/azure-appconfiguration-provider/README.md

Lines changed: 318 additions & 64 deletions
Large diffs are not rendered by default.

sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/_load.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ def load( # pylint: disable=docstring-keyword-should-match-keyword-only
6565
configurations from azure-keyvault-secrets. This is optional if keyvault_credential is provided. If a credential
6666
isn't provided a credential will need to be in each set for each.
6767
:keyword Callable[[str], str] secret_resolver: A function that takes a URI and returns a value.
68+
:keyword int secret_refresh_interval: The interval in seconds at which to refresh resolved Key Vault secrets.
69+
Only applies when Key Vault references are being resolved. If not specified, secrets are not periodically
70+
refreshed. Minimum value is 1 second.
6871
:keyword List[Tuple[str, str]] refresh_on: One or more settings whose modification will trigger a full refresh
6972
after a fixed interval. This should be a list of Key-Label pairs for specific settings (filters and wildcards are
7073
not supported).
@@ -136,6 +139,9 @@ def load( # pylint: disable=docstring-keyword-should-match-keyword-only
136139
configurations from azure-keyvault-secrets. This is optional if keyvault_credential is provided. If a credential
137140
isn't provided a credential will need to be in each set for each.
138141
:keyword Callable[[str], str] secret_resolver: A function that takes a URI and returns a value.
142+
:keyword int secret_refresh_interval: The interval in seconds at which to refresh resolved Key Vault secrets.
143+
Only applies when Key Vault references are being resolved. If not specified, secrets are not periodically
144+
refreshed. Minimum value is 1 second.
139145
:keyword List[Tuple[str, str]] refresh_on: One or more settings whose modification will trigger a full refresh
140146
after a fixed interval. This should be a list of Key-Label pairs for specific settings (filters and wildcards are
141147
not supported).

sdk/appconfiguration/azure-appconfiguration-provider/azure/appconfiguration/provider/aio/_async_load.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,9 @@ async def load( # pylint: disable=docstring-keyword-should-match-keyword-only
6868
configurations from azure-keyvault-secrets. This is optional if keyvault_credential is provided. If a credential
6969
isn't provided a credential will need to be in each set for each.
7070
:keyword Callable[[str], str] secret_resolver: A function that takes a URI and returns a value.
71+
:keyword int secret_refresh_interval: The interval in seconds at which to refresh resolved Key Vault secrets.
72+
Only applies when Key Vault references are being resolved. If not specified, secrets are not periodically
73+
refreshed. Minimum value is 1 second.
7174
:keyword List[Tuple[str, str]] refresh_on: One or more settings whose modification will trigger a full refresh
7275
after a fixed interval. This should be a list of Key-Label pairs for specific settings (filters and wildcards are
7376
not supported).
@@ -139,6 +142,9 @@ async def load( # pylint: disable=docstring-keyword-should-match-keyword-only
139142
configurations from azure-keyvault-secrets. This is optional if keyvault_credential is provided. If a credential
140143
isn't provided a credential will need to be in each set for each.
141144
:keyword Callable[[str], str] secret_resolver: A function that takes a URI and returns a value.
145+
:keyword int secret_refresh_interval: The interval in seconds at which to refresh resolved Key Vault secrets.
146+
Only applies when Key Vault references are being resolved. If not specified, secrets are not periodically
147+
refreshed. Minimum value is 1 second.
142148
:keyword List[Tuple[str, str]] refresh_on: One or more settings whose modification will trigger a full refresh
143149
after a fixed interval. This should be a list of Key-Label pairs for specific settings (filters and wildcards are
144150
not supported).

sdk/appconfiguration/azure-appconfiguration-provider/samples/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ pip install azure.appconfiguration.provider
4646

4747
| File | Description |
4848
|-------------|-------------|
49-
| aad_sample.py | demos connecting to app configuration with Azure Active Directory |
49+
| entra_id_sample.py | demos connecting to app configuration with Entra ID |
5050
| connection_string_sample.py | demos connecting to app configuration with a Connection String |
5151
| key_vault_reference_sample.py | demos resolving key vault references with App Configuration |
5252

sdk/appconfiguration/azure-appconfiguration-provider/samples/aad_sample.py

Lines changed: 0 additions & 39 deletions
This file was deleted.

sdk/appconfiguration/azure-appconfiguration-provider/samples/async_aad_sample.py renamed to sdk/appconfiguration/azure-appconfiguration-provider/samples/async_entra_id_sample.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,22 @@ async def main():
1616
credential = get_credential(authority, is_async=True)
1717
kwargs = get_client_modifications()
1818

19-
# Connecting to Azure App Configuration using AAD
19+
# [START create_provider_entra_id_async]
20+
from azure.appconfiguration.provider.aio import load
21+
22+
# Connecting to Azure App Configuration using Entra ID
2023
config = await load(endpoint=endpoint, credential=credential, **kwargs)
2124
print(config["message"])
2225

2326
await credential.close()
2427
await config.close()
28+
# [END create_provider_entra_id_async]
2529

26-
# Connecting to Azure App Configuration using AAD and trim key prefixes
30+
# [START trim_prefixes_entra_id_async]
31+
# Connecting to Azure App Configuration using Entra ID and trim key prefixes
2732
trimmed = ["test."]
2833
config = await load(endpoint=endpoint, credential=credential, trim_prefixes=trimmed, **kwargs)
34+
# [END trim_prefixes_entra_id_async]
2935

3036
print(config["message"])
3137

sdk/appconfiguration/azure-appconfiguration-provider/samples/async_key_vault_reference_provided_clients_sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ async def main():
1717
credential = get_credential(authority, is_async=True)
1818
kwargs = get_client_modifications()
1919

20-
# Connection to Azure App Configuration using AAD with Provided Client
20+
# Connection to Azure App Configuration using Entra ID with Provided Client
2121
client_configs = {key_vault_uri: {"credential": credential}}
2222
selects = [SettingSelector(key_filter="*", label_filter="prod")]
2323
config = await load(

sdk/appconfiguration/azure-appconfiguration-provider/samples/async_key_vault_reference_sample.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ async def main():
1616
credential = get_credential(authority, is_async=True)
1717
kwargs = get_client_modifications()
1818

19-
# Connection to Azure App Configuration using AAD and Resolving Key Vault References
19+
# Connection to Azure App Configuration using Entra ID and Resolving Key Vault References
2020
selects = [SettingSelector(key_filter="*", label_filter="prod")]
2121

2222
config = await load(

sdk/appconfiguration/azure-appconfiguration-provider/samples/async_snapshot_sample.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
FeatureFlagConfigurationSetting,
1414
)
1515
from azure.identity.aio import DefaultAzureCredential
16+
from sample_utilities import get_client_modifications
1617
from azure.appconfiguration.provider.aio import load
1718
from azure.appconfiguration.provider import SettingSelector
1819

@@ -70,9 +71,11 @@ async def main():
7071
created_snapshot = await poller.result()
7172
print(f"Created snapshot: {created_snapshot.name} with status: {created_snapshot.status}")
7273

74+
kwargs = get_client_modifications()
75+
7376
# Step 2: Loading configuration settings from the snapshot
7477
snapshot_selects = [SettingSelector(snapshot_name=snapshot_name)]
75-
config = await load(endpoint=endpoint, credential=credential, selects=snapshot_selects)
78+
config = await load(endpoint=endpoint, credential=credential, selects=snapshot_selects, **kwargs)
7679

7780
print("Configuration settings from snapshot:")
7881
for key, value in config.items():
@@ -84,7 +87,7 @@ async def main():
8487
SettingSelector(snapshot_name=snapshot_name), # Load all settings from snapshot
8588
SettingSelector(key_filter="override.*", label_filter="prod"), # Also load specific override settings
8689
]
87-
config_mixed = await load(endpoint=endpoint, credential=credential, selects=mixed_selects)
90+
config_mixed = await load(endpoint=endpoint, credential=credential, selects=mixed_selects, **kwargs)
8891

8992
print("\nMixed configuration (snapshot + filtered settings):")
9093
for key, value in config_mixed.items():
@@ -98,6 +101,7 @@ async def main():
98101
credential=credential,
99102
selects=feature_flag_selects,
100103
feature_flag_enabled=True,
104+
**kwargs,
101105
)
102106

103107
print(f"\nFeature flags loaded: {'feature_management' in config_with_flags}")

sdk/appconfiguration/azure-appconfiguration-provider/samples/connection_string_sample.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,21 +10,36 @@
1010
kwargs = get_client_modifications()
1111
connection_string = os.environ["APPCONFIGURATION_CONNECTION_STRING"]
1212

13+
# [START create_provider_connection_string]
14+
import os
15+
from azure.appconfiguration.provider import load
16+
17+
connection_string = os.environ["APPCONFIGURATION_CONNECTION_STRING"]
18+
1319
# Connecting to Azure App Configuration using connection string
1420
config = load(connection_string=connection_string, **kwargs)
21+
# [END create_provider_connection_string]
1522

1623
print(config["message"])
1724
print(config["my_json"]["key"])
1825

26+
# [START trim_prefixes_connection_string]
27+
from azure.appconfiguration.provider import load
28+
1929
# Connecting to Azure App Configuration using connection string and trimmed key prefixes
2030
trimmed = ["test."]
2131
config = load(connection_string=connection_string, trim_prefixes=trimmed, **kwargs)
32+
# [END trim_prefixes_connection_string]
2233

2334
print(config["message"])
2435

36+
# [START setting_selector_connection_string]
37+
from azure.appconfiguration.provider import load, SettingSelector
38+
2539
# Connection to Azure App Configuration using SettingSelector
2640
selects = [SettingSelector(key_filter="message*")]
2741
config = load(connection_string=connection_string, selects=selects, **kwargs)
42+
# [END setting_selector_connection_string]
2843

2944
print("message found: " + str("message" in config))
3045
print("test.message found: " + str("test.message" in config))

0 commit comments

Comments
 (0)