Azure / azure-functions-core-tools

Command line tools for Azure Functions
MIT License
1.33k stars 437 forks source link

Command `func templates list` returns invalid templates #2955

Open alfechner opened 2 years ago

alfechner commented 2 years ago

The templates returned from func templates list are not valid as input for func new's --template parameter.

func templates list --language dotnet returns (amongst others) the template 'Azure Service Bus Topic trigger'.

Using the output in func new --template 'Azure Service Bus Topic trigger' will result in an error Unknown template 'AzureServiceBusTopictrigger' (Parameter 'templateName').

Instead Service Bus Topic trigger needs to be used.

Version 4.0.3971

alfechner commented 2 years ago

Seems like the once for python functions work as expected.

Jawz84 commented 2 years ago

The same problem occurs for the Durable functions Orchestrator template:

~\GitNoOneDrive\test> func templates list --language c# | sls orchestrator

  Durable Functions orchestrator

~\GitNoOneDrive\test> func new --template 'Durable Functions orchestrator' --name foo --language c# --worker-runtime dotnet
Use the up/down arrow keys to select a template:Function name: foo
Unknown template 'DurableFunctionsorchestrator' (Parameter 'templateName')

The correct template name turned out to be 'DurableFunctionsorchestration'.

antoninod commented 2 years ago

Still having this problem with Function Runtime Version: 4.11.2.19273

I found the correct template name at : https://github.com/Azure/azure-functions-core-tools/blob/bb8c53ef90183580c4c4853044e1cfe937dc8553/src/Azure.Functions.Cli/Helpers/DotnetHelpers.cs#L124

m-ali-zafar commented 2 years ago

Issue exists Core Tools Version: 4.0.4829 Commit hash: N/A (64-bit) Function Runtime Version: 4.11.2.19273

image

mcollier commented 1 year ago

The list of templates returned by func templates list --language C# does not match the template list shown after executing func new --language C#. Why would these lists be different?

> func new --language C#
Select a number for template:
1. QueueTrigger
2. HttpTrigger
3. BlobTrigger
4. TimerTrigger
5. KafkaTrigger
6. KafkaOutput
7. DurableFunctionsOrchestration
8. SendGrid
9. EventHubTrigger
10. ServiceBusQueueTrigger
11. ServiceBusTopicTrigger
12. EventGridTrigger
13. CosmosDBTrigger
14. IotHubTrigger
Choose option: 
> func templates list --language C#
C# Templates:
  Azure Blob Storage trigger
  Azure Cosmos DB trigger
  Durable Functions activity
  Durable Functions HTTP starter
  Durable Functions orchestrator
  Azure Event Grid trigger
  Azure Event Hub trigger
  HTTP trigger
  IoT Hub (Event Hub)
  Azure Queue Storage trigger
  RabbitMQ trigger
  SendGrid
  Azure Service Bus Queue trigger
  Azure Service Bus Topic trigger
  SignalR negotiate HTTP trigger
  Timer trigger
erjosito commented 11 months ago

Great stuff @mcollier you saved my day.

AntonKomir commented 3 months ago

The same problem with Azure Service Bus Queue trigger, which is presented in "func templates list"

Result

func init FunctionApp --worker-runtime dotnet-isolated

Writing D:\FunctionApp.vscode\extensions.json

func new --template "Azure Service Bus Queue trigger" --name FunctionApp Template: Azure Service Bus Queue trigger Function name: FunctionApp

Creating dotnet function... Unknown template 'AzureServiceBusQueuetrigger' (Parameter 'templateName')

AntonKomir commented 3 months ago

@mcollier Thanks, your tip saved a lot of time.

daveferrara1 commented 3 months ago

Posting along for someone else new to Azure functions like me. I was able to pass the C# value posted from the list above by @mcollier .

The tutorial command doesn't work like reported above. Microsoft tutorial: : https://learn.microsoft.com/en-us/azure/azure-functions/functions-run-local?tabs=macos%2Cisolated-process%2Cnode-v4%2Cpython-v2%2Chttp-trigger%2Ccontainer-apps&pivots=programming-language-csharp

That tutorial provides func new --template "Azure Queue Storage Trigger" --name MyQueueTrigger but that doesn't work. Using: func new --template QueueTrigger does.