azure.appconfiguration.aio package

Module contents

class azure.appconfiguration.aio.AzureAppConfigurationClient(base_url, credential, **kwargs)[source]

Represents an 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.AppConfigConnectionStringCredential

keyword Pipeline pipeline

If omitted, the standard pipeline is used.

keyword HttpTransport transport

If omitted, the standard pipeline is used.

keyword list[HTTPPolicy] policies

If omitted, the standard pipeline is used.

This is the async version of azure.appconfiguration.AzureAppConfigurationClient

async add_configuration_setting(configuration_setting, **kwargs)[source]

Add a ConfigurationSetting into the Azure App Configuration service.

Parameters

configuration_setting (ConfigurationSetting) – the ConfigurationSetting object to be added

Keyword Arguments

headers (dict) – if “headers” exists, its value (a dict) will be added to the http request header

Returns

The ConfigurationSetting object returned from the App Configuration service

Return type

ConfigurationSetting

Raises

HttpResponseError, ClientAuthenticationError, ResourceExistsError

Example

# in async fuction
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)
clear_read_only(configuration_setting, **kwargs)[source]

Clear read only flag for a configuration setting

Parameters

configuration_setting (ConfigurationSetting) – the ConfigurationSetting to be read only clear

Keyword Arguments

headers (dict) – if “headers” exists, its value (a dict) will be added to the http request header

Returns

The ConfigurationSetting returned from the service

Return type

ConfigurationSetting

Raises

HttpResponseError, ClientAuthenticationError, ResourceNotFoundError

Example

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

read_only_config_setting = await async_client.clear_read_only(config_setting)
async delete_configuration_setting(key, label=None, **kwargs)[source]

Delete a ConfigurationSetting if it exists

Parameters
  • key (str) – key used to identify the ConfigurationSetting

  • label (str) – label used to identify the ConfigurationSetting

Keyword Arguments
  • etag (str) – check if the ConfigurationSetting is changed. Set None to skip checking etag

  • match_condition (MatchConditions) – the match condition to use upon the etag

  • headers (dict) – if “headers” exists, its value (a dict) will be added to the http request

Returns

The deleted ConfigurationSetting returned from the service, or None if it doesn’t exist.

Return type

ConfigurationSetting

Raises

HttpResponseError, ClientAuthenticationError, ResourceReadOnlyError, ResourceModifiedError, ResourceNotModifiedError, ResourceNotFoundError, ResourceExistsError

Example

# in async function
deleted_config_setting = await async_client.delete_configuration_setting(
    key="MyKey", label="MyLabel"
)
classmethod from_connection_string(connection_string, **kwargs)[source]

Create AzureAppConfigurationClient from a Connection String.

param connection_string

Connection String (one of the access keys of the Azure App Configuration resource) used to access the Azure App Configuration.

type connection_string

str

This is the async version of azure.appconfiguration.AzureAppConfigurationClient

Example

from azure.appconfiguration.aio import AzureAppConfigurationClient
connection_str = "<my connection string>"
async_client = AzureAppConfigurationClient.from_connection_string(connection_str)
async get_configuration_setting(key, label=None, etag='*', match_condition=<MatchConditions.Unconditionally: 1>, **kwargs)[source]

Get the matched ConfigurationSetting from Azure App Configuration service

Parameters
  • key (str) – key of the ConfigurationSetting

  • label (str) – label of the ConfigurationSetting

  • etag (str or None) – check if the ConfigurationSetting is changed. Set None to skip checking etag

  • match_condition (MatchConditions) – the match condition to use upon the etag

Keyword Arguments
  • accept_datetime (datetime) – the retrieved ConfigurationSetting that created no later than this datetime

  • headers (dict) – if “headers” exists, its value (a dict) will be added to the http request header

Returns

The matched ConfigurationSetting object

Return type

ConfigurationSetting

Raises

HttpResponseError, ClientAuthenticationError, ResourceNotFoundError, ResourceModifiedError, ResourceExistsError

Example

# in async function
fetched_config_setting = await async_client.get_configuration_setting(
    key="MyKey", label="MyLabel"
)
list_configuration_settings(keys=None, labels=None, **kwargs)[source]

List the configuration settings stored in the configuration service, optionally filtered by label and accept_datetime

Parameters
  • keys (list[str]) – filter results based on their keys. ‘*’ can be used as wildcard in the beginning or end of the filter

  • labels (list[str]) – filter results based on their label. ‘*’ can be used as wildcard in the beginning or end of the filter

Keyword Arguments
  • accept_datetime (datetime) – filter out ConfigurationSetting created after this datetime

  • fields (list[str]) – specify which fields to include in the results. Leave None to include all fields

  • headers (dict) – if “headers” exists, its value (a dict) will be added to the http request header

Returns

An iterator of ConfigurationSetting

Return type

azure.core.paging.ItemPaged[ConfigurationSetting]

Raises

HttpResponseError, ClientAuthenticationError

Example

from datetime import datetime, timedelta

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

all_listed = async_client.list_configuration_settings()
async for item in all_listed:
    pass  # do something

filtered_listed = async_client.list_configuration_settings(
    labels=["*Labe*"], keys=["*Ke*"], accept_datetime=accept_datetime
)
async for item in filtered_listed:
    pass  # do something
list_revisions(keys=None, labels=None, **kwargs)[source]

Find the ConfigurationSetting revision history.

Parameters
  • keys (list[str]) – filter results based on their keys. ‘*’ can be used as wildcard in the beginning or end of the filter

  • labels (list[str]) – filter results based on their label. ‘*’ can be used as wildcard in the beginning or end of the filter

Keyword Arguments
  • accept_datetime (datetime) – filter out ConfigurationSetting created after this datetime

  • fields (list[str]) – specify which fields to include in the results. Leave None to include all fields

  • headers (dict) – if “headers” exists, its value (a dict) will be added to the http request header

Returns

An iterator of ConfigurationSetting

Return type

azure.core.paging.ItemPaged[ConfigurationSetting]

Raises

HttpResponseError, ClientAuthenticationError

Example

# in async function
from datetime import datetime, timedelta

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

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

filtered_revisions = async_client.list_revisions(
    labels=["*Labe*"], keys=["*Ke*"], accept_datetime=accept_datetime
)
async for item in filtered_revisions:
    pass  # do something
async set_configuration_setting(configuration_setting, match_condition=<MatchConditions.Unconditionally: 1>, **kwargs)[source]

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.

Parameters
  • configuration_setting (ConfigurationSetting) – the ConfigurationSetting to be added (if not exists) or updated (if exists) to the service

  • match_condition (MatchConditions) – the match condition to use upon the etag

Keyword Arguments

headers (dict) – if “headers” exists, its value (a dict) will be added to the http request header

Returns

The ConfigurationSetting returned from the service

Return type

ConfigurationSetting

Raises

HttpResponseError, ClientAuthenticationError, ResourceReadOnlyError, ResourceModifiedError, ResourceNotModifiedError, ResourceNotFoundError, ResourceExistsError

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(configuration_setting, **kwargs)[source]

Set a configuration setting read only

Parameters

configuration_setting (ConfigurationSetting) – the ConfigurationSetting to be set read only

Keyword Arguments

headers (dict) – if “headers” exists, its value (a dict) will be added to the http request header

Returns

The ConfigurationSetting returned from the service

Return type

ConfigurationSetting

Raises

HttpResponseError, ClientAuthenticationError, ResourceNotFoundError

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)