{"id":22106,"date":"2017-05-10T13:12:57","date_gmt":"2017-05-10T20:12:57","guid":{"rendered":"https:\/\/devblogs.microsoft.com\/aspnet\/?p=22106"},"modified":"2017-05-10T13:12:57","modified_gmt":"2017-05-10T20:12:57","slug":"visual-studio-2017-tools-for-azure-functions","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/dotnet\/visual-studio-2017-tools-for-azure-functions\/","title":{"rendered":"Visual Studio 2017 Tools for Azure Functions"},"content":{"rendered":"<p>Visual Studio 2017 Tools for Azure Functions are now available as part of the Azure development workload starting in the <a href=\"https:\/\/blogs.msdn.microsoft.com\/visualstudio\/2017\/08\/14\/visual-studio-2017-version-15-3-released\/\">Visual Studio 2017 15.3 release<\/a>. These tools:<\/p>\n<ul>\n<li>Enable creating pre-compiled C# functions that bring better cold start performance than script based functions, and opens the entire eco-system of Visual Studio tools for class libraries including code analysis, unit testing, complete IntelliSense, 3<sup>rd<\/sup> party extensions, etc.<\/li>\n<li>Uses <a href=\"https:\/\/docs.microsoft.com\/en-us\/azure\/app-service-web\/websites-dotnet-webjobs-sdk-get-started\">WebJobs attributes<\/a> to declare function bindings directly in the C# code rather than the separate function.json file.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/05\/clip_image00215.jpg\"><img decoding=\"async\" width=\"940\" height=\"88\" title=\"clip_image002\" style=\"border: 0px currentcolor;padding-top: 0px;padding-right: 0px;padding-left: 0px\" alt=\"clip_image002\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/05\/clip_image002_thumb13.jpg\" border=\"0\" \/><\/a><\/p>\n<h2>Getting Started<\/h2>\n<p>To get started:<\/p>\n<ul>\n<li style=\"list-style-type: none\">\n<ul><!--StartFragment--><\/ul>\n<\/li>\n<li>Install <a href=\"https:\/\/blogs.msdn.microsoft.com\/visualstudio\/2017\/08\/14\/visual-studio-2017-version-15-3-released\/\">Visual Studio 2017 15.3<\/a> (or later)\n<ul><\/ul>\n<\/li>\n<li>Install the \u201cAzure development\u201d workload\n<ul><!--EndFragment--><\/ul>\n<\/li>\n<\/ul>\n<p>To create a new project, choose <b>File -&gt; New Project<\/b>, and the <b>Azure Functions<\/b> project type<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/08\/image260.png\"><img decoding=\"async\" width=\"1414\" height=\"982\" title=\"image\" alt=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/08\/image_thumb200.png\" border=\"0\" \/><\/a><\/p>\n<p>This will create an empty project which contains the following files:<\/p>\n<ul>\n<li><b>host.json <\/b><a href=\"https:\/\/github.com\/Azure\/azure-webjobs-sdk-script\/wiki\/host.json\">enables configuring the function host<\/a><b><\/b><\/li>\n<li><b>local.settings.json <\/b>which stores setting information such as connection strings used for running the function on the development machine. <i>Note: For all trigger types except HTTP, you need to set the value of AzureWebJobsStorage to a valid Azure Storage account connection string.<\/i><b><\/b><\/li>\n<\/ul>\n<p>To add a function to the application right click the project and choose \u201cAdd Item\u201d, then choose the \u201cAzure Function\u201d item template. This will launch the Azure Function dialog that enables you to choose the type of function you want, and enter any relevant binding information. For example, in the dialog below, the queue trigger asks you for the name of the connection string to the storage queue, and the name of the queue (path).<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/08\/image261.png\"><img decoding=\"async\" width=\"1206\" height=\"784\" title=\"image\" alt=\"image\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/08\/image_thumb201.png\" border=\"0\" \/><\/a><\/p>\n<p>This generates a new class that has the following elements:<\/p>\n<ul>\n<li>A static Run method, that is attributed with [FunctionName] attribute. The [FunctionName] attribute indicates that the method is the entry for an Azure Function.<\/li>\n<li>The first parameter has a QueueTrigger attribute, this is what indicates is a queue trigger function (and takes the binding information as parameters to the attribute. In this case the name of the queue and the connection string\u2019s setting name)<\/li>\n<\/ul>\n<p>Once you have a function, local development works like you would expect. You can run and debug it locally, add NuGet packages, create unit tests, and anything else you would do for a class library.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/05\/clip_image0086.jpg\"><img decoding=\"async\" width=\"941\" height=\"167\" title=\"clip_image008\" style=\"border: 0px currentcolor;padding-top: 0px;padding-right: 0px;padding-left: 0px\" alt=\"clip_image008\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/05\/clip_image008_thumb6.jpg\" border=\"0\" \/><\/a><\/p>\n<p>To publish a Function project to Azure directly from Visual Studio, right click the project and choose \u201cPublish\u201d. On the publish page, you can either create a new Function App in Azure or publish to an existing one. Note: even though the Folder option is currently appears, it&#8217;s not intended for use with Azure Functions at this time.<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/05\/clip_image0102.jpg\"><img decoding=\"async\" width=\"688\" height=\"382\" title=\"clip_image010\" style=\"border: 0px currentcolor;padding-top: 0px;padding-right: 0px;padding-left: 0px\" alt=\"clip_image010\" src=\"https:\/\/msdnshared.blob.core.windows.net\/media\/2017\/05\/clip_image010_thumb2.jpg\" border=\"0\" \/><\/a><\/p>\n<p>It&#8217;s also <a href=\"https:\/\/blogs.msdn.microsoft.com\/appserviceteam\/2017\/06\/01\/deploying-visual-studio-2017-function-projects-with-vsts\/\">possible to configure continuous delivery using Visual Studio Team Services<\/a>.<\/p>\n<h2>Question and Answer<\/h2>\n<p><strong>I installed Visual Studio 2017 15.3 and the Azure development workload, but I don\u2019t see the Azure Functions project type or am receiving an error trying to build or run a function app:  <\/strong>While pulled in automatically by the Azure development workload, Azure Function tools are distributed via the Visual Studio gallery which gives us the flexibility to update them as needed to react to changes on the Azure side which don\u2019t always happen on the Visual Studio schedule.  If for some reason the tools don\u2019t get automatically updated from the gallery, in Visual Studio, go to Tools | Extensions and Updates, and look at the \u201cUpdates\u201d tab.  If it shows an update is available for \u201cAzure Functions and Web Job Tools&#8221; manually update them by clicking the &#8220;Update&#8221; button.<\/p>\n<p><b>How can I file issues or provide feedback on these tools? <\/b>You can file issues or provide feedback on the <a href=\"https:\/\/github.com\/Azure\/Azure-Functions\/labels\/Visual%20Studio\">Azure Functions GitHub repo<\/a> by prefixing them with<i> [Visual Studio]<\/i><\/p>\n<p><b>Are these targeting .NET Standard 2.0 as outlined in the <\/b><a href=\"https:\/\/blogs.msdn.microsoft.com\/webdev\/2017\/04\/14\/azure-functions-tools-roadmap\/\"><b>roadmap post<\/b><\/a><b>?<\/b> At this time the Functions Runtime does not yet support .NET Standard libraries.  So these are .NET Standard class library projects, but the build target is set to .NET 4.6.1.  In the future, when the Functions runtime support .NET Standard you will simply need to change the target framework.<\/p>\n<p><b>I have existing functions written as .csx scripts, how do I port those to the new precompiled project type? <\/b>To convert a .csx file into a new function you will need to move the Run method into a class, remove #load, and replace #r with assembly or project to project references (<a href=\"https:\/\/aka.ms\/precompiled-functions\">see complete steps<\/a>).<\/p>\n<p><b>What about support for F# functions?<\/b> It will be possible to create Azure Functions in Visual Studio using F# in a future update, but support is not included in this release.<\/p>\n<p><b>What is the plan for the Visual Studio 2015 tools? <\/b>The Visual Studio 2015 tooling was an initial preview that got us a lot of great feedback and we learned a lot from them. Given our pivot to pre-compiled functions with the intent to focus on .NET Standard 2.0, we have dependencies that only exist in Visual Studio 2017 Update 3 and beyond, so there are no plans to release any future updates for Visual Studio 2015. Once the Functions runtime supports .NET Core, it will be possible to work with Azure Functions in Visual Studio Code as well as Visual Studio 2017 if you prefer or are unable to upgrade to Visual Studio 2017.<b><\/b><\/p>\n<h2>Conclusion<\/h2>\n<p>We\u2019re very happy to be releasing our first version of support tools for Azure Function development in Visual Studio, so please let us know how they work for you. You can do that below, in the <a href=\"https:\/\/github.com\/Azure\/Azure-Functions\/labels\/Visual%20Studio\">Azure Functions GitHub repo<\/a>, or via twitter at <a href=\"https:\/\/twitter.com\/AndrewBrianHall\">@AndrewBrianHall<\/a> and <a href=\"https:\/\/twitter.com\/AzureFunctions\">@AzureFunctions<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Visual Studio 2017 Tools for Azure Functions are now available as part of the Azure development workload starting in the Visual Studio 2017 15.3 release. These tools: Enable creating pre-compiled C# functions that bring better cold start performance than script based functions, and opens the entire eco-system of Visual Studio tools for class libraries including [&hellip;]<\/p>\n","protected":false},"author":404,"featured_media":58792,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[197],"tags":[],"class_list":["post-22106","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-aspnet"],"acf":[],"blog_post_summary":"<p>Visual Studio 2017 Tools for Azure Functions are now available as part of the Azure development workload starting in the Visual Studio 2017 15.3 release. These tools: Enable creating pre-compiled C# functions that bring better cold start performance than script based functions, and opens the entire eco-system of Visual Studio tools for class libraries including [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/22106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/users\/404"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/comments?post=22106"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/posts\/22106\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media\/58792"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/media?parent=22106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/categories?post=22106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/dotnet\/wp-json\/wp\/v2\/tags?post=22106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}