A few weeks ago Azure Functions where released during Build 2016. This really wasn’t announced as a big thing. But if you start looking at what you can do with Azure Functions it really is something awesome.
Occurring to Microsoft Azure Functions is the following:
“Azure functions is a solution for easily running small pieces of code, or “functions,” in the cloud. You can write just the code you need for the problem at hand, without worrying about a whole application or the infrastructure to run it. This can make development even more productive, and you can get started with your first function in just minutes.”
For now Azure Functions is hosted in three locations:
- West Europe
- Southeast Asia
- West US
Managing and creating Azure Functions can be done from two locations:
The Functions application is completely build upon Azure App Services which means you can use all functions that Azure App Services provide as: Deployment Slots, Web Configuration, Hybrid Connections and Continuous Integration.
Some other key features are:
- Choice of language – Write functions using C#, Node.js, Python, F#, PHP, batch, bash, Java, or any executable.
- Pay-per-use pricing model – Pay only for the time spent running your code. See the Dynamic App Service Plan option in the pricing section below.
- Bring your own dependencies – Functions supports NuGet and NPM, so you can use your favorite libraries.
- Integrated security – Protect HTTP-triggered functions with OAuth providers such as Azure Active Directory, Facebook, Google, Twitter, and Microsoft Account.
- Code-less integration – Easily leverage Azure services and software-as-a-service (SaaS) offerings. See the integrations section below for some examples.
- Flexible development – Modify your functions with an in-portal editor, or set up continuous integration and deploy your code through GitHub, Visual Studio Team Services, and more.
- Open-source – Functions is open-source and available on GitHub.
The Azure Functions team is working on the supported languages but for know these are the supported languages:
1st class support
By default Azure Functions contains a lot of Triggers, Inputs and Outputs you can use to process information. The below table gives you an idea of what can be used in what kind of situation.
|HTTP (REST or webhook)||Azure Functions||✔||✔*|
|Blob Storage||Azure Storage||✔||✔||✔|
|Tables||Mobile Apps Easy Tables||✔||✔|
|No-SQL DB||Azure DocumentDB||✔||✔|
|Push Notifications||Azure Notification Hubs||✔|
What you maybe are wondering is, can I use NuGet packages or maybe custom assemblies? Yes you can! NuGet packages can be added by adjusting the project.json file and uploading it trough the KUDU UI or FTP. Besides that you can also reference your own assemblies. If you need to reference a private assembly, you can upload the assembly file into a bin folder relative to your function and reference it by using the file name.
More information on working with “External Assemblies” can be found here:
On of the things I found when working with Azure Functions that get triggered by a scheduler you will have to use Cron Expressions:
Cron expressions is another kind of time expression that Azure Functions uses. In time a UI will be created to set the scheduler but for know you will have to use this format:
Run every 5 seconds: 0/5 * * * * *
The best thing of Azure Functions is that you do not have to implement logic for getting and saving the information. You only have to implement the logic for the actions you want to perform. If you for example want to resize images you can build a Azure Function that is triggered by Azure Blob Storage, and outputs the resized images to Azure Blob Storage. The implementation you need to make is only the logic for resizing the images.
Besides all these great features it can also use Dynamic Compute what means it will use up no resources when it isn’t triggered or running and it will scale up when the functions needs to.