Share via


AzureAppConfigurationClient Class

Represents a client that calls restful API of Azure App Configuration service.

param str base_url: Base url of the service.

param credential: An object which can provide secrets for the app configuration service

type credential: ~azure.core.credentials_async.AsyncTokenCredential

keyword api_version: Api Version. Default value is "2023-11-01". Note that overriding this default value may result in unsupported behavior.

paramtype api_version: str

This is the async version of AzureAppConfigurationClient

Constructor

AzureAppConfigurationClient(base_url: str, credential: AsyncTokenCredential, **kwargs: Any)

Parameters

Name Description
base_url
Required
credential
Required

Methods

add_configuration_setting

Add a ConfigurationSetting instance into the Azure App Configuration service.

Example


   # in async function
   config_setting = ConfigurationSetting(
       key="MyKey",
       label="MyLabel",
       value="my value",
       content_type="my content type",
       tags={"my tag": "my tag value"}
   )
   added_config_setting = await async_client.add_configuration_setting(config_setting)
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


   # in async function
   deleted_config_setting = await async_client.delete_configuration_setting(
       key="MyKey", label="MyLabel"
   )
from_connection_string

Create AzureAppConfigurationClient from a Connection String. This is the async version of AzureAppConfigurationClient

Example


   from azure.appconfiguration.aio import AzureAppConfigurationClient
   connection_str = "<my connection string>"
   async_client = AzureAppConfigurationClient.from_connection_string(connection_str)
get_configuration_setting

Get the matched ConfigurationSetting from Azure App Configuration service

Example


   # in async function
   fetched_config_setting = await async_client.get_configuration_setting(
       key="MyKey", label="MyLabel"
   )
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://learn.microsoft.com/azure/azure-app-configuration/rest-api-revisions?pivots=v23-11#supported-filters.

Example


   # in async function
   from datetime import datetime, timedelta

   accept_datetime = datetime.utcnow() + timedelta(days=-1)

   all_revisions = async_client.list_revisions()
   async for item in all_revisions:
       pass  # do something

   filtered_revisions = async_client.list_revisions(
       label_filter="Labe*", key_filter="Ke*", accept_datetime=str(accept_datetime)
   )
   async for item in filtered_revisions:
       pass  # do something
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


   # in async function
   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 = await async_client.set_configuration_setting(config_setting)
set_read_only

Set a configuration setting read only

Example


   config_setting = await async_client.get_configuration_setting(
       key="MyKey", label="MyLabel"
   )

   read_only_config_setting = await async_client.set_read_only(config_setting)
   read_only_config_setting = await client.set_read_only(config_setting, read_only=False)
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


   # in async function
   config_setting = ConfigurationSetting(
       key="MyKey",
       label="MyLabel",
       value="my value",
       content_type="my content type",
       tags={"my tag": "my tag value"}
   )
   added_config_setting = await async_client.add_configuration_setting(config_setting)
async 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.

async archive_snapshot(name: str, *, match_condition: MatchConditions = MatchConditions.Unconditionally, etag: str | None = None, **kwargs) -> ConfigurationSnapshot

Parameters

Name Description
name
Required
str

The name of the configuration setting snapshot to archive.

Keyword-Only Parameters

Name Description
match_condition

The match condition to use upon the etag.

Default value: MatchConditions.Unconditionally
etag
str or None

Check if the ConfigurationSnapshot is changed. Set None to skip checking etag.

Default value: None

Returns

Type Description

The ConfigurationSnapshot returned from the service.

Exceptions

Type Description

begin_create_snapshot

Create a snapshot of the configuration settings.

async 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) -> AsyncLROPoller[ConfigurationSnapshot]

Parameters

Name Description
name
Required
str

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.

Default value: None
retention_period
int or None

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).

Default value: None
tags
dict[str, str] or None

The tags of the configuration snapshot.

Default value: None

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

async close() -> None

delete_configuration_setting

Delete a ConfigurationSetting if it exists

Example


   # in async function
   deleted_config_setting = await async_client.delete_configuration_setting(
       key="MyKey", label="MyLabel"
   )
async 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
str

Key used to identify the ConfigurationSetting

label
str

Label used to identify the ConfigurationSetting. Default is None.

Default value: None

Keyword-Only Parameters

Name Description
etag
str or None

Check if the ConfigurationSetting is changed. Set None to skip checking etag

Default value: None
match_condition

The match condition to use upon the etag

Default value: MatchConditions.Unconditionally

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. This is the async version of AzureAppConfigurationClient

Example


   from azure.appconfiguration.aio import AzureAppConfigurationClient
   connection_str = "<my connection string>"
   async_client = AzureAppConfigurationClient.from_connection_string(connection_str)
from_connection_string(connection_string: str, **kwargs: Any) -> AzureAppConfigurationClient

Parameters

Name Description
connection_string
Required
str

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

get_configuration_setting

Get the matched ConfigurationSetting from Azure App Configuration service

Example


   # in async function
   fetched_config_setting = await async_client.get_configuration_setting(
       key="MyKey", label="MyLabel"
   )
async 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
str

Key of the ConfigurationSetting

label
str or None

Label used to identify the ConfigurationSetting. Default is None.

Default value: None
etag
str or None

Check if the ConfigurationSetting is changed. Set None to skip checking etag

Default value: *
match_condition

The match condition to use upon the etag

Default value: MatchConditions.Unconditionally

Keyword-Only Parameters

Name Description
accept_datetime
datetime or str or None

Retrieve ConfigurationSetting that existed at this datetime

Default value: None

Returns

Type Description

The matched ConfigurationSetting object

Exceptions

Type Description

get_snapshot

Get a configuration setting snapshot.

async get_snapshot(name: str, *, fields: List[str | SnapshotFields] | None = None, **kwargs) -> ConfigurationSnapshot

Parameters

Name Description
name
Required
str

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.

Default value: None

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) -> AsyncItemPaged[ConfigurationSetting]

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) -> AsyncItemPaged[ConfigurationSettingLabel]

Keyword-Only Parameters

Name Description
name
str or None

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://learn.microsoft.com/azure/azure-app-configuration/rest-api-labels?pivots=v23-11#supported-filters.

Default value: None
after
str or None

Instructs the server to return elements that appear after the element referred to by the specified token.

Default value: None
accept_datetime
datetime or str or None

Requests the server to respond with the state of the resource at the specified time.

Default value: None
fields

Specify which fields to include in the results. If not specified, will include all fields. Available fields see LabelFields.

Default value: None

Returns

Type Description
<xref:azure.core.paging.AsyncItemPaged>[ConfigurationSettingLabel]

An async 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://learn.microsoft.com/azure/azure-app-configuration/rest-api-revisions?pivots=v23-11#supported-filters.

Example


   # in async function
   from datetime import datetime, timedelta

   accept_datetime = datetime.utcnow() + timedelta(days=-1)

   all_revisions = async_client.list_revisions()
   async for item in all_revisions:
       pass  # do something

   filtered_revisions = async_client.list_revisions(
       label_filter="Labe*", key_filter="Ke*", accept_datetime=str(accept_datetime)
   )
   async 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) -> AsyncItemPaged[ConfigurationSetting]

Parameters

Name Description
key_filter
str or None

Filter results based on their keys. '*' can be used as wildcard in the beginning or end of the filter.

Default value: None
label_filter
str or None

Filter results based on their label. '*' can be used as wildcard in the beginning or end of the filter.

Default value: None

Keyword-Only Parameters

Name Description
tags_filter
list[str] or None

Filter results based on their tags.

Default value: None
accept_datetime
datetime or str or None

Retrieve ConfigurationSetting that existed at this datetime

Default value: None
fields

Specify which fields to include in the results. If not specified, will include all fields. Available fields see ConfigurationSettingFields.

Default value: None

Returns

Type Description

An async 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) -> AsyncItemPaged[ConfigurationSnapshot]

Keyword-Only Parameters

Name Description
name
str or None

Filter results based on snapshot name.

Default value: None
fields

Specify which fields to include in the results. If not specified, will include all fields. Available fields see SnapshotFields.

Default value: None
status

Filter results based on snapshot keys. Available status see SnapshotStatus.

Default value: None

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".

async recover_snapshot(name: str, *, match_condition: MatchConditions = MatchConditions.Unconditionally, etag: str | None = None, **kwargs) -> ConfigurationSnapshot

Parameters

Name Description
name
Required
str

The name of the configuration setting snapshot to recover.

Keyword-Only Parameters

Name Description
match_condition

The match condition to use upon the etag.

Default value: MatchConditions.Unconditionally
etag
str or None

Check if the ConfigurationSnapshot is changed. Set None to skip checking etag.

Default value: None

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.

async send_request(request: HttpRequest, *, stream: bool = False, **kwargs) -> AsyncHttpResponse

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.

Default value: False

Returns

Type Description

The response of your network call. Does not do error handling on your response.

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


   # in async function
   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 = await async_client.set_configuration_setting(config_setting)
async 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

The match condition to use upon the etag

Default value: MatchConditions.Unconditionally

Keyword-Only Parameters

Name Description
etag
str or None

Check if the ConfigurationSetting is changed. Will use the value from param configuration_setting if not set.

Default value: None

Returns

Type Description

The ConfigurationSetting returned from the service

Exceptions

Type Description

set_read_only

Set a configuration setting read only

Example


   config_setting = await async_client.get_configuration_setting(
       key="MyKey", label="MyLabel"
   )

   read_only_config_setting = await async_client.set_read_only(config_setting)
   read_only_config_setting = await client.set_read_only(config_setting, read_only=False)
async 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

Set the read only setting if true, else clear the read only setting

Default value: True

Keyword-Only Parameters

Name Description
match_condition

The match condition to use upon the etag

Default value: MatchConditions.Unconditionally

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.

async update_sync_token(token: str) -> None

Parameters

Name Description
token
Required
str

The sync token to be added to the internal list of tokens