Using the templates directly via dotnet new - Azure/azure-functions-templates GitHub Wiki
You can create Azure Functions projects and execute individual templates from the command line using dotnet new. Please note that this experience has not received much in the way of polish yet. These templates could use some cleanup from a metadata perspective (we need to make sure they use the right name, tag, etc).
-
Use the metadata feed to discover and download the appropriate packages. Grab the latest copy of the feed from: https://functionscdn.azureedge.net/public/cli-feed-v3.json
-
In the tags section, find the entry for
"v2"and look up the corresponding release. At time of writing its2.0.1-beta.25. -
Find that release in the releases section, and grab the links for
itemTemplatesandprojectTemplates. Take those links and use them to download the template .nupkg's. -
Install the templates using
dotnet new -i <packagepath>e.g.
dotnet new -i "D:\downloads\Microsoft.AzureFunctions.ProjectTemplates.2.0.0-beta-10177.nupkg"
dotnet new -i "D:\downloads\Azure.Functions.Templates.2.0.0-beta-10177.nupkg"
- If this worked, you should see a bunch of templates tagged with
Azure Functionwhen you rundotnew new:
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
- Create a new functions project:
dotnet new "Azure Functions"
- Add a function - lets use the HTTP trigger template:
dotnet new HttpTrigger -n Function1
- Compile:
dotnet build
- After package restore and build, the
bin\Debug\netstandard2.0directory will contain your compiled function app:
λ ls bin\Debug\netstandard2.0
Directory: D:\code\temp\dotnetnew\FunctionsCmdLineTest\bin\Debug\netstandard2.0
Mode LastWriteTime Length Name
---- ------------- ------ ----
d----- 4/9/2018 9:29 AM bin
d----- 4/9/2018 9:27 AM Function1
-a---- 4/9/2018 9:27 AM 77422 FunctionsCmdLineTest.deps.json
-a---- 4/9/2018 9:25 AM 4 host.json
-a---- 4/9/2018 9:25 AM 128 local.settings.json
- You can run the output via the commandline if you've installed the azure-functions-core-tools. Today you can do this using npm:
npm install azure-functions-core-tools@core -g
- Start the functions host using the output from the build process:
func start --script-root bin\Debug\netstandard2.0
- If done correctly, you should see at the bottom of the output:
[4/9/2018 4:37:27 PM] Job host started
Listening on http://localhost:7071/
Hit CTRL-C to exit...
Http Functions:
Function1: http://localhost:7071/api/Function1
- Invoke the function:
λ curl http://localhost:7071/api/Function1?name=paul
StatusCode : 200
StatusDescription : OK
Content : Hello, paul