Reputation: 93
I wrote a python code using Time Trigger in Azure Function, that takes data from an api and sends it to Event Hub. When I'm executing the function, I'm getting the following error:
System.Private.CoreLib: Exception while executing function: Functions.TimerTrigger. Microsoft.Azure.WebJobs.Host: Error while handling parameter _binder after function returned:. System.Private.CoreLib: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
My function.json looks as following:
{
"scriptFile": "__init__.py",
"bindings": [
{
"name": "mytimer",
"type": "timerTrigger",
"direction": "in",
"schedule": "0 */1 * * * *"
},
{
"type": "eventHub",
"name": "output",
"eventHubName": "eventhub-af-project",
"connection": "myconnection",
"direction": "out"
}
]
}
The connection is defined in my local.settings.json, as well as in the configuration tab on Azure. I used the Connection string–primary key with manage, send and listen rights.
Is there anything that I've missed?
Upvotes: 0
Views: 907
Reputation: 4778
In Main
function change your return type from None
to str
def main(
mytimer: func.TimerRequest) ->
str:
Also, your connection
property should have the name of the app setting that contains the connection string like this:
"type": "eventHub",
"name": "$return",
"eventHubName": "sqlserverstreaming",
"connection": "MyConnStringAppSetting",
"direction": "out"
And then create an app setting named MyConnStringAppSetting
and put your full connection string in there.
Refer here for complete example & SO Reference
Upvotes: 1