DRgrtea

Medsos DRcjgrTeA

Media Sosial Duridwangurunatafkar

Alih Bahasa

English French German Spain Italian Dutch Russian Brazil Japanese Korean Arabic Chinese Simplified

DRMenuNavigasiBar

menunavngampar

drcnavbar

Minggu, 13 Juli 2025

Github | drAzure

 Skip to content

Files

Latest commit

99ac866 · 11 months ago

History

History

azure-appconfiguration

Folders and files

Name
Last commit message
Last commit date

parent directory

..
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
4 years ago
4 years ago
11 months ago
2 years ago
11 months ago
last year
3 years ago
11 months ago
6 years ago
last year

Azure App Configuration client library for Python

Azure App Configuration is a managed service that helps developers centralize their application configurations simply and securely.

Modern programs, especially programs running in a cloud, generally have many components that are distributed in nature. Spreading configuration settings across these components can lead to hard-to-troubleshoot errors during an application deployment. Use App Configuration to securely store all the settings for your application in one place.

Use the client library for App Configuration to create and manage application configuration settings.

Source code | Package (Pypi) | Package (Conda) | API reference documentation | Product documentation

Getting started

Install the package

Install the Azure App Configuration client library for Python with pip:

pip install azure-appconfiguration

Prerequisites

To create a Configuration Store, you can use the Azure Portal or Azure CLI.

After that, create the Configuration Store:

az appconfig create --name <config-store-name> --resource-group <resource-group-name> --location eastus

Authenticate the client

In order to interact with the App Configuration service, you'll need to create an instance of the AzureAppConfigurationClient class. To make this possible, you can either use the connection string of the Configuration Store or use an AAD token.

Use connection string

Get credentials

Use the Azure CLI snippet below to get the connection string from the Configuration Store.

az appconfig credential list --name <config-store-name>

Alternatively, get the connection string from the Azure Portal.

Create client

Once you have the value of the connection string, you can create the AzureAppConfigurationClient:

import os
from azure.appconfiguration import AzureAppConfigurationClient

CONNECTION_STRING = os.environ["APPCONFIGURATION_CONNECTION_STRING"]

# Create app config client
client = AzureAppConfigurationClient.from_connection_string(CONNECTION_STRING)

Use AAD token

Here we demonstrate using DefaultAzureCredential to authenticate as a service principal. However, AzureAppConfigurationClient accepts any azure-identity credential. See the azure-identity documentation for more information about other credentials.

Create a service principal (optional)

This Azure CLI snippet shows how to create a new service principal. Before using it, replace "your-application-name" with the appropriate name for your service principal.

Create a service principal:

az ad sp create-for-rbac --name http://my-application --skip-assignment

Output:

{
    "appId": "generated app id",
    "displayName": "my-application",
    "name": "http://my-application",
    "password": "random password",
    "tenant": "tenant id"
}

Use the output to set AZURE_CLIENT_ID ("appId" above), AZURE_CLIENT_SECRET ("password" above) and AZURE_TENANT_ID ("tenant" above) environment variables. The following example shows a way to do this in Bash:

export AZURE_CLIENT_ID="generated app id"
export AZURE_CLIENT_SECRET="random password"
export AZURE_TENANT_ID="tenant id"

Assign one of the applicable App Configuration roles to the service principal.

Create a client

Once the AZURE_CLIENT_IDAZURE_CLIENT_SECRET and AZURE_TENANT_ID environment variables are set, DefaultAzureCredential will be able to authenticate the AzureAppConfigurationClient.

Constructing the client also requires your configuration store's URL, which you can get from the Azure CLI or the Azure Portal. In the Azure Portal, the URL can be found listed as the service "Endpoint"

from azure.identity import DefaultAzureCredential
from azure.appconfiguration import AzureAppConfigurationClient

credential = DefaultAzureCredential()

client = AzureAppConfigurationClient(base_url="your_endpoint_url", credential=credential)

Key concepts

Configuration Setting

A Configuration Setting is the fundamental resource within a Configuration Store. In its simplest form it is a key and a value. However, there are additional properties such as the modifiable content type and tags fields that allow the value to be interpreted or associated in different ways.

The Label property of a Configuration Setting provides a way to separate Configuration Settings into different dimensions. These dimensions are user defined and can take any form. Some common examples of dimensions to use for a label include regions, semantic versions, or environments. Many applications have a required set of configuration keys that have varying values as the application exists across different dimensions.

For example, MaxRequests may be 100 in "NorthAmerica", and 200 in "WestEurope". By creating a Configuration Setting named MaxRequests with a label of "NorthAmerica" and another, only with a different value, in the "WestEurope" label, an application can seamlessly retrieve Configuration Settings as it runs in these two dimensions.

Properties of a Configuration Setting:

key : str
label : str
content_type : str
value : str
last_modified : str
read_only : bool
tags : dict
etag : str

Snapshot

Azure App Configuration allows users to create a point-in-time snapshot of their configuration store, providing them with the ability to treat settings as one consistent version. This feature enables applications to hold a consistent view of configuration, ensuring that there are no version mismatches to individual settings due to reading as updates were made. Snapshots are immutable, ensuring that configuration can confidently be rolled back to a last-known-good configuration in the event of a problem.

Examples

The following sections provide several code snippets covering some of the most common Configuration Service tasks, including:

Create a Configuration Setting

Create a Configuration Setting to be stored in the Configuration Store. There are two ways to store a Configuration Setting:

  • add_configuration_setting creates a setting only if the setting does not already exist in the store.
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)
  • set_configuration_setting creates a setting if it doesn't exist or overrides an existing setting.
added_config_setting.value = "new value"
added_config_setting.content_type = "new content type"
updated_config_setting = client.set_configuration_setting(added_config_setting)

Set and clear read-only for a configuration setting.

  • Set a configuration setting to be read-only.
read_only_config_setting = client.set_read_only(updated_config_setting)
  • Clear read-only for a configuration setting.
read_write_config_setting = client.set_read_only(updated_config_setting, False)

Get a Configuration Setting

Get a previously stored Configuration Setting.

fetched_config_setting = client.get_configuration_setting(key="MyKey", label="MyLabel")

Delete a Configuration Setting

Delete an existing Configuration Setting.

client.delete_configuration_setting(key="MyKey", label="MyLabel")

List Configuration Settings

List all configuration settings filtered with label_filter and/or key_filter and/or tags_filter.

config_settings = client.list_configuration_settings(key_filter="MyKey*", tags_filter=["my tag1=my tag1 value"])
for config_setting in config_settings:
    print(config_setting)

List revisions

List revision history of configuration settings filtered with label_filter and/or key_filter and/or tags_filter.

items = client.list_revisions(key_filter="MyKey", tags_filter=["my tag=my tag value"])
for item in items:
    print(item)

List labels

List labels of all configuration settings.

print("List all labels in resource")
config_settings = client.list_labels()
for config_setting in config_settings:
    print(config_setting)

print("List labels by exact match")
config_settings = client.list_labels(name="my label1")
for config_setting in config_settings:
    print(config_setting)

print("List labels by wildcard")
config_settings = client.list_labels(name="my label*")
for config_setting in config_settings:
    print(config_setting)

Create a Snapshot

from azure.appconfiguration import ConfigurationSettingsFilter

filters = [ConfigurationSettingsFilter(key="my_key1", label="my_label1")]
response = client.begin_create_snapshot(name=snapshot_name, filters=filters)
created_snapshot = response.result()

Get a Snapshot

received_snapshot = client.get_snapshot(name=snapshot_name)

Archive a Snapshot

archived_snapshot = client.archive_snapshot(name=snapshot_name)

Recover a Snapshot

recovered_snapshot = client.recover_snapshot(name=snapshot_name)

List Snapshots

for snapshot in client.list_snapshots():
    print(snapshot)

List Configuration Settings of a Snapshot

for config_setting in client.list_configuration_settings(snapshot_name=snapshot_name):
    print(config_setting)

Async APIs

Async client is supported. To use the async client library, import the AzureAppConfigurationClient from package azure.appconfiguration.aio instead of azure.appconfiguration.

import os
from azure.appconfiguration.aio import AzureAppConfigurationClient

CONNECTION_STRING = os.environ["APPCONFIGURATION_CONNECTION_STRING"]

# Create an app config client
client = AzureAppConfigurationClient.from_connection_string(CONNECTION_STRING)

This async AzureAppConfigurationClient has the same method signatures as the sync ones except that they're async.
For instance, retrieve a Configuration Setting asynchronously:

fetched_config_setting = await client.get_configuration_setting(key="MyKey", label="MyLabel")

To list configuration settings, call list_configuration_settings operation synchronously and iterate over the returned async iterator asynchronously:

config_settings = client.list_configuration_settings(key_filter="MyKey*", tags_filter=["my tag1=my tag1 value"])
async for config_setting in config_settings:
    print(config_setting)

Troubleshooting

See the troubleshooting guide for details on how to diagnose various failure scenarios.

Next steps

More sample code

Several App Configuration client library samples are available to you in this GitHub repository. These include:

For more details see the samples README.

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

When you submit a pull request, a CLA-bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., label, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information, see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.

4456 branches found

Tidak ada komentar:

Posting Komentar

Posting Populer

Duridwan TeA Google Arsip

Tampil Ful Skrin

Tampilan penuh layar

Klik tombol "Penuh" untuk mode ful skrin. Tutup dengan cara klik tuts "Esc" di kibot, atau dengan mengklik tombol "Normal" saja.

Penuh Normal

Materi artikel

DRLabel

.NETdr 'Urwah ۝۞ دعاء الأوراد ۞۝ 1drive 2019 3Dwarehouse Abaib Academia AdminisGuru Adzan AKGTK Akrab 9497 AkselelatorDRc Aksioma Alfa Aljamal Anakku Android Apache API Aplikasi Aplikasi Online Aplikasiku aqidah aqo'id Arsiper Arudl ASPnet Atribusi Attaqwa Audacity Audio Aurod AutoCAD ba'da sholat Ba'diyah Babad Bahasa Indonesia Balaghoh Baleomol bangpol Banner basund Belajar.id Biantara bilibiliTV bing.com Biografi Bisikan Bisnis Blog blogku Bluestack BMTT Bola Dunia Boxmode BUKU C++ Caknun Canva Capcut CData Cerita Chanel Cijagong cmd Copast Coreldraw;Koreldrow cortang CPANEL cv Daftar Isi Daftar Tamu Dailymotion Dakwah Daring db515TB Dek@t Dikdasmen Diktat Do''a Domainesia dongeng Download DRctvone DRcVivaTV DRlink drMedsos drSamiraTeA drSoftaculous drSQL DRxampp DTD Duridwancijag duridwanMI E-Book Earth eDGe Edmodo Edwin eftepe ekstensi Emulated Epson eSDeKU Excel Facebook Fafa Belajar favicon FB FBwatch Fikih Film FKGN FKSS Flickr ftf ftp Gambar Gaweku GDexcel GDrive GDword Gif Giphy Github Goguru GooForm googele GooTeA GooWork Gosiswawi GS v2 Gudang Gif GuMeng Guru Hotmail HP HPpc HPrint HUDHUD ATTWITERI humor HVR iframe IHTT IIS IKBAL ikonku Ilham Ilmu Waris Imam Mahdi Iman imrithi imtihan Inlislite ips Ips siswa irkhash Ishol Israel Jackie Chan JadwalHirup Jendelatea Jerosimut Jurumiah Kaamengan Kaldik karuhun Kasintu Kasyif Kemdak Kenangan Kepesantrenan KHMZ Khutbah Idul Adha Khutbah Jum'at Kitab Koneng KlaudiAwan KMS KodeBlok Koding Komentarku konsorsium Kristen KSM KSM_24 kulsub Kumer Kutab Kuning Lalogin Laporan link lirik sunda Literasi LKSATA Logo lokalhost Lokasi LTNU Malaikat Mama Gelar mapel Mapel Plus marawis materi ajar materi ips materi sunda Mediafire Menu Mulai Messenger meta Metode Belajar MGMP MTS Mi.co.id Microsoft Mikrosoft Word MKKS MKSS MKT Modul MoU Movie MTs. Muhawarot Mushaf Sunda Mvs Nabi nadhom nahwu Nashoih Nasihat Pernikahan Nasrudin Hoja Nasyid NewTabTvSearch Ngablog ngaDOS Ngaji Pontren Nganet Ngaos ngaweb Ngimel Ngobrol Solat ngobrolgurutea ngoding Ngoleksi Nikah Nonton Nubuwwah NUID NUPTKku Nyekrip Nyitus OderPejKu Office office 2010 Office.co.id Offidocs ome Ome.TV omeaeun Onedrive Onlen Opis OpisTeA Oracle OSIS Outlook Pakakas Pamilarian Panulung PaperDropboxTeA PAS PAS S1 PAT pdf Penahexa Penilaian Perangkat Guru Peringatan Nabi perpus Perpusdig PHBI photo Phyton Pintarkem PKKM PKKS PKSS PohonKeluarga Ponpes Portabel Post WA PPDB PPKKS Prkt Ltk Program Files Proker Proposal Prosem Prota PTS PTS S1 publikteaqta Pupujian Quran Sunda Rapat RDM Removal renungan Resize RFC RidsyafTeA Risalah Risalah Sholat RKS Rohbiyah Romadlon Romadon Rumus Rumus;PHP; RumusHead s.idku Safari Santif Sanusi segitiga Sekolah seren tampi Sertifikat sholat Shopee Shorof sifat_20 Silaturahmi Simdif SIMPATIKA sinopsis sipd siswa sitegog Skenario Belajar Sketchup SketsaupTeA Slayid SMA Soal Soanten Software SoraTeuPerluNinggal StoryTelling Suara Sukapura sumputkeun sunda syare'at Ta'lim tabir mimpi Tadabbur tadarrus TafkarMart Tahajud Tahlil Tasbeh Taskbar Tauhid Tawasul Tema Blog tenor.com Terjemah tiktok TimTeA tips n trick Trik Tsaqifah tulisan TV Nasional Twitter Usaha Vektor Video Video Player Video;Edit Video;Rara VideoPost vidio w3s WA - AYT wahyu Wali Walimahan Wallpaper wayang WeA Windows Wirid Witir word Wordpress WordTeA WorldBank WP WPS WS XLS DRcjgTeA Yahoo yandexck Yapista link YT ytDuridwanSunda YTstudio Yutub ZIP Zoom سلاح الدعوة
×
Judul