Azure functions recently changed their programming model for python as described here, https://techcommunity.microsoft.com/t5/azure-compute-blog/azure-functions-v2-python-programming-model/ba-p/3665168 and I am trying to port some code.
In v1 you use function.json to bind get the connection as an input, as well as to listen to messages from the hub.
{
"scriptFile": "__init__.py",
"bindings": [
{
"type": "webPubSubTrigger",
"direction": "in",
"name": "request",
"hub": "simplechat",
"eventName": "message",
"eventType": "user"
}
]
}
In C# and V2 for python, you should use decorators https://github.com/MicrosoftDocs/azure-docs/blob/main/articles/azure-web-pubsub/reference-functions-bindings.md but as far as I can tell, there is no decorator for this in Python.
I used Azure functions version(v3) and python version 3.10.9.
In v2 I tried using my python code but unable to reach so switched to v3 then Iam able to bind and connected. Please refer this doc for versions info
I used the below decorators to bind a route to Azure Web PubSub events using Azure Functions v2.
webpubsub_eventdecorator logs the incoming event details and passes the event request to themainfunction for further processing.