Skip to content

Commit 921ad51

Browse files
committed
samples for new features
1 parent 3bb49cf commit 921ad51

File tree

2 files changed

+44
-0
lines changed

2 files changed

+44
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# --------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for
4+
# license information.
5+
# --------------------------------------------------------------------------
6+
import os
7+
from azure.eventgrid import EventGridClient
8+
from azure.eventgrid.models import *
9+
from azure.identity import DefaultAzureCredential
10+
11+
EVENTGRID_ENDPOINT: str = os.environ["EVENTGRID_ENDPOINT"]
12+
13+
# Create a client using DefaultAzureCredential
14+
client = EventGridClient(EVENTGRID_ENDPOINT, DefaultAzureCredential())
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# --------------------------------------------------------------------------
2+
# Copyright (c) Microsoft Corporation. All rights reserved.
3+
# Licensed under the MIT License. See License.txt in the project root for
4+
# license information.
5+
# --------------------------------------------------------------------------
6+
import os
7+
from azure.core.credentials import AzureKeyCredential
8+
from azure.eventgrid import EventGridClient
9+
from azure.eventgrid.models import *
10+
from azure.core.exceptions import HttpResponseError
11+
12+
EVENTGRID_KEY: str = os.environ["EVENTGRID_KEY"]
13+
EVENTGRID_ENDPOINT: str = os.environ["EVENTGRID_ENDPOINT"]
14+
TOPIC_NAME: str = os.environ["EVENTGRID_TOPIC_NAME"]
15+
EVENT_SUBSCRIPTION_NAME: str = os.environ["EVENTGRID_EVENT_SUBSCRIPTION_NAME"]
16+
17+
# Create a client
18+
client = EventGridClient(EVENTGRID_ENDPOINT, AzureKeyCredential(EVENTGRID_KEY))
19+
20+
# Renew a lockToken
21+
try:
22+
lock_tokens = RenewLockOptions(lock_tokens=["token"])
23+
release_events = client.renew_cloud_event_locks(
24+
topic_name=TOPIC_NAME,
25+
event_subscription_name=EVENT_SUBSCRIPTION_NAME,
26+
renew_lock_options=lock_tokens,
27+
)
28+
print(release_events)
29+
except HttpResponseError:
30+
raise

0 commit comments

Comments
 (0)