The serverless computing realm of cloud computing has been growing in interest and functionality lately. Recently, Azure Functions reached General Availability and an eagerly anticipated v1.0 release. Microsoft has not stopped there, in fact they just recently released a Preview of the new Visual Studio Tools for Azure Functions. These tools bring Azure Functions support into the Visual Studio IDE!
Visual Studio Tools for Azure Functions Preview
The new Visual Studio Tools for Azure Functions is currently in a Preview release state. As a result, the tools aren’t fully complete yet, and as with any Preview release it can be expected that things may / will change a bit before the final release. All preview releases can be expected to have some rough spots, bugs, and limitations. That being stated…
The requirements to install the Visual Studio Tools for Azure Functions are:
- You must be running Visual Studio 2015 Update 3 with the “Microsoft Web Developer Tools” extension installed.
- You must have Azure 2.9.6 .NET SDK installed.
Once you have the following prerequisites installed, you can go ahead to download and install the Visual Studio Tools for Azure Functions Preview.
Create New Azure Functions Project
Once the Visual Studio Tools for Azure Functions Preview is installed, you can easily create a new Azure Functions project within Visual Studio 2015 from the New Project dialog. It is located under the Cloud section under Visual C#.
Even though the Azure Function (Preview) project template is located underneath the Visual C# -> Cloud section, you are able to create / author Azure Functions in non-C# languages within the project after creation.
- Right-click on the Project within the Solution Explorer window.
- Click on Add, then New Azure Function…
- Within the New Azure Function dialog, select the Azure Function template in your choice language from the list.
The Azure Functions languages supported include:
Here’s a list of the different types of Azure Functions currently available within the Preview release. Remember, the options do vary depending on the programming language selected.
- Generic WebHook
- GitHub Commenter
- GitHub WebHook
- Http GET (CRUD)
- Http POST (CRUD)
- Http PUT (CRUD)
- Image Resizer
- SAS Token Generator
Once you choose the Azure Functions template to start from for a new Function, there are some Bindings fields that need to be filled in. These Bindings fields will vary depending on the Azure Functions template chosen to create a new Function from.
Azure Functions Project Files
At the root of the project are the appsettings.json and host.json files. These are files that can be used to describe some things for the projects, but at initial creation they are pretty much empty.
The appsettings.json file can be used to configure any necessary App Settings values that are needed by the Azure Functions within the project.
Then there is a folder created for each Function that gets created within the Azure Function. in this screenshot is an example of a new Azure Function that was created using the Manual Trigger C# template.
The functions.json file contains configuration data for the Function. This is the JSON file that is used to specify / configure the Function Bindings for Inputs and Outputs of the Function.
The project.json for a C# Azure Function is where any NuGet dependencies for the Function get defined. It’s useful to know that in addition to using the project.json file, Azure Functions to automatically have access to some standard namespace imports that just be referenced with a using keyword. There is also a shorthand syntax for adding references to external assemblies from within the C# script file.
Here’s a sample of a project.json file that adds a NuGet reference:
Azure Functions projects can be run on the local development machine. Currently, in the Visual Studio Tools for Azure Functions Preview release only supports remote debugging with C#, but that is expected to be expanded out in the future.
One prerequisite for running and debugging Azure Functions locally is that the Azure Functions CLI needs to be installed. The first time an Azure Functions project is run locally, it will prompt to download and install the Azure Functions CLI, so this is an easy requirement to manage / obtain.
Publishing to Azure
Azure Functions project can be published to Azure In the same manner as publishing Web Apps into an Azure Subscription. An Azure Web App is created within an Azure Subscription, then the credentials and other information for the Web App is configured within the Publish dialog for the project. Then the Azure Functions project can easily be published into Azure directly from within Visual Studio.
In line with other functionality of Azure Web Apps, the Azure Functions project can also be Debugged Remotely from the local development machine while running in Azure. Currently, this is only supported with C# based Azure Functions.
The Visual Studio Tools for Azure Functions Preview announcement post lists a few known limitations for this new Preview release. The are as follows:
- Adding New files is not available using “Add New Item”.
- There is currently a bug that causes Functions published from Visual Studio to be improperly registered in Azure.
- The C# Image Resizer function template incorrectly generates the function Bindings. These need to be manually edited to fix.
The Azure Functions team is eager to get feedback from anyone using the new Visual Studio Tools for Azure Functions Preview release. Any issues can be reported using the GitHub repository (please include “Visual Studio” in the issue title), plus additional comments and questions are welcome on their Twitter accounts as well.