Azure / azure-functions-host

The host/runtime that powers Azure Functions
https://functions.azure.com
MIT License
1.92k stars 440 forks source link

Azure Functions V4 (.NET 6.0) early preview - unable to create Functions if IDE previously had an earlier Core Tools version #7655

Open gabesmsft opened 3 years ago

gabesmsft commented 3 years ago

If I install the Functions v4 runtime and .NET 6 preview on a machine that previously had an earlier Functions Core Tools install (eg v3), I get the following error when I try to add a Function to the project. No templates found matching: 'HTTPtrigger'. To list installed templates, run 'dotnet new --list'. To search for the templates on NuGet.org, run 'dotnet new HTTPtrigger --search'.

Error creating function

Note: I get a comparable error regardless of what type of Function I try to add (eg QueueTrigger, etc).

My environment: OS: Windows (eg Windows 10 or Windows Server 2019) Core Tools Version: 4.0.3687 Commit hash: 9974228c80b20f3128903fac1035d94200d0ba5f (64-bit) .NET SDKs: 3.1.302.15188 5.1.120.60105 6.1.21.35502

Node.js: 14.7.0 Visual Studio 2019

Repro steps:

  1. On a machine that has an earlier Functions Core Tools install (eg v3), uninstall Functions Core Tools via Programs and Features and/or via npm uninstall -g azure-functions-core-tools. Confirm that the npm directory is automatically deleted from %USERPROFILE%\AppData\Roaming
  2. Install Core Tools v4 preview via npm i -g azure-functions-core-tools@4 --unsafe-perm true , in a command line console running in admin mode
  3. Confirm that the above Core Tools version is installed via func --version
  4. For good measure, close the command prompt and open a new command prompt (in admin mode)
  5. In a new folder, initialize a project via func init --csharp , and verify that the target framework of the csproj file is net6.0
  6. Attempt to create an HTTP Function via the following command: func new --name HttpExample --template "HTTP trigger" --authlevel "anonymous"

Expected result: Function would get created. Actual result: above-mentioned error.

Same result if I run func new and then select HttpTrigger or another Function type in the list.

If I uninstall .NET 6 SDK, I can create Functions in the project. Once I have Function, I can use the above setup (with .NET 6 SDK installed) to build and run the project and execute the function.

mikelor commented 3 years ago

I have this problem with a new install (no prior Functions runtime v3 or otherwise install).

> dotnet new HttpTrigger --search
These templates matched your input: 'HttpTrigger'

Template Name           Short Name   Author     Language  Package                                         Downloads
----------------------  -----------  ---------  --------  ----------------------------------------------  ---------
HttpTrigger             http         Microsoft  [C#],F#   Microsoft.Azure.WebJobs.ItemTemplates              4,518k
HttpTrigger             http         Microsoft  [C#]      Microsoft.Azure.Functions.Worker.ItemTemplates       178k
HttpTriggerWithOpenAPI  httpOpenAPI  Microsoft  [C#]      Microsoft.Azure.WebJobs.ItemTemplates              4,518k

I install using the Microsoft.Azure.WebJobs.ItemTemplates

PS C:\Users\m\repos\FunkySix> dotnet new --install Microsoft.Azure.WebJobs.ItemTemplates
The following template packages will be installed:
   Microsoft.Azure.WebJobs.ItemTemplates

Success: Microsoft.Azure.WebJobs.ItemTemplates::3.1.1812 installed the following templates:
Template Name                  Short Name       Language  Tags
-----------------------------  ---------------  --------  ----------------------------------------------
BlobTrigger                    blob             [C#],F#   Azure Function/Trigger/Blob
CosmosDBTrigger                cosmos,CosmosDB  [C#],F#   Azure Function/Trigger/Cosmos DB
DurableFunctionsOrchestration  durable          [C#]      Azure Function/Durable Functions Orchestration
EventGridTrigger               eventgrid        [C#]      Azure Function/Trigger/EventGrid
EventHubTrigger                eventhub         [C#],F#   Azure Function/Trigger/EventHub
HttpTrigger                    http             [C#],F#   Azure Function/Trigger/Http
HttpTriggerWithOpenAPI         httpOpenAPI      [C#]      Azure Function/Trigger/Http
IotHubTrigger                  iothub           [C#]      Azure Function/Trigger/IotHub
KafkaOutput                    kafkao           [C#]      Azure Function/Ouput/Kafka
KafkaTrigger                   kafka            [C#]      Azure Function/Trigger/Kafka
QueueTrigger                   queue            [C#]      Azure Function/Trigger/Storage Queue
RabbitMQTrigger                rqueue           [C#]      Azure Function/Trigger/RabbitMQ Queue
SendGrid                       sendgrid         [C#]      Azure Function/Ouput/SendGrid
ServiceBusQueueTrigger         squeue           [C#]      Azure Function/Trigger/Service Bus/Queue
ServiceBusTopicTrigger         stopic           [C#]      Azure Function/Trigger/Service Bus/Topic
SignalRTrigger                 signalr          [C#]      Azure Function/Trigger/Http/SignalR
TimerTrigger                   timer            [C#],F#   Azure Function/Trigger/Timer

And when I do a dotnet new --list, it shows up

PS C:\Users\m\repos\FunkySix> dotnet new --install Microsoft.Azure.WebJobs.ItemTemplates
The following template packages will be installed:
   Microsoft.Azure.WebJobs.ItemTemplates

Success: Microsoft.Azure.WebJobs.ItemTemplates::3.1.1812 installed the following templates:
Template Name                  Short Name       Language  Tags
-----------------------------  ---------------  --------  ----------------------------------------------
BlobTrigger                    blob             [C#],F#   Azure Function/Trigger/Blob
CosmosDBTrigger                cosmos,CosmosDB  [C#],F#   Azure Function/Trigger/Cosmos DB
DurableFunctionsOrchestration  durable          [C#]      Azure Function/Durable Functions Orchestration
EventGridTrigger               eventgrid        [C#]      Azure Function/Trigger/EventGrid
EventHubTrigger                eventhub         [C#],F#   Azure Function/Trigger/EventHub
HttpTrigger                    http             [C#],F#   Azure Function/Trigger/Http
HttpTriggerWithOpenAPI         httpOpenAPI      [C#]      Azure Function/Trigger/Http
IotHubTrigger                  iothub           [C#]      Azure Function/Trigger/IotHub
KafkaOutput                    kafkao           [C#]      Azure Function/Ouput/Kafka
KafkaTrigger                   kafka            [C#]      Azure Function/Trigger/Kafka
QueueTrigger                   queue            [C#]      Azure Function/Trigger/Storage Queue
RabbitMQTrigger                rqueue           [C#]      Azure Function/Trigger/RabbitMQ Queue
SendGrid                       sendgrid         [C#]      Azure Function/Ouput/SendGrid
ServiceBusQueueTrigger         squeue           [C#]      Azure Function/Trigger/Service Bus/Queue
ServiceBusTopicTrigger         stopic           [C#]      Azure Function/Trigger/Service Bus/Topic
SignalRTrigger                 signalr          [C#]      Azure Function/Trigger/Http/SignalR
TimerTrigger                   timer            [C#],F#   Azure Function/Trigger/Timer

However the func new still fails, and then with I do the above command the HttpTrigger no longer shows up

mikelor commented 3 years ago

Probably makes sense to link it to this issue 1076 in Azure/azure-function-templates Azure/Azure-Functions#1076