Skip to content

Commit ba3bb60

Browse files
committed
Updates from review
1 parent 476ce41 commit ba3bb60

File tree

1 file changed

+28
-30
lines changed

1 file changed

+28
-30
lines changed

articles/azure-app-configuration/quickstart-python.md

Lines changed: 28 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -98,19 +98,18 @@ You use the `DefaultAzureCredential` to authenticate to your App Configuration s
9898

9999
```python
100100
from azure.identity import DefaultAzureCredential
101-
from azure.appconfiguration import AzureAppConfigurationClient
102101

103102
credential = DefaultAzureCredential()
104103

105104
endpoint = os.getenv('AZURE_APPCONFIG_ENDPOINT')
106-
client = AzureAppConfigurationClient(base_url=endpoint, credential=credential)
105+
app_config_client = AzureAppConfigurationClient(base_url=endpoint, credential=credential)
107106
```
108107

109108
### [Connection string](#tab/connection-string)
110109

111110
```python
112-
connection_string = os.getenv('AZURE_APPCONFIG_CONNECTION_STRING')
113-
app_config_client = AzureAppConfigurationClient.from_connection_string(connection_string)
111+
connection_string = os.getenv('AZURE_APPCONFIG_CONNECTION_STRING')
112+
app_config_client = AzureAppConfigurationClient.from_connection_string(connection_string)
114113
```
115114
---
116115

@@ -119,9 +118,9 @@ client = AzureAppConfigurationClient(base_url=endpoint, credential=credential)
119118
The following code snippet retrieves a configuration setting by `key` name.
120119

121120
```python
122-
retrieved_config_setting = app_config_client.get_configuration_setting(key='TestApp:Settings:Message')
123-
print("\nRetrieved configuration setting:")
124-
print("Key: " + retrieved_config_setting.key + ", Value: " + retrieved_config_setting.value)
121+
retrieved_config_setting = app_config_client.get_configuration_setting(key='TestApp:Settings:Message')
122+
print("\nRetrieved configuration setting:")
123+
print("Key: " + retrieved_config_setting.key + ", Value: " + retrieved_config_setting.value)
125124
```
126125

127126
### Add a configuration setting
@@ -130,64 +129,63 @@ The following code snippet creates a `ConfigurationSetting` object with `key` an
130129
This method will throw an exception if you try to add a configuration setting that already exists in your store. If you want to avoid this exception, the [set_configuration_setting](#update-a-configuration-setting) method can be used instead.
131130

132131
```python
133-
config_setting = ConfigurationSetting(
134-
key='TestApp:Settings:NewSetting',
135-
value='New setting value'
136-
)
137-
added_config_setting = app_config_client.add_configuration_setting(config_setting)
138-
print("\nAdded configuration setting:")
139-
print("Key: " + added_config_setting.key + ", Value: " + added_config_setting.value)
132+
config_setting = ConfigurationSetting(
133+
key='TestApp:Settings:NewSetting',
134+
value='New setting value'
135+
)
136+
added_config_setting = app_config_client.add_configuration_setting(config_setting)
137+
print("\nAdded configuration setting:")
138+
print("Key: " + added_config_setting.key + ", Value: " + added_config_setting.value)
140139
```
141140

142141
### Get a list of configuration settings
143142

144143
The following code snippet retrieves a list of configuration settings. The `key_filter` and `label_filter` arguments can be provided to filter key-values based on `key` and `label` respectively. For more information on filtering, see how to [query configuration settings](./concept-key-value.md#query-key-values).
145144

146145
```python
147-
filtered_settings_list = app_config_client.list_configuration_settings(key_filter="TestApp*")
148-
print("\nRetrieved list of configuration settings:")
149-
for item in filtered_settings_list:
150-
print("Key: " + item.key + ", Value: " + item.value)
146+
filtered_settings_list = app_config_client.list_configuration_settings(key_filter="TestApp*")
147+
print("\nRetrieved list of configuration settings:")
148+
for item in filtered_settings_list:
149+
print("Key: " + item.key + ", Value: " + item.value)
151150
```
152151

153152
### Lock a configuration setting
154153

155154
The lock status of a key-value in App Configuration is denoted by the `read_only` attribute of the `ConfigurationSetting` object. If `read_only` is `True`, the setting is locked. The `set_read_only` method can be invoked with `read_only=True` argument to lock the configuration setting.
156155

157156
```python
158-
locked_config_setting = app_config_client.set_read_only(added_config_setting, read_only=True)
159-
print("\nRead-only status for " + locked_config_setting.key + ": " + str(locked_config_setting.read_only))
157+
locked_config_setting = app_config_client.set_read_only(added_config_setting, read_only=True)
158+
print("\nRead-only status for " + locked_config_setting.key + ": " + str(locked_config_setting.read_only))
160159
```
161160

162161
### Unlock a configuration setting
163162

164163
If the `read_only` attribute of a `ConfigurationSetting` is `False`, the setting is unlocked. The `set_read_only` method can be invoked with `read_only=False` argument to unlock the configuration setting.
165164

166165
```python
167-
unlocked_config_setting = app_config_client.set_read_only(locked_config_setting, read_only=False)
168-
print("\nRead-only status for " + unlocked_config_setting.key + ": " + str(unlocked_config_setting.read_only))
166+
unlocked_config_setting = app_config_client.set_read_only(locked_config_setting, read_only=False)
167+
print("\nRead-only status for " + unlocked_config_setting.key + ": " + str(unlocked_config_setting.read_only))
169168
```
170169

171170
### Update a configuration setting
172171

173172
The `set_configuration_setting` method can be used to update an existing setting or create a new setting. The following code snippet changes the value of an existing configuration setting.
174173

175174
```python
176-
added_config_setting.value = "Value has been updated!"
177-
updated_config_setting = app_config_client.set_configuration_setting(added_config_setting)
178-
print("\nUpdated configuration setting:")
179-
print("Key: " + updated_config_setting.key + ", Value: " + updated_config_setting.value)
175+
added_config_setting.value = "Value has been updated!"
176+
updated_config_setting = app_config_client.set_configuration_setting(added_config_setting)
177+
print("\nUpdated configuration setting:")
178+
print("Key: " + updated_config_setting.key + ", Value: " + updated_config_setting.value)
180179
```
181180

182181
### Delete a configuration setting
183182

184183
The following code snippet deletes a configuration setting by `key` name.
185184

186185
```python
187-
188-
deleted_config_setting = app_config_client.delete_configuration_setting(key="TestApp:Settings:NewSetting")
189-
print("\nDeleted configuration setting:")
190-
print("Key: " + deleted_config_setting.key + ", Value: " + deleted_config_setting.value)
186+
deleted_config_setting = app_config_client.delete_configuration_setting(key="TestApp:Settings:NewSetting")
187+
print("\nDeleted configuration setting:")
188+
print("Key: " + deleted_config_setting.key + ", Value: " + deleted_config_setting.value)
191189
```
192190

193191
## Run the app

0 commit comments

Comments
 (0)