41

I am trying to write a couple of Azure functions (version 2) using Visual Studio 2019. The first time I try to run them I get the following message:

enter image description here

The functions run but if I restart VS and try to run the function again it downloads the tools again, which takes forever. As long as I rerun the function within the same VS session it doesn't re-perform the download.

I have verified that I have the "Azure development" workload installed in VS. I have also installed the Azure Functions Core Tools using NPM as described here. But it continues to re-download each time.

How do I get around this? Thanks.

Federick J
  • 478
  • 5
  • 16
Mark Wagoner
  • 1,729
  • 1
  • 13
  • 20
  • 1
    I had slow internet, and it seems like onetime download. But due to slow internet, there must be timeout before completely downloading it. Not sure if this is the case for all. – Max Apr 27 '20 at 11:59

5 Answers5

64

A little late to respond, but I just recently ran into this issue and it was seriously slowing down my debugging. I had tried downloading the Azure Functions Core tools via npm as recommended by the Azure Functions GitHub page but to no avail.

Thanks to another stack overflow question, I went digging into where Visual Studio keeps locally installed versions of the Azure Functions Tools:

C:\Users\[username]\AppData\Local\AzureFunctionsTools\Releases

The most recent version (for me it was 2.46.0), was empty. On a whim, I copied over the contents of the previous version into the empty folder and updated the manifest.json inside to point at the new folder.

I updated the following properties.

I updated the following properties.

This fixed the issue immediately for me, but I still don't know why this folder was empty in the first place, or why letting Visual Studio download the tools didn't persist them correctly.

Either way, I just thought I'd share in case anyone else was running into the same thing.

JJIqbal
  • 630
  • 1
  • 8
  • 23
necampanini
  • 654
  • 6
  • 5
  • 3
    Thanks, you saved me from wasting hours. It's a VS bug, it's simply unable to persist files properly. The VS team received compaints from devs for 1yr or more, then they apparently fixed it in v. 16.6.0 Preview 3.0 (didnt try yet) see more here: https://developercommunity.visualstudio.com/content/problem/612514/cant-debug-azure-function-1.html – Anton M May 07 '20 at 11:18
  • 3
    Thanks, updating Visual Studio to 16.6.0 doesn't seem to resolve this issue, however the instruction above (+comments from @heavenwing) does resolve it. – user527614 May 20 '20 at 12:38
  • 1
    @AntonM ~ The linked issue appears to be about a different topic. Perhaps you mistakenly posted the incorrect URL? In any case, I've entered a new report, found [here](https://developercommunity.visualstudio.com/content/problem/1046149/azure-functions-cli-tools-download-repeats-endless.html). This is now a circular reference ;-) – InteXX May 22 '20 at 16:03
  • 1
    Thanks alot, this really helped me speed up my debugging – Vihanga Bandara Mar 18 '21 at 06:58
  • Wish I found this sooner, you've saved me a lot of time. – Aaron Hudon Sep 13 '21 at 02:15
  • This is awesome, not only did it work flawlessly on the first try it fixed some nagging issues I was having with my Timer Trigger functions not starting immediately when I started debugging. Double Win. – Mike Devenney Feb 08 '22 at 01:59
22

@necampanini's answer is right.

And I will provide more details as below:

There is a feed file feed.json (or feed-v3.json) in %LocalAppData%\AzureFunctionsTools. Check the subfolder hierarchy for the latest version of this tool (e.g. for me it's v3.4.1) and create a corresponding subfolder (e.g. %LocalAppData%\AzureFunctionsTools\Releases\3.4.1).

Get the URL from the feed file and download the CLI zip file Azure.Functions.Cli.min.win-<platform>.<version>.zip. Extract it into %LocalAppData%\AzureFunctionsTools\Releases\<version>\cli.

Get the URLs for these two NuGet packages from the feed file:

  1. itemTemplates
  2. projectTemplates

Download the packages and save them in %LocalAppData%\AzureFunctionsTools\Releases\<version>\templates. Rename the files:

  1. microsoft.azure.webjobs.itemtemplates.<version>.nupkg becomes Azure.Functions.Templates.1.0.0.nupkg
  2. microsoft.azure.webjobs.projecttemplates.<version>.nupkg becomes Microsoft.AzureFunctions.ProjectTemplates.1.0.0.nupkg

Last, copy manifest.json from the older version folder into %LocalAppData%\AzureFunctionsTools\Releases\<version>, and then edit this file to reference the new version.

Here's a screenshot:

enter image description here

InteXX
  • 6,135
  • 6
  • 43
  • 80
heavenwing
  • 588
  • 4
  • 7
  • To match my existing installed versions I had to make some minor changes; name the folder 'cli_x64' rather then 'cli'; renames the files to ItemTemplates.nupkg and ProjectTemplates.nupkg. – Alan Hinton Jul 14 '20 at 09:22
0

Both @necampanini and @heavenwing answers helped me in resolving my issue with VS 2019 v16.7.3.

I think it's having it blank with the latest func CLI tools because VS will try to load the latest version of the tool which in my case 3.12.0. I notice that 3.12.0 is preview. Then I thought that maybe because my VS 2019 is configured to use the preview SDK - which is why it tries to locate the latest preview of the tool. So after I manually added the appropriate folders cli and templates, and run Visual Studio again, it's now using the 3.12.0 and is able to locate the files for 3.12.0. I observe that if it is unable to locate the latest cli, it will use the next version which in my case is 3.6.0.

0

Thanks for the top 2 answers. I had the same issue with vs2019, while the project references azure functions tool v2.

By looking into the feed-v3.json under %localappdata%\AzureFunctionsTools folder, I found releases 2.60.0 and 2.60.1 actually is the same build Azure.Functions.Cli.min.win-x64.2.7.3188.zip. So I can simply copied 2.60.0 into 2.60.1 which is always empty, and just updated manifest.json accordingly.

BZ_QA
  • 106
  • 3
-1

Try running Visual Studio as administrator and issue this from the console:

npm i -g azure-functions-core-tools --unsafe-perm true

Then try to reproduce the issue.

Architect Jamie
  • 1,621
  • 4
  • 18
  • Thanks but no difference. After I ran NPM I got the message "1 package updated". But I relaunched VS as both myself and administrator and in both cases it re-downloads the CLI tools. – Mark Wagoner Nov 01 '19 at 15:35
  • @MarkWagoner ~ FYI a workaround has been posted for this, in case you didn't see it. – InteXX May 22 '20 at 17:21