Install and use Azure Function Tools for Visual Studio 2017 [Video]

Yesterday, at the Microsoft Build 2017 conference, Microsoft announced the preview release of Azure Functions Tools for Visual Studio (AZFT). These tools allow you to create Functions in Visual Studio and then publish them to your Azure site.  In this video, I show you how to install everything you need to get started, and I walk you through using your first Azure Function.

[tg_youtube video_id=”bv1x4QR6FX8″]

What is an Azure Function?

Azure Functions are microservices that are a core component of serverless computing. Please read some of the great articles we already have on the site, like this one.

What do I need?

To use AZFT, you will need the following products:

  1. Visual Studio 2017 Preview 3. Now before you start thinking the way I did, Preview does not mean pre-release. Visual Studio Preview is akin to the Windows Insider program where you can get early builds of Visual Studio before they are complete.
  2. The Azure .NET 2.9.6 SDK.
  3. Visual Studio Tools for Azure Functions.

Note: Later, when you run the function for the first time, you may receive a prompt asking you to install the Azure Functions CLI. Even if you already installed the CLI in Bash or Node, you might still need to follow the instructions to install the Windows version.

Before you install

Since you are installing a preview version of Visual Studio, I do not recommend you install to a production environment. That said, Microsoft does say you can install the preview version right alongside your production version of Visual Studio 2017. Further to that, Microsoft states it will not do a full install when certain products are already on your computer.

In my case, I do have Visual Studio 2017 on my computer, but I also use a virtual machine. Good thing I thought ahead and created a snapshot ahead of time because the installation process crashed three times before I got it working.

I do not know if this is important or not, but I do recommend you install all Visual Studio 2017 updates first, and then restart your computer. Microsoft doesn’t say you have to do this, but personally, I think it is a good idea.

Install and run Visual Studio 2017 Preview 3 (VSP3)

After you download VSP3 using the link in the What do I need section of this article, and run it. When you get to the Workloads screen, you must pick at least one of the two following workloads:

  • ASP.NET and web development and/or…
  • Azure development

Warning: From my tests, you can install pretty much any other workload but do not install Data Storage & Processing as it may crash at the end and will not uninstall.

After you install VSP3, run it and wait while it configures for the first time.

Note: If you cannot find VSP3 in the Start menu (like me), click the Start menu and then type the word Preview or Visual Studio Preview and you should find it that way.

Install the Visual Studio Tools for Azure (VSTA)

Before you install VSTA, I suggest you exit all programs, including Visual Studio. Download the link from the What do I need section of this article and run it. There are no special steps to make, so just work your way through the installation process.

Create your first Azure Function in VSP3

The video that accompanies this article provides more detail, so these are just the basic steps you follow to create a new Function(s):

  1. Run VSP3 and create a new project. You can search for the word Function to find the Azure Functions project. Select that and create the project.
  2. The project does not contain any functions, so you need to add them. Right-click on the project and add a new item. Once again, search for the word Function, and you should find the Azure Function item. Select that to create a new Function.
  3. A dialog appears asking you what will trigger the function. Choose the Http Trigger option and create the final function.
    • Note: Your new function contains a small hello world style example where you will pass it a name, and it will respond with Hello {name}.
  4. Run your project. If you do not have the Azure Functions CLI installed, you will be prompted to do so. Follow the steps, and then your project will run.
    • Note: If your project fails to run and the Azure Functions CLI installed, then you might need to restart your computer first.
  5. The Azure CLI runs, and you will see a web server is running with a URL that looks something like this:
    • http://localhost:7001/myfunction
  6. To test the function, copy the URL from the Azure Functions CLI and paste it into a browser with the following query string:
    • http://localhost:7001/myfunction?name=Bill
  7. Using the above example, the browser should return with Hello Bill. Depending on your browser, you may just see the text or some additional XML surrounding the text.
  8. Stop the project by exiting the Azure Functions CLI.
  9. To see how to use more than one function, follow steps 2-4. This time, the Azure Functions CLI runs, and you will see two unique URLs to access. Feel free to test both of them as you did in steps 5-6.

So there you have it! You can now create Azure Functions using Visual Studio and C#. This is still in preview and Microsoft does not support use in a production environment. You can also test publishing the Azure Function to the Microsoft Azure cloud, but that is a subject for another article.

Please remember this article is published the day after Microsoft released Visual Studio Tools for Azure Functions, so there is a possibility things will change. Therefore, please watch this link to make sure you stay up to date:

https://blogs.msdn.microsoft.com/webdev/2017/05/10/azure-function-tools-for-visual-studio-2017/

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top