diff --git a/scripts/devops_tasks/test_run_samples.py b/scripts/devops_tasks/test_run_samples.py index d26987727a2c..5ce3b48f40d1 100644 --- a/scripts/devops_tasks/test_run_samples.py +++ b/scripts/devops_tasks/test_run_samples.py @@ -33,6 +33,9 @@ } """ TIMEOUT_SAMPLES = { + "azure-eventgrid": { + "consume_cloud_events_from_storage_queue.py": (10), + }, "azure-eventhub": { "receive_batch_with_checkpoint.py": (10), "recv.py": (10), @@ -76,10 +79,7 @@ "azure-eventgrid": [ "__init__.py", "consume_cloud_events_from_eventhub.py", - "consume_eventgrid_events_from_service_bus_queue.py", - "consume_cloud_events_from_storage_queue.py", - "sample_publish_events_to_a_topic_using_sas_credential.py", - "sample_publish_events_to_a_topic_using_sas_credential_async.py"], + "consume_eventgrid_events_from_service_bus_queue.py"], "azure-eventhub": [ "connection_to_custom_endpoint_address.py", "proxy.py", diff --git a/sdk/eventgrid/azure-eventgrid/dev_requirements.txt b/sdk/eventgrid/azure-eventgrid/dev_requirements.txt index f9efb595635a..3f90c92310b6 100644 --- a/sdk/eventgrid/azure-eventgrid/dev_requirements.txt +++ b/sdk/eventgrid/azure-eventgrid/dev_requirements.txt @@ -3,4 +3,5 @@ -e ../../core/azure-core -e ../../identity/azure-identity -e ../azure-mgmt-eventgrid +azure-storage-queue aiohttp>=3.0; python_version >= '3.5' diff --git a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_cloud_events_from_eventhub.py b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_cloud_events_from_eventhub.py index 27f56126da72..b372d4ea6752 100644 --- a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_cloud_events_from_eventhub.py +++ b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_cloud_events_from_eventhub.py @@ -13,17 +13,20 @@ 1) EVENT_HUB_CONN_STR: The connection string to the Event hub account 3) EVENTHUB_NAME: The name of the eventhub account """ + +# Note: This sample would not work on pypy since azure-eventhub +# depends on uamqp which is not pypy compatible. + import os import json from azure.core.messaging import CloudEvent from azure.eventhub import EventHubConsumerClient CONNECTION_STR = os.environ["EVENT_HUB_CONN_STR"] -EVENTHUB_NAME = os.environ["EVENTHUB_NAME"] +EVENTHUB_NAME = os.environ["EVENT_HUB_NAME"] def on_event(partition_context, event): - dict_event = CloudEvent.from_dict(json.loads(event)[0]) print("data: {}\n".format(deserialized_event.data)) diff --git a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_cloud_events_from_storage_queue.py b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_cloud_events_from_storage_queue.py index 511188b66df5..2b94f5816c2b 100644 --- a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_cloud_events_from_storage_queue.py +++ b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_cloud_events_from_storage_queue.py @@ -20,7 +20,7 @@ import json # all types of CloudEvents below produce same DeserializedEvent -connection_str = os.environ['STORAGE_QUEUE_CONN_STR'] +connection_str = os.environ['AZURE_STORAGE_CONNECTION_STRING'] queue_name = os.environ['STORAGE_QUEUE_NAME'] with QueueServiceClient.from_connection_string(connection_str) as qsc: diff --git a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_eventgrid_events_from_service_bus_queue.py b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_eventgrid_events_from_service_bus_queue.py index a99f98f4fb7f..0756043a9ac7 100644 --- a/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_eventgrid_events_from_service_bus_queue.py +++ b/sdk/eventgrid/azure-eventgrid/samples/consume_samples/consume_eventgrid_events_from_service_bus_queue.py @@ -13,13 +13,17 @@ 1) SB_CONN_STR: The connection string to the Service Bus account 3) SERVICE_BUS_QUEUE_NAME: The name of the servicebus account """ + +# Note: This sample would not work on pypy since azure-servicebus +# depends on uamqp which is not pypy compatible. + from azure.eventgrid import EventGridEvent from azure.servicebus import ServiceBusClient import os import json # all types of EventGridEvents below produce same DeserializedEvent -connection_str = os.environ['SERVICE_BUS_CONN_STR'] +connection_str = os.environ['SERVICE_BUS_CONNECTION_STR'] queue_name = os.environ['SERVICE_BUS_QUEUE_NAME'] with ServiceBusClient.from_connection_string(connection_str) as sb_client: diff --git a/sdk/eventgrid/tests.yml b/sdk/eventgrid/tests.yml index 004e3e128656..451c0153ecb7 100644 --- a/sdk/eventgrid/tests.yml +++ b/sdk/eventgrid/tests.yml @@ -7,6 +7,7 @@ stages: BuildTargetingString: azure-eventgrid* TestSamples: true EnvVars: + AZURE_STORAGE_CONNECTION_STRING: $(python-storage-blob-connection-string) AZURE_SUBSCRIPTION_ID: $(azure-subscription-id) AZURE_TENANT_ID: $(aad-azure-sdk-test-tenant-id) AZURE_CLIENT_ID: $(aad-azure-sdk-test-client-id) @@ -21,5 +22,6 @@ stages: EG_DOMAIN_TOPIC_HOSTNAME: $(python-sdk-test-domain-topic-hostname-eg) EVENTGRID_SAS: $(python-sdk-test-eg-sas) DOMAIN_NAME: $(python-sdk-test-eg-domain-name) + STORAGE_QUEUE_NAME: $(python-storage-queue-name) CUSTOM_SCHEMA_ACCESS_KEY: $(python-sdk-test-eg-custom-schema-access-key) CUSTOM_SCHEMA_TOPIC_HOSTNAME: $(python-sdk-test-custom-schema-topic-hostname)