Closed alexgman closed 5 years ago
Just func new
and pick the Service Bus template. Do you mean there's no output binding for Service Bus in the runtime?
correct, there's no output binding
On Fri, Aug 2, 2019 at 11:52 AM Adrian Calinescu notifications@github.com wrote:
Just func new and pick the Service Bus template. Do you mean there's no output binding for Service Bus in the runtime?
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/yokawasa/azure-functions-python-samples/issues/25?email_source=notifications&email_token=ABAIE3YVRT2AZUB4VLNPKKTQCRQ5FA5CNFSM4II7DMI2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOD3OJFMQ#issuecomment-517771954, or mute the thread https://github.com/notifications/unsubscribe-auth/ABAIE33PZUUGLCFTXYKGVYLQCRQ5FANCNFSM4II7DMIQ .
Use a Storage Queue output binding for your main function and create a second function that triggers on that Storage Queue and writes to Service Bus using the storage SDK. This way, once there's a Service Bus output binding you only need to change configuration, not code. Of course you can do it all in one function if you wish, just a personal preference to separate concerns.
from azure.servicebus import QueueClient, Message
# Create the QueueClient
queue_client = QueueClient.from_connection_string(
"<CONNECTION STRING>", "<QUEUE NAME>")
# Send a test message to the queue
msg = Message(b'Test Message')
queue_client.send(msg)
Don't forget to add azure.servicebus
to your function app's requirements.txt
.
Wait, judging by this there is an output binding for Service Bus. Try that first.
This PR (https://github.com/yokawasa/azure-functions-python-samples/pull/26) adds a sample for Service Bus trigger and output. I've tested it, the message gets added to the output Service Bus queue successfully.
@alexgman We close the issue ( See PR #26). Please feel free to open if you need further discussion!
Is there a way to read/write from service bus queue using python? I know there might not be a way to using an explicit binding, but perhaps there's a manual way where we establish a connection and manually put a message on a service bus queue? My main interest is in triggering with servicebus and then output to servicebus