Visual Studio Tools for Azure Functions

WebDev Tools

November 1st, 2016

Update 5-10-2017: The first release of Visual Studio 2017 Tools for Azure Functions is now available to try. As discussed in the Visual Studio 2017 Toolspost and these 2015 tools were preview tools that provided us great feedback and learning. However, as outlined in our roadmap post, the pivot to precompiled functions with a focus on .NET Standard 2.0 means we have no plans to release any further updates to 2015 at this time. We would encourage everyone to try out the new tools for Visual Studio 2017.

Today we are pleased to announce a preview of tools for building Azure Functions for Visual Studio 2015. Azure Functions provide event-based serverless computing that make it easy to develop and scale your application, paying only for the resources your code consumes during execution. This preview offers the ability to create a function project in Visual Studio, add functions using any supported language, run them locally, and publish them to Azure. Additionally, C# functions support both local and remote debugging.

In this post, I’ll walk you through using the tools by creating a C# function, covering some important concepts along the way. Then, once we’ve seen the tools in action I’ll cover some known limitations we currently have.

Also, please take a minute and let us know who you are so we can follow up and see how the tools are working.

Getting Started

Before we dive in, there are a few things to note:

These tools are offered as a preview release and will have some rough spots and limitations

They currently only work with Visual Studio 2015 Update 3 with “Microsoft Web Developer Tools” installed

You must have Azure 2.9.6 .NET SDK installed

Download and install Visual Studio Tools for Azure Functions

For our sample function, we’ll create a C# function that is triggered when a message is published into a storage Queue, reverses it, and stores both the original and reversed strings in Table storage.

Publishing to Azure

Now that we’ve tested the function locally, we’re ready to publish our function to Azure. To do this right click on the project and choose “Publish…”, then choose “Microsoft Azure App Service” as the publish target

Next, you can either pick an existing app, or create a new one. We’ll create a new one by clicking the “New…” button on the right side of the dialog

This will pop up the provisioning dialog that lets us choose or setup the Azure environment (we can customize the names or choose existing assets). These are: Function App Name: the name of the function app, this must be unique Subscription: the Azure subscription to use Resource Group: what resource group the to add the Function App to App Service Plan: What app service plan you want to run the function on. For complete information read about hosting plans, but it’s important to note that if you choose an existing App Service plan you will need to set the plan to “always on” or your functions won’t always trigger (Visual Studio automatically sets this if you create the plan from Visual Studio)

Now we’re ready to provision (create) all of the assets in Azure. Note: that the “Validate Connection” button does not work in this preview for Azure Functions

Once provisioning is complete, click “Publish” to publish the Function to Azure. We now have a publish profile which means all future publishes will skip the provisioning steps Note: If you publish to a Consumption plan, there is currently a bug where new triggers that you define (other than HTTP) will not be registered in Azure, which can cause your functions not to trigger correctly. To work around this, open your Function App in the Azure portal and click the “Refresh” button on the lower left to fix the trigger registration. This bug with publish will be fixed on the Azure side soon.

If you publish to a Consumption plan, there is currently a bug where new triggers that you define (other than HTTP) will not be registered in Azure, which can cause your functions not to trigger correctly. To work around this, open your Function App in the Azure portal and click the “Refresh” button on the lower left to fix the trigger registration. This bug with publish will be fixed on the Azure side soon. To verify our function is working correctly in Azure, we’ll click the “Logs” button on the function’s page, and then push a message into the Queue using Storage Explorer again. We should see a message that the function successfully processed the message

The last thing to note, is that it is possible to remote debug a C# function running in Azure from Visual Studio. To do this: Open Cloud Explorer Browse to the Function App Right click and choose “Attach Debugger”



Known Limitations

As previously mentioned, this is the first preview of these tools, and we have several known limitations with them. They are as follow:

IntelliSense: IntelliSense support is limited, and available only for C#, and JavaScript by default. F#, Python, and PowerShell support is available if you have installed those optional components. It is also important to note that C# and F# IntelliSense is limited at this point to classes and methods defined in the same .csx/.fsx file and a few system namespaces.

IntelliSense support is limited, and available only for C#, and JavaScript by default. F#, Python, and PowerShell support is available if you have installed those optional components. It is also important to note that C# and F# IntelliSense is limited at this point to classes and methods defined in the same .csx/.fsx file and a few system namespaces. Cannot add new files using “Add New Item”: Adding new files to your function (e.g. .csx or .json files) is not available through “Add New Item”. The workaround is to add them using file explorer, the Add New File extension, or another tool such as Visual Studio Code.

Adding new files to your function (e.g. .csx or .json files) is not available through “Add New Item”. The workaround is to add them using file explorer, the Add New File extension, or another tool such as Visual Studio Code. Function bindings generate incorrectly when creating a C# Image Resize function: The settings for the binding “Azure Storage Blob out (imageSmall)” are overridden by the settings for the binding “Azure Storage Blob out (imageMedium)” in the generated function.json. The workaround is to go to the generated function.json and manually edit the “imageSmall” binding.

The settings for the binding “Azure Storage Blob out (imageSmall)” are overridden by the settings for the binding “Azure Storage Blob out (imageMedium)” in the generated function.json. The workaround is to go to the generated function.json and manually edit the “imageSmall” binding. Local deployment and web deploy packages are not supported: Currently, only Web Deploy to App Service is supported. If you try to use Local Deploy or a Web Deploy Package, you’ll see the error “GatherAllFilesToPublish does not exist in the project”.

Currently, only Web Deploy to App Service is supported. If you try to use Local Deploy or a Web Deploy Package, you’ll see the error “GatherAllFilesToPublish does not exist in the project”. The Publish Preview shows all files in the project’s folder even if they are not part of the project: Publish preview does not function correctly, and will cause all files in the project folder to be picked up and and published. Avoid using the Preview view.

Publish preview does not function correctly, and will cause all files in the project folder to be picked up and and published. Avoid using the Preview view. The publish option “Remove additional files at destination” does not work correctly: The workaround is to remove these files manually by going to the Azure Functions Portal, Function App Settings -> App Service Editor

Conclusion

Please download and try out this preview of Visual Studio Tools for Azure Functions and let us know who you are so we can follow up and see how they are working. Additionally, please report any issues you encounter on our GitHub repo (include “Visual Studio” in the issue title) and provide any comments or questions you have below, or via Twitter.