We have learnt about serverless computing on Azure using Azure Functions and Cosmos DB in a previous post. In this post lets see how we can run an Azure Function from an Azure Stream Analytics job.
This can be achieved in the following steps:
Step 1: Create Azure Stream Analytics job: This can be done using the Azure portal UI.
Step 2: Create an Azure Cache for Redis instance: After creating a cache, make a note of the Primary connection string under Access Keys.
Step 3: Create an Azure Function: This will be an HTTP-triggered function. For detailed steps and code for the Azure function, please see the Reference link below this post.
Step 4: Update the Stream Analytics job with the Azure Function as output: In this step, we are just adding Azure Functions as the sink for the Stream Analytics job that we created in Step 1.
The Azure Steam Analytics job should be sending data to the Redis Cache using the Azure Function that we created in Step3.
The HTTP request timeout is set to 100 seconds. This means that if the Azure Function takes more than 100 seconds to process a batch, the Stream Analytics job will error out. But in case this occurs, Azure Stream Analytics is going to retry sending the failed batch to the Azure Function again.