未加星标

dotnet new templates for serverless functions

字体大小 | |
[系统(windows) 所属分类 系统(windows) | 发布者 店小二05 | 时间 2018 | 作者 红领巾 ] 0人收藏点击收藏

Since .NET Core was announced, I've really been loving the command line experience for .NET Core. Being able to use dotnet new to start a new application regardless of the OS or what shell/terminal experience is on a machine is the way to happiness.

The Azure Functions team has put together some fancy new templates for creating serverless apps now.

Getting the new templates installed

.NET Core templates are all just NuGet packages and installed using dotnet new -i <package-path> . In this case, the templates are on a private feed, so you need to get them nupkg files from https://functionscdn.azureedge.net/public/cli-feed-v3.json .

The latest current version right now is from the feed:

"2.3.3": { "Microsoft.NET.Sdk.Functions": "1.0.14", "cli": "https://functionscdn.azureedge.net/public/2.0.1-beta.34/Azure.Functions.Cli.win-x86.2.0.1-beta.34.zip", "nodeVersion": "8.11.1", "localEntryPoint": "func.exe", "itemTemplates": "https://www.myget.org/F/azure-appservice/api/v2/package/Azure.Functions.Templates/2.0.0-beta-10224", "projectTemplates": "https://www.myget.org/F/azure-appservice/api/v2/package/Microsoft.AzureFunctions.ProjectTemplates/2.0.0-beta-10224", "templateApiZip": "https://functionscdn.azureedge.net/public/TemplatesApi/2.0.0-beta-10224.zip", "sha2": "4A2B808E86AE4C4DEF38A2A14270D19EC384648AD1FDF635921A64F609D41098", "FUNCTIONS_EXTENSION_VERSION": "beta", "requiredRuntime": ".NET Core", "minimumRuntimeVersion": "2.1"

Download the projectTemplates and itemTemplates nupkg files and install them using the command:

dotnet new -i ~/Downloads/Azure.Functions.Templates.2.0.0-beta-10224.nupkg" dotnet new -i ~/Downloads/Microsoft.AzureFunctions.ProjectTemplates.2.0.0-beta-10224.nupkg"

Now when dotnet new is run, the Azure Function templates are available.

Templates Short Name Language Tags ------------------------------------------------------------------------------------------------------------------------------- QueueTrigger Queue [C#] Azure Function HttpTrigger Http [C#] Azure Function BlobTrigger Blob [C#] Azure Function TimerTrigger Timer [C#] Azure Function DurableFunctionsOrchestration DurableFunctionsOrchestration [C#] Azure Function SendGrid SendGrid [C#] Azure Function EventHubTrigger EventHub [C#] Azure Function ServiceBusQueueTrigger SBQueue [C#] Azure Function ServiceBusTopicTrigger SBTopic [C#] Azure Function EventGridTrigger EventGrid [C#] Azure Function Azure Functions azureFunctionsProjectTemplates [C#] AzureFunctions/ClassLib Creating a quick function app # initial a new Azure Function application dotnet new azurefunction --output myfunctionapp # change dir cd myfunctionapp # add a new HttpTrigger Function dotnet new http --name echo # directory . ├── echo.cs ├── host.json ├── local.settings.json └── myfunctionapp.csproj

Now that I have initialized my app and first function, I could start the app using the functions cli with func host start but I want to be able to be able to debug the app, and deploy. I can open the project using VS Code using code . or in my case I use the Insiders Build code-insiders .

I have the Azure Extension Pack for VS Code installed which includes the Azure Functions extension which allows you quickly browse, create, manage, deploy, and even debug functions locally .

I am prompted with a notification that this is an Azure Function created outside of VS Code, and it is asking to add the assets for setting up debugging. Click Yes.


dotnet new templates for serverless functions

Now I can hit F5, add break points, and inspect my code just as I would expect from a great tooling experience but also have the ability to add new functions. Using the integrated terminal in VS Code you can see that the endpoint http://localhost:7071/api/echo is available.


dotnet new templates for serverless functions

If we wanted to add an additional HttpTrigger, use the following command:

# using -n as the short form for --name and -na short for namespace dotnet new http -n echo2 -na myfunctionapp

Or if you prefer a UI experience in VS Code, there is the Functions Extension for adding a new one as well.


dotnet new templates for serverless functions
Click on the "Add new function" Select the folder you want to work in Select the type of function Type the name of the function Type the name of the namespace ... potentially other options.

Both options are great depending on how you like to work. The templates are in line with how I work for all .NET Core applications now and I spend much of my time using command line tools like Docker, Kubernetes and the Azure CLI.

The Azure Functions are open source at https://github.com/Azure/azure-functions-templates please provide feedback. Azure Function development, debugging and deployment in Visual Studio is available as well.

本文系统(windows)相关术语:三级网络技术 计算机三级网络技术 网络技术基础 计算机网络技术

tags: Azure,new,Function,C#,Functions,beta,templates,dotnet,using
分页:12
转载请注明
本文标题:dotnet new templates for serverless functions
本站链接:https://www.codesec.net/view/586964.html


1.凡CodeSecTeam转载的文章,均出自其它媒体或其他官网介绍,目的在于传递更多的信息,并不代表本站赞同其观点和其真实性负责;
2.转载的文章仅代表原创作者观点,与本站无关。其原创性以及文中陈述文字和内容未经本站证实,本站对该文以及其中全部或者部分内容、文字的真实性、完整性、及时性,不作出任何保证或承若;
3.如本站转载稿涉及版权等问题,请作者及时联系本站,我们会及时处理。
登录后可拥有收藏文章、关注作者等权限...
技术大类 技术大类 | 系统(windows) | 评论(0) | 阅读(105)