Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ pip install azure-appconfiguration
| conditional_operation_sample.py / conditional_operation_async_sample.py | demos conditional set/get/delete operations |
| read_only_sample.py / read_only_async_sample.py | demos set_read_only operations |
| list_revision_sample.py / list_revision_async_sample.py | demos list revision operations |
| sync_token_samples.py / sync_token_async_samples.py | demos the `update_sync_token` method |

<!-- LINKS -->
[azure_sub]: https://azure.microsoft.com/free/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# coding: utf-8

# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------

"""
FILE: sync_token_async_samples.py
DESCRIPTION:
This sample demos update_sync_token for the AzureAppConfigurationClient
USAGE: python sync_token_async_samples.py
"""

import asyncio
from azure.appconfiguration.aio import AzureAppConfigurationClient
from util import print_configuration_setting, get_connection_string


async def handle_event_grid_notifications(event_grid_events):
# type: (List[dict[str, Any]]) -> None
CONNECTION_STRING = get_connection_string()

all_keys = []

async with AzureAppConfigurationClient.from_connection_string(CONNECTION_STRING) as client:

for event_grid_event in event_grid_events:
if event_grid_event["eventType"] == 'Microsoft.KeyValueModified':
sync_token = event['data']['syncToken']
client.update_sync_token(sync_token)

new_key = await client.get_configuration_setting(key=event['data']['key'], label=event['data']['label'])

all_keys.append(new_key)


if __name__ == "__main__":
loop = asyncio.get_event_loop()
loop.run_until_complete(handle_event_grid_notifications([]))
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# coding: utf-8

# -------------------------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License. See License.txt in the project root for
# license information.
# --------------------------------------------------------------------------

"""
FILE: sync_token_samples.py
DESCRIPTION:
This sample demos update_sync_token for the AzureAppConfigurationClient
USAGE: python sync_token_samples.py
"""

from azure.appconfiguration import AzureAppConfigurationClient
from util import print_configuration_setting, get_connection_string


def handle_event_grid_notifications(event_grid_events):
# type: (List[dict[str, Any]]) -> None
CONNECTION_STRING = get_connection_string()

all_keys = []

with AzureAppConfigurationClient.from_connection_string(CONNECTION_STRING) as client:

for event_grid_event in event_grid_events:
if event_grid_event["eventType"] == 'Microsoft.KeyValueModified':
sync_token = event['data']['syncToken']
client.update_sync_token(sync_token)

new_key = client.get_configuration_setting(key=event['data']['key'], label=event['data']['label'])

all_keys.append(new_key)


if __name__ == "__main__":
handle_event_grid_notifications([])