In this post, we will see how to create a simple Azure Function in Azure Portal, that reads a message from an Azure Service Bus Queue.
First of all, what is an Azure Function?
From Microsoft web site:
“Azure Functions is a serverless solution that allows you to write less code, maintain less infrastructure, and save on costs. Instead of worrying about deploying and maintaining servers, the cloud infrastructure provides all the up-to-date resources needed to keep your applications running.”
We start creating a Service Bus called servicetestfunctions, where we will add a Queue called queuetestfunctions:
Now, we will create a Function App called readqueuetestfunctions and then, we will add a functions called simpleread used to read the queue created above and showing the message in the log:
Finally, we change the code generated by Azure, in order to print an information when the queue message will be equal to “Damiano”:
When we save it, the function will start to run:
In order to check our Function, we will send three messages from the queue and then, we will see the Function’s log:
If we check our queue, we will see that no messages are present:
THIS IS A VERY SIMPLE EXAMPLE OF HOW TO USE AN AZURE FUNCTION, BUT I JUST WANTED TO SHOW HOW EASY IS TO CREATE ONE USING THE AZURE PORTAL.