microsoft / vscode-azurestaticwebapps

Azure Static Web Apps extension for VS Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurestaticwebapps
MIT License
86 stars 33 forks source link

Node.js v4 Preview typescript function file not created correctly #829

Closed diberry closed 1 year ago

diberry commented 1 year ago

In a new/empty directory, I created a v4 ts app. The boilerplate looks correct except for the function file itself.

{
    "name": "Azure"
}

image

image

image

image

image

MicroFish91 commented 1 year ago

How did you create this project? What kind of trigger did you start with? When you create a new TS project with an httpTrigger, it looks like this:

Image

diberry commented 1 year ago

I started with VSCode's Azure functions extension to create function app but selected the Node.js v4 model. The trigger was an HTTP trigger but I renamed it in the step to status.

Thanks for providing the code - I do know what the code looks like - just wondered if the Azure Functions vscode extension was supposed to work with the new programming model.

diberry commented 1 year ago

I can't repro this now.

diberry commented 1 year ago

Just repro'd: more details.

  1. On windows - internal FTE laptop windows version.
  2. In new/empty folder - nothing else in it - not even .git.
  3. Created new app from Azure explorer workspace icon - didn't ask me for directory - all questions asked and answered - no problems. (I tried a second time using the Command Pallete and was allowed to select the base directory - the final file created looks correct and there is no API nesting)

image

  1. After process, file is named correctly but only has
{
    "name": "Azure"
}
  1. Another weird thing is that the directory structure is an additional layer of api.

image

image

nturinski commented 1 year ago

Ah, I see. This is a good find!

The "+" button that you're clicking is actually part of the Static Web Apps extension (that leverages Functions to create a HTTP Trigger). SWA must not be equipped to deal with the new programming model which is probably why it's creating this weird function. That's also why it's automatically creating it in the "api" folder.

If you want to create a new Functions project using the Functions extension, you need to click the image button instead. But this is definitely something that we need to fix (though I'm going to transfer it to SWA since it's technically an issue there)