microsoft / vscode-azurefunctions

Azure Functions extension for VS Code
https://marketplace.visualstudio.com/items?itemName=ms-azuretools.vscode-azurefunctions
MIT License
291 stars 134 forks source link

Better support projects in a subdirectory of root workspace #686

Closed holzapfelnet closed 5 years ago

holzapfelnet commented 6 years ago

I created a new azure function by using the Visual Studio Code Command Palette. I used the HTTP Trigger Template to create the function. I selected version 2 as project runtime, C# as language and Core as template filter.

If I try to deploy the function by clicking right on the folder (Deploy to Function App) the deployment is started but there will be no function visible within the azure portal.

During the deployment process I get the following output:

6:33:14 PM testdotcore: Creating zip package... 6:33:17 PM testdotcore: Starting deployment... 6:33:57 PM testdotcore: Updating submodules. 6:33:58 PM testdotcore: Preparing deployment for commit id '049469ec79'. 6:34:00 PM testdotcore: Skipping build. Project type: Run-From-Zip 6:34:00 PM testdotcore: Skipping post build. Project type: Run-From-Zip 6:34:04 PM testdotcore: Syncing 0 function triggers with payload size 2 bytes successful. 6:34:04 PM testdotcore: Updating D:\home\data\SitePackages\packagename.txt with deployment 20181003163318.zip 6:34:04 PM testdotcore: Deployment successful. Deployment to "testdotcore" completed.

If I use the azure function command line tool (v 2.0.3) to start the deployment the function will be successfully deployed and is visible within the azure portal.

OS: macOS Mojave 10.14 Visual Studio Code 1.27.2 Azure Functions Extension v0.11.0

ejizba commented 6 years ago

@holzapfelnet Can you copy your .vscode/settings.json file here?

I haven't tried creating a function before a project recently (although it should work). As a workaround - try creating a project before a function. See this gif for more info: https://github.com/Microsoft/vscode-azurefunctions#create-new-project

holzapfelnet commented 6 years ago

.vscode/settings.json

{ "azureFunctions.projectRuntime": "~2", "azureFunctions.projectLanguage": "C#", "azureFunctions.templateFilter": "Verified", "azureFunctions.preDeployTask": "publish", "azureFunctions.deploySubpath": "bin/Release/netstandard2.0/publish" }

nturinski commented 6 years ago

@holzapfelnet Could you let us know what version of dotnet you have installed? All your settings seem correct, so I'm wondering if maybe the name of your subpath is different. Also, could you check if bin/Release/netstandard2.0/publish exists in your project?

In this issue https://github.com/Microsoft/vscode-azurefunctions/issues/685, this user had a different path that included Hosted so I'm wondering if you're having a similar issue.

Thanks!

holzapfelnet commented 6 years ago

@nturinski I use dotnet version 2.1.402.

The bin folder contains only a Debug folder.

holzapfelnet commented 6 years ago

I think I found the problem.

If I open the folder that contains the Azure Function the deployment works fine.

However if I open the parent folder and select the folder that contains the Azure Function and then try to do the deployment (see the screenshot) the problem occurs.

screenshot
nturinski commented 6 years ago

@holzapfelnet Ah, I see. Just to make sure, you are trying to deploy "testfunc" that is within the "serverless" folder? And if you open the "testfunc" in your workspace, then everything works?

I notice your "serverless" folder contains a .vscode folder. Is there a settings.json in that folder? If there is, could you show me the settings?

It may be interfering with the deploySubpath setting that we leverage to deploy the corret folder.

holzapfelnet commented 6 years ago

@holzapfelnet Ah, I see. Just to make sure, you are trying to deploy "testfunc" that is within the "serverless" folder? And if you open the "testfunc" in your workspace, then everything works?

That's right.

I notice your "serverless" folder contains a .vscode folder. Is there a settings.json in that folder? If there is, could you show me the settings?

There is a settings.json with one single line

{ "azureFunctions.projectLanguage": "C#" }

It may be interfering with the deploySubpath setting that we leverage to deploy the corret folder.

bradcavanagh-ffs commented 6 years ago

I too ran into this bug. I have a directory structure that's similar to upperProject/azureFunctions, and if I open the upperProject folder in VS Code and try to deploy the functions in azureFunctions, I get the behaviour described above (Syncing 0 trigger functions...) and there are no more functions in the Function App in the Portal. If I open the azureFunctions directory directly, then deploy, everything works.

ejizba commented 5 years ago

Okay we have made a few improvements here (but it will still include manual steps to configure a project). Edit: This has been released. First of all, if you want to test out before our release next week, install this build: https://dev.azure.com/ms-azuretools/AzCode/_build/results?buildId=3461 following these instructions: https://aka.ms/azcodeinsiders (also note you have to be on VS Code 1.31.0+)

After that, you can follow these steps:

  1. Create a brand new project in VS Code
  2. Copy the .vscode folder at the root of that project to the root of your repo
  3. Add your subfolder as necessary. I've done an example for a C# project here: https://github.com/EricJizbaMSFT/subcs/commit/82fa639324ca4a3dcc078fabe726d22c845af37e

Let me know if you run into any issues and I'll keep this thread updated as we continue to improve this scenario.

ChristianWeyer commented 5 years ago

@EricJizbaMSFT should this still work?

I just tried with the latest VS Code and Azure Functions tools bits, and it does not work. I always get a image

Error: The func task detection didn't contribute a task for the following configuration:
{
    "type": "func",
    "dependsOn": "build",
    "options": {
        "cwd": "${workspaceFolder}/sqlserver-demo/bin/Debug/netcoreapp2.1"
    },
    "command": "host start",
    "isBackground": true,
    "problemMatcher": "$func-watch"
}
The task will be ignored.

Sample can be found here: https://github.com/thinktecture/azure-functions-extensibility

Thanks!

ejizba commented 5 years ago

@ChristianWeyer that's a related, but separate issue. Moved to #1121