I have a WebSocket that I'm subscribing to and when an event comes in, I want to trigger an Azure Function. Is this possible?
For example, I'm listening to https://alpaca.markets/docs/api-documentation/api-v2/streaming/
And whenever I get trade_updates, I want to run a function on Azure Functions
No, it is not possible to connect directly, so far the azure function only supports these trigger:
https://learn.microsoft.com/en-us/azure/azure-functions/functions-triggers-bindings#supported-bindings
(Please note the trigger column. Only ten services is supported.)
An important reason why WebSocket is not directly supported is because it is a stateful protocol, and the azure function is stateless at the beginning of the design. In addition, WebSocket needs to create a connection first. After you create a connection, it will still consume the resources of the virtual machine even if it is idle. The main billing basis of the azure function consumption plan is the number of executions. It will be troublesome in terms of billing.
The correct approach should be to use another program to listen and put the information you need to pass into the request or queue, and then use httptrigger or queuetrigger to capture the information and process it. It is not feasible to directly use WebSocket as a trigger.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With