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

Fail to deploy a project to a function app #3312

Open v-xinda opened 2 years ago

v-xinda commented 2 years ago

OS: Win 10 Build Version: 20220902.7 Regression: Previous release

Repro Steps:

  1. Create and open a nodejs project.
  2. Create a new function app -> Deploy the nodejs project to it.
  3. Check whether succeeds to deploy the nodejs project to a function app or not.

Expect: Succeed to deploy the nodejs project to a function app.

Actual: Fail to deploy the nodejs project to a function app. image

More Info:

  1. This issue also reproduces when deploying other language projects to the function apps.
  2. Succeed to deploy Python (Programming Model V2) project to python premium function app after adding an application setting AzureWebJobsFeatureFlags:EnableWorkerIndexing, but sometimes the deployment is still failed.
philliphoff commented 2 years ago

I've been able to reproduce this intermittently. In some cases, it looks like the function app resource item doesn't have a set appSettingsTreeItem. This appears set only when loading children, so perhaps a bug when commands that need the property are invoked before the item is expanded?

philliphoff commented 2 years ago

Workaround appears to be to expand the function app node first before deploying.

philliphoff commented 2 years ago

May be the same as #3219.

Flanker32 commented 2 years ago

We also meet this exception when test java 17 support in VSCode, which seems caused by https://github.com/microsoft/vscode-azurefunctions/blob/main/src/commands/deploy/verifyAppSettings.ts#L41, as node.appSettingsTreeItem may be undefined if node is not expanded. Resolved in commit https://github.com/microsoft/vscode-azurefunctions/pull/3311/commits/ec8fe909ad27c9d496f78a23448f97412c0cf6a7

ejizba commented 2 years ago

@philliphoff I ran into this after deploying to a freshly created app from the portal, specifically after the extension added WEBSITE_RUN_FROM_PACKAGE to the app settings (VS Code will add that setting by default for windows apps, but the portal won't). It seems to happen consistently if I remove that setting before deploy, but not if I have that setting. So I wonder if it's related to updating app settings during deploy

philliphoff commented 2 years ago

@ejizba. Yes, looking at the code, if the extension needs to update the app settings during deployment, it needs the appSettingsTreeItem property be available. However, this only appears to be set when the app node has been expanded. If no settings need to be updated during deployment, that logic is skipped.