Microsoft Azure App Configuration Management Client Library for Python
npx @tessl/cli install tessl/pypi-azure-mgmt-appconfiguration@5.0.00
# Azure App Configuration Management Client Library for Python
1
2
The `azure-mgmt-appconfiguration` package provides a comprehensive client library for managing Azure App Configuration resources through the Azure Resource Manager (ARM) APIs. This library enables you to programmatically create, configure, and manage Azure App Configuration stores, their key-value pairs, replicas, snapshots, and networking configurations.
3
4
## Package Information
5
6
- **Package**: `azure-mgmt-appconfiguration`
7
- **Version**: `5.0.0`
8
- **API Version**: `2024-06-01`
9
- **Repository**: [Azure SDK for Python](https://github.com/Azure/azure-sdk-for-python)
10
11
## Core Imports
12
13
### Synchronous Client
14
15
```python { .api }
16
from azure.mgmt.appconfiguration import AppConfigurationManagementClient
17
from azure.identity import DefaultAzureCredential
18
19
# Initialize client
20
credential = DefaultAzureCredential()
21
client = AppConfigurationManagementClient(
22
credential=credential,
23
subscription_id="your-subscription-id"
24
)
25
```
26
27
### Asynchronous Client
28
29
```python { .api }
30
from azure.mgmt.appconfiguration.aio import AppConfigurationManagementClient
31
from azure.identity.aio import DefaultAzureCredential
32
33
# Initialize async client
34
credential = DefaultAzureCredential()
35
async_client = AppConfigurationManagementClient(
36
credential=credential,
37
subscription_id="your-subscription-id"
38
)
39
```
40
41
## Basic Usage Example
42
43
```python { .api }
44
from azure.mgmt.appconfiguration import AppConfigurationManagementClient
45
from azure.mgmt.appconfiguration.models import ConfigurationStore, Sku
46
from azure.identity import DefaultAzureCredential
47
48
# Authenticate and create client
49
credential = DefaultAzureCredential()
50
client = AppConfigurationManagementClient(credential, "your-subscription-id")
51
52
# Create a new App Configuration store
53
store_params = ConfigurationStore(
54
location="East US",
55
sku=Sku(name="Free"),
56
tags={"Environment": "Development"}
57
)
58
59
# Start the create operation (Long Running Operation)
60
create_poller = client.configuration_stores.begin_create(
61
resource_group_name="my-resource-group",
62
config_store_name="my-config-store",
63
config_store_creation_parameters=store_params
64
)
65
66
# Wait for completion and get result
67
config_store = create_poller.result()
68
print(f"Created store: {config_store.name} at {config_store.endpoint}")
69
70
# List all stores in subscription
71
stores = client.configuration_stores.list()
72
for store in stores:
73
print(f"Store: {store.name} in {store.location}")
74
```
75
76
## Client Architecture
77
78
The `AppConfigurationManagementClient` provides access to seven primary operations groups, each handling specific aspects of Azure App Configuration management:
79
80
### AppConfigurationManagementClient
81
82
```python { .api }
83
class AppConfigurationManagementClient:
84
def __init__(
85
self,
86
credential: TokenCredential,
87
subscription_id: str,
88
base_url: Optional[str] = None,
89
**kwargs: Any
90
) -> None:
91
"""
92
Initialize the App Configuration Management Client.
93
94
Args:
95
credential: Azure credential for authentication
96
subscription_id: Azure subscription ID
97
base_url: Service URL (defaults to Azure Resource Manager endpoint)
98
**kwargs: Additional keyword arguments for client configuration
99
"""
100
```
101
102
### Operations Groups
103
104
The client exposes the following operations groups as properties:
105
106
- **`configuration_stores`**: [Store management operations](configuration-stores.md) - Create, update, delete, and list App Configuration stores
107
- **`key_values`**: [Key-value operations](key-values.md) - Manage configuration key-value pairs
108
- **`operations`**: [General operations](operations.md) - List available API operations and check name availability
109
- **`private_endpoint_connections`**: [Private networking](private-networking.md) - Manage private endpoint connections
110
- **`private_link_resources`**: [Private networking](private-networking.md) - Manage private link resources
111
- **`replicas`**: [Replica management](replicas.md) - Create and manage store replicas across regions
112
- **`snapshots`**: [Snapshot operations](snapshots.md) - Create and manage configuration snapshots
113
114
## Core Capabilities
115
116
### Configuration Store Management
117
118
Comprehensive lifecycle management of Azure App Configuration stores:
119
120
```python { .api }
121
# List stores across subscription
122
stores = client.configuration_stores.list()
123
124
# Get specific store details
125
store = client.configuration_stores.get("resource-group", "store-name")
126
127
# Update store configuration
128
from azure.mgmt.appconfiguration.models import ConfigurationStoreUpdateParameters
129
update_params = ConfigurationStoreUpdateParameters(
130
tags={"Environment": "Production", "Team": "DevOps"}
131
)
132
update_poller = client.configuration_stores.begin_update(
133
"resource-group", "store-name", update_params
134
)
135
updated_store = update_poller.result()
136
```
137
138
**[→ See complete Configuration Store Operations](configuration-stores.md)**
139
140
### Key-Value Management
141
142
Direct management of configuration key-value pairs through the ARM API:
143
144
```python { .api }
145
from azure.mgmt.appconfiguration.models import KeyValue
146
147
# Create or update a key-value pair
148
key_value = KeyValue(value="production-value", content_type="text/plain")
149
result = client.key_values.create_or_update(
150
resource_group_name="resource-group",
151
config_store_name="store-name",
152
key_value_name="MyApp:Settings:DatabaseUrl",
153
key_value_parameters=key_value
154
)
155
156
# Retrieve a key-value
157
kv = client.key_values.get("resource-group", "store-name", "MyApp:Settings:DatabaseUrl")
158
print(f"Value: {kv.value}, Content-Type: {kv.content_type}")
159
```
160
161
**[→ See complete Key-Value Operations](key-values.md)**
162
163
### Private Networking
164
165
Secure your App Configuration stores with private endpoints and private link resources:
166
167
```python { .api }
168
# List private endpoint connections
169
connections = client.private_endpoint_connections.list_by_configuration_store(
170
"resource-group", "store-name"
171
)
172
173
# List available private link resources
174
link_resources = client.private_link_resources.list_by_configuration_store(
175
"resource-group", "store-name"
176
)
177
178
for resource in link_resources:
179
print(f"Group: {resource.group_id}, Required members: {resource.required_members}")
180
```
181
182
**[→ See complete Private Networking Operations](private-networking.md)**
183
184
### Replica Management
185
186
Scale your configuration across regions with replicas:
187
188
```python { .api }
189
from azure.mgmt.appconfiguration.models import Replica
190
191
# Create a replica in another region
192
replica_params = Replica(location="West US")
193
create_replica_poller = client.replicas.begin_create(
194
resource_group_name="resource-group",
195
config_store_name="store-name",
196
replica_name="west-us-replica",
197
replica_creation_parameters=replica_params
198
)
199
replica = create_replica_poller.result()
200
201
# List all replicas for a store
202
replicas = client.replicas.list_by_configuration_store("resource-group", "store-name")
203
for replica in replicas:
204
print(f"Replica: {replica.name} in {replica.location}")
205
```
206
207
**[→ See complete Replica Management](replicas.md)**
208
209
### Snapshot Management
210
211
Create point-in-time snapshots of your configuration:
212
213
```python { .api }
214
from azure.mgmt.appconfiguration.models import Snapshot, KeyValueFilter, CompositionType
215
216
# Create a snapshot with specific filters
217
filters = [KeyValueFilter(key="MyApp:*")]
218
snapshot_params = Snapshot(
219
filters=filters,
220
composition_type=CompositionType.KEY,
221
retention_period=7776000 # 90 days in seconds
222
)
223
224
create_snapshot_poller = client.snapshots.begin_create(
225
resource_group_name="resource-group",
226
config_store_name="store-name",
227
snapshot_name="prod-config-snapshot",
228
snapshot_creation_parameters=snapshot_params
229
)
230
snapshot = create_snapshot_poller.result()
231
```
232
233
**[→ See complete Snapshot Operations](snapshots.md)**
234
235
## Authentication and Credentials
236
237
The library supports all Azure Identity credential types:
238
239
```python { .api }
240
from azure.identity import (
241
DefaultAzureCredential,
242
ClientSecretCredential,
243
ManagedIdentityCredential,
244
AzureCliCredential
245
)
246
247
# Default credential (recommended for most scenarios)
248
credential = DefaultAzureCredential()
249
250
# Service principal with client secret
251
credential = ClientSecretCredential(
252
tenant_id="tenant-id",
253
client_id="client-id",
254
client_secret="client-secret"
255
)
256
257
# Managed Identity (for Azure services)
258
credential = ManagedIdentityCredential()
259
260
# Azure CLI credential
261
credential = AzureCliCredential()
262
```
263
264
## Error Handling
265
266
The library provides comprehensive error models for handling API errors:
267
268
```python { .api }
269
from azure.core.exceptions import HttpResponseError
270
from azure.mgmt.appconfiguration.models import ErrorResponse
271
272
try:
273
store = client.configuration_stores.get("resource-group", "non-existent-store")
274
except HttpResponseError as e:
275
print(f"HTTP {e.status_code}: {e.reason}")
276
if hasattr(e, 'error') and e.error:
277
print(f"Error code: {e.error.code}")
278
print(f"Error message: {e.error.message}")
279
```
280
281
## Long Running Operations
282
283
Many operations are asynchronous and return `LROPoller` objects:
284
285
```python { .api }
286
from azure.core.polling import LROPoller
287
288
# Start a long-running operation
289
poller = client.configuration_stores.begin_create(resource_group, store_name, params)
290
291
# Check if operation is complete
292
if not poller.done():
293
print("Operation is still in progress...")
294
295
# Wait for completion with custom polling interval
296
result = poller.result(timeout=300) # Wait up to 5 minutes
297
298
# Or poll manually
299
while not poller.done():
300
time.sleep(30) # Wait 30 seconds between checks
301
print("Still waiting...")
302
```
303
304
## Paged Results
305
306
List operations return `ItemPaged` objects for efficient handling of large result sets:
307
308
```python { .api }
309
from azure.core.paging import ItemPaged
310
311
# Get paged results
312
paged_stores = client.configuration_stores.list()
313
314
# Iterate through all pages automatically
315
for store in paged_stores:
316
print(store.name)
317
318
# Manual page iteration
319
for page in paged_stores.by_page():
320
for store in page:
321
print(f"Store: {store.name} in {store.location}")
322
```
323
324
## Additional Resources
325
326
- **[Configuration Store Operations](configuration-stores.md)** - Complete store lifecycle management
327
- **[Key-Value Operations](key-values.md)** - Configuration data management
328
- **[General Operations](operations.md)** - Name availability and operation discovery
329
- **[Private Networking](private-networking.md)** - Private endpoints and link resources
330
- **[Replica Management](replicas.md)** - Multi-region replication
331
- **[Snapshot Operations](snapshots.md)** - Point-in-time configuration snapshots
332
- **[Models and Types](models-and-types.md)** - Complete API model reference
333
334
## Context Manager Support
335
336
Both synchronous and asynchronous clients support context managers:
337
338
```python { .api }
339
# Synchronous context manager
340
with AppConfigurationManagementClient(credential, subscription_id) as client:
341
stores = client.configuration_stores.list()
342
for store in stores:
343
print(store.name)
344
# Client automatically closed
345
346
# Asynchronous context manager
347
async with AppConfigurationManagementClient(credential, subscription_id) as client:
348
stores = client.configuration_stores.list()
349
async for store in stores:
350
print(store.name)
351
# Client automatically closed
352
```