Skip to content

Node: Prompt or detect upgrading users from azure-functions-core-tools@2 to azure-functions-core-tools@3 (or other major version) #2985

@kamranayub

Description

@kamranayub

Been a user of this extension for a long time (thanks!). I recently used it to create some new TypeScript/Node V3 Functions for a new project. When I went to run/debug the Functions app, I noticed it was saying I was running Functions Runtime v2 😮

It turns out, when I installed this extension, v2 was the major version. But now it's V3. Initially, it installed azure-functions-core-tools@2 globally. However, it wasn't detecting that I was trying to run a V3 app yet my azure-functions-core-tools npm global package is outdated/doesn't match. AFAIK for Node apps, there's not an explicit declaration I'm using V3 in the host.json or anything, so in a way that kinda makes sense.

The command Install Or Update Azure Function Core Tools also doesn't appear to prompt me to upgrade. It only detects I'm on v2 currently and just updates to @2 instead of @3.

It took me awhile to understand how this worked. I finally fixed it by installing @3 myself globally 😄

Proposed Solution

In my workflow, the best place this would have been addressed is when I was originally prompted to create a V3 Functions Node App. At that point, it could have checked to see if I was running outdated Core Tools and then initiated the update.

Alternatively, the next best place would be when I tried to run func host start (via Debugger). The functions runtime is set in my .vscode/settings.json:

{
  "azureFunctions.deploySubpath": ".",
  "azureFunctions.postDeployTask": "npm install (functions)",
  "azureFunctions.projectLanguage": "TypeScript",
  "azureFunctions.projectRuntime": "~3",
  "debug.internalConsoleOptions": "neverOpen",
  "azureFunctions.preDeployTask": "npm prune (functions)"
}

Lastly, Install or Update Azure Function Core Tools could perform this check but I only discovered that looking at the Extension Points.

I don't know how this would be addressed if running a V2 app. There is only one globally installed Core Tools npm package (at the moment) so another possible enhancement might be to find a way to detect it and choose the version.

Extension Output

When running Install Or Update Azure Function Core Tools when I was on v2.

9:24:04 PM: Running command: "npm install -g azure-functions-core-tools@2"...
C:\Program Files\nodejs\func -> C:\Program Files\nodejs\node_modules\azure-functions-core-tools\lib\main.js
C:\Program Files\nodejs\azfun -> C:\Program Files\nodejs\node_modules\azure-functions-core-tools\lib\main.js
C:\Program Files\nodejs\azurefunctions -> C:\Program Files\nodejs\node_modules\azure-functions-core-tools\lib\main.js

> azure-functions-core-tools@2.7.3188 postinstall C:\Program Files\nodejs\node_modules\azure-functions-core-tools
> node lib/install.js

attempting to GET "https://functionscdn.azureedge.net/public/2.7.3188/Azure.Functions.Cli.win-x64.2.7.3188.zip"

+ azure-functions-core-tools@2.7.3188
updated 1 package in 28.29s
9:24:34 PM: Finished running command: "npm install -g azure-functions-core-tools@2".

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions