def example_create_servicebus_receiver_sync(): servicebus_client = example_create_servicebus_client_sync() # [START create_servicebus_receiver_from_conn_str_sync] import os from azure.servicebus import ServiceBusReceiver servicebus_connection_str = os.environ['SERVICE_BUS_CONNECTION_STR'] queue_name = os.environ['SERVICE_BUS_QUEUE_NAME'] queue_receiver = ServiceBusReceiver.from_connection_string( conn_str=servicebus_connection_str, queue_name=queue_name) # [END create_servicebus_receiver_from_conn_str_sync] # [START create_servicebus_receiver_sync] import os from azure.servicebus import ServiceBusReceiver, ServiceBusSharedKeyCredential fully_qualified_namespace = os.environ[ 'SERVICE_BUS_FULLY_QUALIFIED_NAMESPACE'] shared_access_policy = os.environ['SERVICE_BUS_SAS_POLICY'] shared_access_key = os.environ['SERVICE_BUS_SAS_KEY'] queue_name = os.environ['SERVICE_BUS_QUEUE_NAME'] queue_receiver = ServiceBusReceiver( fully_qualified_namespace=fully_qualified_namespace, credential=ServiceBusSharedKeyCredential(shared_access_policy, shared_access_key), queue_name=queue_name) # [END create_servicebus_receiver_sync] # [START create_servicebus_receiver_from_sb_client_sync] import os from azure.servicebus import ServiceBusClient servicebus_connection_str = os.environ['SERVICE_BUS_CONNECTION_STR'] queue_name = os.environ['SERVICE_BUS_QUEUE_NAME'] servicebus_client = ServiceBusClient.from_connection_string( conn_str=servicebus_connection_str) with servicebus_client: queue_receiver = servicebus_client.get_queue_receiver( queue_name=queue_name) # [END create_servicebus_receiver_from_sb_client_sync] # [START create_subscription_receiver_from_sb_client_sync] import os from azure.servicebus import ServiceBusClient servicebus_connection_str = os.environ['SERVICE_BUS_CONNECTION_STR'] topic_name = os.environ["SERVICE_BUS_TOPIC_NAME"] subscription_name = os.environ["SERVICE_BUS_SUBSCRIPTION_NAME"] servicebus_client = ServiceBusClient.from_connection_string( conn_str=servicebus_connection_str) with servicebus_client: subscription_receiver = servicebus_client.get_subscription_receiver( topic_name=topic_name, subscription_name=subscription_name, ) # [END create_subscription_receiver_from_sb_client_sync] return queue_receiver
def read_messages_from_queue(): servicebus_receiver = ServiceBusReceiver.from_connection_string( conn_str=EQUINIX_OUTGOING_QUEUE_CONNECTION_STRING) return servicebus_receiver