Getting started with Azure Functions
Azure Functions is serverless computing offer by Microsoft. Functions by Microsoft implementation are scripts that can be written in JavaScript, C#, F#, Python, PHP, Bash, Batch or PowerShell. Functions can be developed on Visual Studio using preview level tools or directly through browser in Azure portal. This blog post introduces Azure Functions and shows how to build your first function.
Functions are run by trigger events. When run functions may accept input parameters and they can also return output to some supported service. By example, we may have timer triggered function that accepts Azure Table as an input and and Azure Notification Hub as output. The function processes latest records in Azure Table Storage and generates notifications for users.
The following table lists triggers, inputs and outputs that Azure Functions currently supports.
Triggers | Inputs | Outputs |
---|---|---|
Blob Event hub External file External table Generic web hook GitHub commenter GitHub web hook Http request Manual trigger Queue trigger Service Bus queue trigger Service Bus topic trigger Timer trigger | Azure Blob Storage External File External Table Azure Table Storage Azure DocumentDB Document Azure Mobile Table Record Bot Framework | Azure Event Hub Azure Queue Storage Azure Blob Storage External File External Table HTTP Azure Service Bus Azure Table Storage Azure DocumentDB document Azure Mobile Table Record Azure Notification Hub SendGrid Twilio SMS Bot Framework |
Building your first Azure Function
Log in to your Azure account and create new function from left menu and choose TimerTrigger-CSharp as function type. Give function a name and leave interval as it is.
New function is created and opened in function editor.
Although the editor runs in browser it has syntax highlight. If function is not developed online and tooling doesn’t support publishing to Azure then user can upload function files to server in editor window. Also keys needed to call function are available here.
Default timer trigger function is primitive. It just writes out to console when it was executed. Let’s click button Run and see the output. Output is written to log window below function editor.
Congrats! You just ran successfully your first Azure Function!
Visual Studio Tools for Azure Functions
Azure Functions can also be built on Visual Studio. There is preview of Visual Studio Tools for Azure Functions available. There are some problems and limitations as described in .NET Web Development and Tools Blog but still it is possible to develop functions in familiar environment.
Visual Studio tools come with Azure Functions emulator that we can use to run and debug functions on local box. To find out more I agan refer .NET Web Development and Tools Blog as they have described tools in deep depth.
I will come back to tooling with next posts that show what and how we can build on Azure Functions.
Wrapping up
Azure Functions is serverless computing service by MIcrosoft. Functions are simple scripts by their nature and they can be built in Azure portal or in Visual Studio. Visual Studio has preview level tools for functions that we can use to build and debug functions on our development boxes. Azure portal lets us monitor our functions and see if they have any health issues or problems. It was easy to build our first function using browser and online function editor. We can consider Azure Functions as our choice for serverless as it seems to work well.
Pingback:Introducing static website hosting for Azure Storage | Gunnar Peipman - Programming Blog