Azure Functions allow developers to write serverless applications, meaning that developers or operations do not have to worry about the infrastructure on which the application executes. In many scenarios, application or business needs require a small piece of logic to be reused by other services for some small task to be performed based on an event such as sending a notification to user when a message is sent to a queue.
Such tasks were previously handled by WebJobs or scripts, which are difficult to reuse and connect in a flow of logic. Azure Functions give developers the ability to wrap the logic in a Nanoservice that can connect and communicate with other services to carry out the logic flow.
Azure Functions is part of web and mobile suite of services in Azure. In addition to Visual Studio tooling, you can design and manage Azure Functions from a dedicated portal at: https://functions.azure.com.
Currently you can create functions in JavaScript, C#, Python, and PHP as well as with scripting languages such as Bash, Batch, and PowerShell. The functions can be triggered by virtually any event in an on cloud or on-premise system or a third-party service.
Let's head over to https://functions.azure.com to explore Azure Functions in greater detail:
In the function area, you will notice that you can select a subscription where you want to create your function and assign a Name and Region to your function. Assign a name to your function and click the Create + get started button.
Once your function gets provisioned, you will be redirected to the Management Portal, on which you will be able to compose and manage your function:
To add a function to your application, click on the + sign next to the Functions menu to bring up the quick start panel:
Select the Timer scenario, which will configure your function to get executed based on a configurable schedule. Set the language preference to compose the function as C# and click on Create this function button.
The previous steps will create a function that write a message to log every five minutes. You can view the log output in the window below the editor console:
Let's change the logging frequency of this function, so that we can see more messages in the console. Click on the Integrate option under the Functions menu:
In the integration pane, change the Schedule CRON expression to six stars (* * * * * *), which means that function will execute every second, and click on Save.
Once the settings are saved, go back to the editor view where you will now find that new messages are logged every second. Click on Manage menu item and click on the Delete button to delete the function.