-
Notifications
You must be signed in to change notification settings - Fork 107
Add support for ServiceBus bindings #158
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
"disabled": false, | ||
"bindings": [ | ||
{ | ||
"type": "httpTrigger", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
serviceBusTrigger?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ServiceBusQueue Trigger sample
"bindings": [
{
"name": "myQueueItem",
"type": "serviceBusTrigger",
"direction": "in",
"queueName": "myqueue",
"connection": "pgopafunctestsb_RootManageSharedAccessKey_SERVICEBUS",
"accessRights": "Manage"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this is not a trigger. This is an http-triggered check to see if a trigger has fired. Similar to other bindings.
{ | ||
"type": "httpTrigger", | ||
"direction": "in", | ||
"name": "req" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ServiceBusTopic Trigger
"bindings": [
{
"name": "mySbMsg",
"type": "serviceBusTrigger",
"direction": "in",
"topicName": "mytopic",
"subscriptionName": "mysubscription",
"connection": "pgopafunctestsb_RootManageSharedAccessKey_SERVICEBUS",
"accessRights": "Manage"
}
],
Update the tests and let me know if still does not work |
@@ -0,0 +1,21 @@ | |||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual trigger function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From the documentation https://docs.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus looks like we only have OutputBinding and ServiceBusTrigger.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't understand. This is a "serviceBusTrigger" function. It does get triggered. My issue is that the data passed by the host to the trigger is incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How is the function triggerred? Are you using storage sdk to input values into ServiceBusQueue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I put a message into a queue by calling another function with an output binding.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add link to that test here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's in the last file in this PR.
function.json
:
{
"scriptFile": "__init__.py",
"disabled": false,
"bindings": [
{
"type": "httpTrigger",
"direction": "in",
"name": "req"
},
{
"direction": "out",
"name": "msg",
"queueName": "testqueue",
"connection": "AzureWebJobsServiceBusConnectionString",
"type": "serviceBus"
},
{
"direction": "out",
"name": "$return",
"type": "http"
}
]
}
init.py
:
import azure.functions as azf
def main(req: azf.HttpRequest, msg: azf.Out[str]):
msg.set(req.get_body())
return 'OK'
import azure.functions as azf | ||
|
||
|
||
def main(msg: azf.QueueMessage) -> bytes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if I am looking at the right file. Is this right? QueueMessage? Should it be ServiceBusMessage? It will be easier if you just paste function.json, init.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, that's a different trigger, disregard it for now. The correct trigger is in tests/servicebus_functions/servicebus_trigger/__init__.py
:
import json
import azure.functions as azf
def main(msg: azf.ServiceBusMessage) -> str:
result = json.dumps({
'message_id': msg.message_id,
'body': msg.get_body().decode('utf-8'), # the body here is invalid
'content_type': msg.content_type,
'expiration_time': msg.expiration_time,
'label': msg.label,
'partition_key': msg.partition_key,
'reply_to': msg.reply_to,
'reply_to_session_id': msg.reply_to_session_id,
'scheduled_enqueue_time': msg.scheduled_enqueue_time,
'session_id': msg.session_id,
'time_to_live': msg.time_to_live,
'to': msg.to,
'user_properties': msg.user_properties,
})
return result
function.json
:
{
"scriptFile": "__init__.py",
"disabled": false,
"bindings": [
{
"type": "serviceBusTrigger",
"direction": "in",
"name": "msg",
"queueName": "testqueue",
"connection": "AzureWebJobsServiceBusConnectionString",
},
{
"type": "blob",
"direction": "out",
"name": "$return",
"connection": "AzureWebJobsStorage",
"path": "python-worker-tests/test-servicebus-triggered.txt"
}
]
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. This helps. Test code that inserts msg into testqueue?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried different variations with JavaScript functions - HttpTrigger to ServiceBus Output binding and then verifying serviceBusTrigger gets invoked. I cannot repro this issue.
function.json and test that triggers looks OK.
At this point, we need to debug host. Here are the instructions, please give it a try
- Clone https://github.com/Azure/azure-functions-host
- Open in VSCode
- Set following environment variables
- languageWorkers:python:workerDirectory to {Dir}\azure-functions-python-worker
- languageWorkers:python:arguments to command line arguments for python to debug
- consoleLoggingMode to always
- AzureWebJobsScriptRoot to your test directory with host.json
- Set breakpoints at
- RpcMessageConversionExtensions.cs#L23 - Possible issue converting data from languageworker
- RpcMessageConversionExtensions.cs#L48 - Possible issue converting data when sending to language worker
- F5 and invoke httpTrigger that has the serviceBus output binding
cc: @soninaren - To help unblock while I am OOF |
Here's how the worker is putting the message into the queue:
Notice that the service bus message data is returned as a byte array. However, when the serviceBusTrigger is fired, the worker is sent the following:
Note that instead of the original byte array, the message body is instead sent as a Full trace follows:
|
@elprans - Any remaining work on this? |
No, this can be merged once CI issues are figured out (missing .NET build for Travis). |
@elprans are you working on the CI issues? Do you need anything from us? |
@asavaritayal I sent you an email about this. Quoting below:
|
@fabiocav - Do you know where we can follow up to get the final version of AspNetCore 2.1.0 for Linux? |
Those are available from the official download site. The Linux runtime and SDK packages are available here: https://www.microsoft.com/net/download/linux If you need to automate the isntallation, you can also look at what we do for the host install here: |
Hi @fabiocav. The download site still mentions '2.1': https://www.microsoft.com/net/download/linux-package-manager/ubuntu14-04/sdk-current Here's how we install .NET on Travis:
This worked perfectly for previous releases. I feel like throwing in that script will complicate the build unnecessarily. |
The script was in case you didn't already have something in place. These are the installation instructions for the RTM bits: |
@fabiocav That's for 18.04. Travis is on 14.04, which is where there seems to be no RTM .deb. |
Waiting on @pragnagopa to resolve AppVeyor issues. |
Btw, this issue is relevant: travis-ci/travis-ci#9684 |
@fabiocav travis-ci/travis-ci#9684 is mostly about Travis' own support for .NET. We already use an explicit repo+package configuration. Again, the issue here is missing release packages in the Microsoft apt repo, is not about |
@pragnagopa Travis CI is green on this now. |
Let’s merge this in |
Fixes: #133