In this blog post we will discuss an Azure Service called Azure Functions. This service has recently (15th of November) gone GA (General Available) and provides a capability of running small pieces of code in Azure. With functions, you do not have to deal that much with infrastructure, it’s the responsibility of Azure or an application (see Azure Functions Overview). The functionality you develop in a browser i.e. in the Azure Portal (Function App or https://functions.azure.com/), test it and done. The only aspects other than the code are scalability and pricing.
Basic Walkthrough of creating an Azure Function
In the Azure Portal, you can navigate/search for Function App. And click on Function App. Next, you’ll see a button Create and once you press that a pane will appear.
In this pane, you specify the name for the app, select a subscription, create or add to the existing resource group, choose a hosting plan, location and choose a storage account. Hit create and a quick start tab will appear once the app has been provisioned, where you can choose a scenario, a preferred language or create your own function. You can choose for the Webhook + API scenario with C# and click “Create this function”, which will create an HTTP triggered function. The first thing that will happen is that you will be taken through a tour guiding you through several tabs and options. The focus will be on the development tab once you complete the tour.
By choosing the scenario “Webhook + API” you instantly get access to sample code you can leverage. The code represents a HTTP request that takes a request and returns with a response either Hello plus or that you’ll have to provide a query string. You can run this straight away or call via Postman i.e. copy the Function URL and execute a GET.
By choosing the Integrate tab you can change the trigger, input and output bindings for your function. By clicking the document plus sign you’ll see information on the setting for HTTP and webhook bindings, including more sample code (see also Azure Functions HTTP and webhook bindings). In the next tab Manage you can enable/disable the function, and manage function keys, which are intended for security purposes (see also Working with Keys). In the Monitor tab, you observe your function runs.
The Function app settings tab below shows function app settings, that hook into the capabilities of the app service, where basically the function apps run.
In the Developmenttab, you can test your function by selecting test and configure how you like to test your function.
The development environment or feature of functions provides you with the necessary tools to build, test and deploy your function. You do not specifically need any other tools like Postman. However, the latter can be useful to see if your function is accessible from the outside. For testing a function see Testing Azure Functions.
The Azure function can be another solution building block in your toolbox. From a solution architecture perspective, you a few similar building blocks available such as WebJob, Flow, and Logic Apps. All capable of solving integration problems and/or automate business process. Fortunately there is guidance on what to choose: Choose between Flow, Logic Apps, Functions, and WebJobs.
Pricing is another aspect of any Azure Service you use. With functions, you can either opt for a consumption plan or regular pricing through App Service Plan, see Function Pricing. You can use the calculator to have a better indication of price.
Depending on your requirements i.e. predominantly at what scale you want to run your functions, see Scaling Azure Functions.
To build Azure Functions you can use a browser as it is a server less coding experience. However, you have the possibility of building a function using Visual Studio 2015. Note that this is still in preview.
In case you run into issues with Functions you have several options:
In this blog post we scratched the service of Azure Functions by providing a basic walk through of creating a function. The service has gone GA and extends the capabilities Microsoft Azure brings to its consumers. It’s a great addition to building Azure solutions.