azure.appconfiguration package

exception azure.appconfiguration.ResourceReadOnlyError(message=None, response=None, **kwargs)[source]

An error response with status code 409

The key is read-only.

To allow modification unlock it first.

raise_with_traceback()
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

args
class azure.appconfiguration.AzureAppConfigurationClient(base_url: str, credential: Any, **kwargs: Any)[source]

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

Parameters
  • base_url (str) – base url of the service

  • credential (AppConfigConnectionStringCredential) – An object which can provide secrets for the app configuration service

Keyword Arguments
  • pipeline (Pipeline) – If omitted, the standard pipeline is used.

  • transport (HttpTransport) – If omitted, the standard pipeline is used.

  • policies (list[HTTPPolicy]) – If omitted, the standard pipeline is used.

add_configuration_setting(configuration_setting: azure.appconfiguration._models.ConfigurationSetting, **kwargs: Any) → azure.appconfiguration._models.ConfigurationSetting[source]

Add a ConfigurationSetting instance 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

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)
close()None[source]

Close all connections made by the client

delete_configuration_setting(key: str, label: Optional[str] = None, **kwargs: Any) → azure.appconfiguration._models.ConfigurationSetting[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

deleted_config_setting = client.delete_configuration_setting(
    key="MyKey", label="MyLabel"
)
classmethod from_connection_string(connection_string: str, **kwargs: Any) → azure.appconfiguration._azure_appconfiguration_client.AzureAppConfigurationClient[source]

Create AzureAppConfigurationClient from a Connection String.

Parameters

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

Returns

An AzureAppConfigurationClient authenticated with the connection string

Return type

AzureAppConfigurationClient

Example

from azure.appconfiguration import AzureAppConfigurationClient
connection_str = "<my connection string>"
client = AzureAppConfigurationClient.from_connection_string(connection_str)
get_configuration_setting(key: str, label: Optional[str] = None, etag: Optional[str] = '*', match_condition: Optional[azure.core._match_conditions.MatchConditions] = <MatchConditions.Unconditionally: 1>, **kwargs: Any) → azure.appconfiguration._models.ConfigurationSetting[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

fetched_config_setting = client.get_configuration_setting(
    key="MyKey", label="MyLabel"
)
list_configuration_settings(key_filter: Optional[str] = None, label_filter: Optional[str] = None, **kwargs: Any) → ItemPaged[ConfigurationSetting][source]

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

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

  • label_filter (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

ItemPaged[ConfigurationSetting]

Raises

HttpResponseError, ClientAuthenticationError

Example

from datetime import datetime, timedelta

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

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

filtered_listed = client.list_configuration_settings(
    label_filter="Labe*", key_filter="Ke*", accept_datetime=accept_datetime
)
for item in filtered_listed:
    pass  # do something
list_revisions(key_filter: Optional[str] = None, label_filter: Optional[str] = None, **kwargs: Any) → ItemPaged[ConfigurationSetting][source]

Find the ConfigurationSetting revision history.

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

  • label_filter (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

ItemPaged[ConfigurationSetting]

Raises

HttpResponseError, ClientAuthenticationError

Example

from datetime import datetime, timedelta

accept_datetime = datetime.today() + 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=accept_datetime
)
for item in filtered_revisions:
    pass  # do something
set_configuration_setting(configuration_setting: azure.appconfiguration._models.ConfigurationSetting, match_condition: Optional[azure.core._match_conditions.MatchConditions] = <MatchConditions.Unconditionally: 1>, **kwargs: Any) → azure.appconfiguration._models.ConfigurationSetting[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

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_read_only(configuration_setting: azure.appconfiguration._models.ConfigurationSetting, read_only: Optional[bool] = True, **kwargs: Any) → azure.appconfiguration._models.ConfigurationSetting[source]

Set a configuration setting read only

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

  • read_only (bool) – set the read only setting if true, else clear the read only setting

Keyword Arguments
  • 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 header

Returns

The ConfigurationSetting returned from the service

Return type

ConfigurationSetting

Raises

HttpResponseError, ClientAuthenticationError, ResourceNotFoundError

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)
update_sync_token(token: str)None[source]

Add a sync token to the internal list of tokens.

Parameters

token (str) – The sync token to be added to the internal list of tokens

class azure.appconfiguration.ConfigurationSetting(**kwargs: Any)[source]

A configuration value. Variables are only populated by the server, and will be ignored when sending a request.

Variables
  • value (str) – The value of the configuration setting

  • etag (str) – Entity tag (etag) of the object

  • last_modified (datetime) –

  • read_only (bool) –

Parameters
as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionaly use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

validate()

Validate this model recursively and return a list of ValidationError.

Returns

A list of validation error

Return type

list

content_type = None
kind = 'Generic'
class azure.appconfiguration.FeatureFlagConfigurationSetting(feature_id: str, enabled: bool, filters: Optional[List[Dict[str, Any]]] = [], **kwargs: Any)[source]

A feature flag configuration value. Variables are only populated by the server, and will be ignored when sending a request.

Variables
  • etag (str) – Entity tag (etag) of the object

  • key (str) –

  • value (str) – The value of the configuration setting

  • enabled (bool) –

  • last_modified (datetime) –

  • read_only (bool) –

Parameters
as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionaly use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

validate()

Validate this model recursively and return a list of ValidationError.

Returns

A list of validation error

Return type

list

content_type = None
property enabled
property filters
key_prefix = '.appconfig.featureflag/'
kind = 'FeatureFlag'
class azure.appconfiguration.SecretReferenceConfigurationSetting(key: str, secret_uri: str, label: Optional[str] = None, **kwargs: Any)[source]

A configuration value that references a KeyVault Secret Variables are only populated by the server, and will be ignored when sending a request.

Variables
  • etag (str) – Entity tag (etag) of the object

  • key (str) –

  • secret_uri (str) –

  • value (str) – The value of the configuration setting

  • last_modified (datetime) –

  • read_only (bool) –

Parameters
as_dict(keep_readonly=True, key_transformer=<function attribute_transformer>, **kwargs)

Return a dict that can be JSONify using json.dump.

Advanced usage might optionaly use a callback as parameter:

Key is the attribute name used in Python. Attr_desc is a dict of metadata. Currently contains ‘type’ with the msrest type and ‘key’ with the RestAPI encoded key. Value is the current value in this object.

The string returned will be used to serialize the key. If the return type is a list, this is considered hierarchical result dict.

See the three examples in this file:

  • attribute_transformer

  • full_restapi_key_transformer

  • last_restapi_key_transformer

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

key_transformer (function) – A key transformer function.

Returns

A dict JSON compatible object

Return type

dict

classmethod deserialize(data, content_type=None)

Parse a str using the RestAPI syntax and return a model.

Parameters
  • data (str) – A str using RestAPI structure. JSON by default.

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod enable_additional_properties_sending()
classmethod from_dict(data, key_extractors=None, content_type=None)

Parse a dict using given key extractor return a model.

By default consider key extractors (rest_key_case_insensitive_extractor, attribute_key_case_insensitive_extractor and last_rest_key_case_insensitive_extractor)

Parameters
  • data (dict) – A dict using RestAPI structure

  • content_type (str) – JSON by default, set application/xml if XML.

Returns

An instance of this model

Raises

DeserializationError if something went wrong

classmethod is_xml_model()
serialize(keep_readonly=False, **kwargs)

Return the JSON that would be sent to azure from this model.

This is an alias to as_dict(full_restapi_key_transformer, keep_readonly=False).

If you want XML serialization, you can pass the kwargs is_xml=True.

Parameters

keep_readonly (bool) – If you want to serialize the readonly attributes

Returns

A dict JSON compatible object

Return type

dict

validate()

Validate this model recursively and return a list of ValidationError.

Returns

A list of validation error

Return type

list

content_type = None
kind = 'SecretReference'
property secret_uri

Subpackages