AzureAppConfigurationClient Class
Represents a client that calls restful API of Azure App Configuration service.
- Inheritance
-
builtins.objectAzureAppConfigurationClient
Constructor
AzureAppConfigurationClient(base_url: str, credential: TokenCredential, **kwargs: Any)
Parameters
Name | Description |
---|---|
base_url
Required
|
Base url of the service. |
credential
Required
|
An object which can provide secrets for the app configuration service |
Keyword-Only Parameters
Name | Description |
---|---|
api_version
|
Api Version. Default value is "2023-11-01". Note that overriding this default value may result in unsupported behavior. |
Methods
add_configuration_setting |
Add a ConfigurationSetting instance into the Azure App Configuration service. Example
|
archive_snapshot |
Archive a configuration setting snapshot. It will update the status of a snapshot from "ready" to "archived". The retention period will start to count, the snapshot will expire when the entire retention period elapses. |
begin_create_snapshot |
Create a snapshot of the configuration settings. |
close |
Close all connections made by the client |
delete_configuration_setting |
Delete a ConfigurationSetting if it exists Example
|
from_connection_string |
Create AzureAppConfigurationClient from a Connection String. Example
|
get_configuration_setting |
Get the matched ConfigurationSetting from Azure App Configuration service Example
|
get_snapshot |
Get a configuration setting snapshot. |
list_configuration_settings | |
list_labels |
Gets a list of labels. |
list_revisions |
Find the ConfigurationSetting revision history, optionally filtered by key, label, tags and accept_datetime. For more information about supported filters, see https://video2.skills-academy.com/azure/azure-app-configuration/rest-api-revisions?pivots=v23-11#supported-filters. Example
|
list_snapshots |
List the configuration setting snapshots stored in the configuration service, optionally filtered by snapshot name, snapshot status and fields to present in return. |
recover_snapshot |
Recover a configuration setting snapshot. It will update the status of a snapshot from "archived" to "ready". |
send_request |
Runs a network request using the client's existing pipeline. The request URL can be relative to the vault URL. The service API version used for the request is the same as the client's unless otherwise specified. This method does not raise if the response is an error; to raise an exception, call raise_for_status() on the returned response object. For more information about how to send custom requests with this method, see https://aka.ms/azsdk/dpcodegen/python/send_request. |
set_configuration_setting |
Add or update a ConfigurationSetting. If the configuration setting identified by key and label does not exist, this is a create. Otherwise this is an update. Example
|
set_read_only |
Set a configuration setting read only Example
|
update_sync_token |
Add a sync token to the internal list of tokens. |
add_configuration_setting
Add a ConfigurationSetting instance into the Azure App Configuration service.
Example
config_setting = ConfigurationSetting(
key="MyKey",
label="MyLabel",
value="my value",
content_type="my content type",
tags={"my tag": "my tag value"}
)
added_config_setting = client.add_configuration_setting(config_setting)
add_configuration_setting(configuration_setting: ConfigurationSetting, **kwargs) -> ConfigurationSetting
Parameters
Name | Description |
---|---|
configuration_setting
Required
|
The ConfigurationSetting object to be added |
Returns
Type | Description |
---|---|
The ConfigurationSetting object returned from the App Configuration service |
Exceptions
Type | Description |
---|---|
archive_snapshot
Archive a configuration setting snapshot. It will update the status of a snapshot from "ready" to "archived". The retention period will start to count, the snapshot will expire when the entire retention period elapses.
archive_snapshot(name: str, *, match_condition: MatchConditions = MatchConditions.Unconditionally, etag: str | None = None, **kwargs) -> ConfigurationSnapshot
Parameters
Name | Description |
---|---|
name
Required
|
The name of the configuration setting snapshot to archive. |
Keyword-Only Parameters
Name | Description |
---|---|
match_condition
|
The match condition to use upon the etag. |
etag
|
Check if the ConfigurationSnapshot is changed. Set None to skip checking etag. |
Returns
Type | Description |
---|---|
The ConfigurationSnapshot returned from the service. |
Exceptions
Type | Description |
---|---|
begin_create_snapshot
Create a snapshot of the configuration settings.
begin_create_snapshot(name: str, filters: List[ConfigurationSettingsFilter], *, composition_type: str | SnapshotComposition | None = None, retention_period: int | None = None, tags: Dict[str, str] | None = None, **kwargs) -> LROPoller[ConfigurationSnapshot]
Parameters
Name | Description |
---|---|
name
Required
|
The name of the configuration snapshot to create. |
filters
Required
|
A list of filters used to filter the configuration settings by key field and label field included in the configuration snapshot. |
Keyword-Only Parameters
Name | Description |
---|---|
composition_type
|
The composition type describes how the key-values within the configuration snapshot are composed. Known values are: "key" and "key_label". The "key" composition type ensures there are no two key-values containing the same key. The 'key_label' composition type ensures there are no two key-values containing the same key and label. |
retention_period
|
The amount of time, in seconds, that a configuration snapshot will remain in the archived state before expiring. This property is only writable during the creation of a configuration snapshot. If not specified, will set to 2592000(30 days). If specified, should be in range 3600(1 hour) to 7776000(90 days). |
tags
|
The tags of the configuration snapshot. |
Returns
Type | Description |
---|---|
A poller for create configuration snapshot operation. Call result() on this object to wait for the operation to complete and get the created snapshot. |
Exceptions
Type | Description |
---|---|
close
Close all connections made by the client
close() -> None
Exceptions
Type | Description |
---|---|
delete_configuration_setting
Delete a ConfigurationSetting if it exists
Example
deleted_config_setting = client.delete_configuration_setting(
key="MyKey", label="MyLabel"
)
delete_configuration_setting(key: str, label: str | None = None, *, etag: str | None = None, match_condition: MatchConditions = MatchConditions.Unconditionally, **kwargs) -> None | ConfigurationSetting
Parameters
Name | Description |
---|---|
key
Required
|
Key used to identify the ConfigurationSetting |
label
Required
|
Label used to identify the ConfigurationSetting. Default is None. |
Keyword-Only Parameters
Name | Description |
---|---|
etag
|
Check if the ConfigurationSetting is changed. Set None to skip checking etag |
match_condition
|
The match condition to use upon the etag |
Returns
Type | Description |
---|---|
The deleted ConfigurationSetting returned from the service, or None if it doesn't exist. |
Exceptions
Type | Description |
---|---|
from_connection_string
Create AzureAppConfigurationClient from a Connection String.
Example
from azure.appconfiguration import AzureAppConfigurationClient
connection_str = "<my connection string>"
client = AzureAppConfigurationClient.from_connection_string(connection_str)
from_connection_string(connection_string: str, **kwargs: Any) -> AzureAppConfigurationClient
Parameters
Name | Description |
---|---|
connection_string
Required
|
Connection String (one of the access keys of the Azure App Configuration resource) used to access the Azure App Configuration. |
Returns
Type | Description |
---|---|
An AzureAppConfigurationClient authenticated with the connection string |
Exceptions
Type | Description |
---|---|
get_configuration_setting
Get the matched ConfigurationSetting from Azure App Configuration service
Example
fetched_config_setting = client.get_configuration_setting(
key="MyKey", label="MyLabel"
)
get_configuration_setting(key: str, label: str | None = None, etag: str | None = '*', match_condition: MatchConditions = MatchConditions.Unconditionally, *, accept_datetime: datetime | str | None = None, **kwargs) -> None | ConfigurationSetting
Parameters
Name | Description |
---|---|
key
Required
|
Key of the ConfigurationSetting |
label
Required
|
Label used to identify the ConfigurationSetting. Default is None. |
etag
Required
|
Check if the ConfigurationSetting is changed. Set None to skip checking etag |
match_condition
Required
|
The match condition to use upon the etag |
Keyword-Only Parameters
Name | Description |
---|---|
accept_datetime
|
Retrieve ConfigurationSetting that existed at this datetime |
Returns
Type | Description |
---|---|
The matched ConfigurationSetting object |
Exceptions
Type | Description |
---|---|
get_snapshot
Get a configuration setting snapshot.
get_snapshot(name: str, *, fields: List[str | SnapshotFields] | None = None, **kwargs) -> ConfigurationSnapshot
Parameters
Name | Description |
---|---|
name
Required
|
The name of the configuration setting snapshot to retrieve. |
Keyword-Only Parameters
Name | Description |
---|---|
fields
|
Specify which fields to include in the results. If not specified, will include all fields. Available fields see SnapshotFields. |
Returns
Type | Description |
---|---|
The ConfigurationSnapshot returned from the service. |
Exceptions
Type | Description |
---|---|
list_configuration_settings
list_configuration_settings(*, key_filter: str | None = None, label_filter: str | None = None, tags_filter: List[str] | None = None, accept_datetime: datetime | str | None = None, fields: List[str | ConfigurationSettingFields] | None = None, **kwargs: Any) -> ItemPaged[ConfigurationSetting]
Exceptions
Type | Description |
---|---|
list_labels
Gets a list of labels.
list_labels(*, name: str | None = None, after: str | None = None, accept_datetime: datetime | str | None = None, fields: List[str | LabelFields] | None = None, **kwargs) -> ItemPaged[ConfigurationSettingLabel]
Keyword-Only Parameters
Name | Description |
---|---|
name
|
A filter for the name of the returned labels. '*' can be used as wildcard in the beginning or end of the filter. For more information about supported filters, see https://video2.skills-academy.com/azure/azure-app-configuration/rest-api-labels?pivots=v23-11#supported-filters. |
after
|
Instructs the server to return elements that appear after the element referred to by the specified token. |
accept_datetime
|
Requests the server to respond with the state of the resource at the specified time. |
fields
|
Specify which fields to include in the results. If not specified, will include all fields. Available fields see LabelFields. |
Returns
Type | Description |
---|---|
An iterator of labels. |
Exceptions
Type | Description |
---|---|
list_revisions
Find the ConfigurationSetting revision history, optionally filtered by key, label, tags and accept_datetime. For more information about supported filters, see https://video2.skills-academy.com/azure/azure-app-configuration/rest-api-revisions?pivots=v23-11#supported-filters.
Example
from datetime import datetime, timedelta
accept_datetime = datetime.utcnow() + timedelta(days=-1)
all_revisions = client.list_revisions()
for item in all_revisions:
pass # do something
filtered_revisions = client.list_revisions(
label_filter="Labe*", key_filter="Ke*", accept_datetime=str(accept_datetime)
)
for item in filtered_revisions:
pass # do something
list_revisions(key_filter: str | None = None, label_filter: str | None = None, *, tags_filter: List[str] | None = None, accept_datetime: datetime | str | None = None, fields: List[str | ConfigurationSettingFields] | None = None, **kwargs) -> ItemPaged[ConfigurationSetting]
Parameters
Name | Description |
---|---|
key_filter
Required
|
Filter results based on their keys. '*' can be used as wildcard in the beginning or end of the filter. |
label_filter
Required
|
Filter results based on their label. '*' can be used as wildcard in the beginning or end of the filter. |
Keyword-Only Parameters
Name | Description |
---|---|
tags_filter
|
Filter results based on their tags. |
accept_datetime
|
Retrieve ConfigurationSetting that existed at this datetime |
fields
|
Specify which fields to include in the results. If not specified, will include all fields. Available fields see ConfigurationSettingFields. |
Returns
Type | Description |
---|---|
An iterator of ConfigurationSetting |
Exceptions
Type | Description |
---|---|
list_snapshots
List the configuration setting snapshots stored in the configuration service, optionally filtered by snapshot name, snapshot status and fields to present in return.
list_snapshots(*, name: str | None = None, fields: List[str | SnapshotFields] | None = None, status: List[str | SnapshotStatus] | None = None, **kwargs) -> ItemPaged[ConfigurationSnapshot]
Keyword-Only Parameters
Name | Description |
---|---|
name
|
Filter results based on snapshot name. |
fields
|
Specify which fields to include in the results. If not specified, will include all fields. Available fields see SnapshotFields. |
status
|
Filter results based on snapshot keys. Available status see SnapshotStatus. |
Returns
Type | Description |
---|---|
An iterator of ConfigurationSnapshot |
Exceptions
Type | Description |
---|---|
recover_snapshot
Recover a configuration setting snapshot. It will update the status of a snapshot from "archived" to "ready".
recover_snapshot(name: str, *, match_condition: MatchConditions = MatchConditions.Unconditionally, etag: str | None = None, **kwargs) -> ConfigurationSnapshot
Parameters
Name | Description |
---|---|
name
Required
|
The name of the configuration setting snapshot to recover. |
Keyword-Only Parameters
Name | Description |
---|---|
match_condition
|
The match condition to use upon the etag. |
etag
|
Check if the ConfigurationSnapshot is changed. Set None to skip checking etag. |
Returns
Type | Description |
---|---|
The ConfigurationSnapshot returned from the service. |
Exceptions
Type | Description |
---|---|
send_request
Runs a network request using the client's existing pipeline.
The request URL can be relative to the vault URL. The service API version used for the request is the same as the client's unless otherwise specified. This method does not raise if the response is an error; to raise an exception, call raise_for_status() on the returned response object. For more information about how to send custom requests with this method, see https://aka.ms/azsdk/dpcodegen/python/send_request.
send_request(request: HttpRequest, *, stream: bool = False, **kwargs) -> HttpResponse
Parameters
Name | Description |
---|---|
request
Required
|
The network request you want to make. |
Keyword-Only Parameters
Name | Description |
---|---|
stream
|
Whether the response payload will be streamed. Defaults to False. |
Returns
Type | Description |
---|---|
The response of your network call. Does not do error handling on your response. |
Exceptions
Type | Description |
---|---|
set_configuration_setting
Add or update a ConfigurationSetting. If the configuration setting identified by key and label does not exist, this is a create. Otherwise this is an update.
Example
config_setting = ConfigurationSetting(
key="MyKey",
label="MyLabel",
value="my set value",
content_type="my set content type",
tags={"my set tag": "my set tag value"}
)
returned_config_setting = client.set_configuration_setting(config_setting)
set_configuration_setting(configuration_setting: ConfigurationSetting, match_condition: MatchConditions = MatchConditions.Unconditionally, *, etag: str | None = None, **kwargs) -> ConfigurationSetting
Parameters
Name | Description |
---|---|
configuration_setting
Required
|
The ConfigurationSetting to be added (if not exists) or updated (if exists) to the service |
match_condition
Required
|
The match condition to use upon the etag |
Keyword-Only Parameters
Name | Description |
---|---|
etag
|
Check if the ConfigurationSetting is changed. Will use the value from param configuration_setting if not set. |
Returns
Type | Description |
---|---|
The ConfigurationSetting returned from the service |
Exceptions
Type | Description |
---|---|
set_read_only
Set a configuration setting read only
Example
config_setting = client.get_configuration_setting(
key="MyKey", label="MyLabel"
)
read_only_config_setting = client.set_read_only(config_setting)
read_only_config_setting = client.set_read_only(config_setting, read_only=False)
set_read_only(configuration_setting: ConfigurationSetting, read_only: bool = True, *, match_condition: MatchConditions = MatchConditions.Unconditionally, **kwargs) -> ConfigurationSetting
Parameters
Name | Description |
---|---|
configuration_setting
Required
|
The ConfigurationSetting to be set read only |
read_only
Required
|
Set the read only setting if true, else clear the read only setting |
Keyword-Only Parameters
Name | Description |
---|---|
match_condition
|
The match condition to use upon the etag |
Returns
Type | Description |
---|---|
The ConfigurationSetting returned from the service |
Exceptions
Type | Description |
---|---|
update_sync_token
Add a sync token to the internal list of tokens.
update_sync_token(token: str) -> None
Parameters
Name | Description |
---|---|
token
Required
|
The sync token to be added to the internal list of tokens |
Exceptions
Type | Description |
---|---|
Azure SDK for Python