Search code examples
azureazure-functionsazure-functions-core-tools

Azure Function - Unable to Find Project Root


We've been working on an Azure Function for a few weeks and it has been working perfectly both locally and when published to Azure.

Today, Visual Studio downloaded the latest CLI Tools automatically (without any approval) when we ran our function locally and we now get the error:

Unable to find function project root. Expecting to have host.json in function project root.

Anyone any ideas on why this is now happening?

Thanks.


Solution

  • Azure Functions core tools(cli) might become broken due to interrupted downloading. There are three methods to handle the downloading issue in VS. The difference between the three methods is how we download the cli(including templates). To conclude,

    The first step in common, we have to ensure Azure Functions and Web Jobs Tools is the latest, right now it's 15.10.2046. On VS menus> Tools> Extensions and Updates> Updates, Update the extension if it's in the list. Close all VS instances. Wait for the update to finish(if there is).

    To verify whether our VS has an obstinate problem(e.g network speed) downloading Cli or just happen to meet the issue once, try the first method--Download in VS on startup.

    1. Remove %localappdata%\AzureFunctionsTools and %userprofile%\.templateengine folder.

    2. Reopen VS to create a new Function project, wait at the creation dialog, See Making sure all templates are up to date....

      enter image description here After a while, we can see the tip changes as

      enter image description here

    3. Click Refresh to work with the latest template instantly.

    If the network connection does fail us, i.e. Never see Updates are ready and %localappdata%\AzureFunctionsTools\Releases has no filled folders named after the value of v1 and v2 release, try the second method--Execute Automated Powershell script. Run the PS script to download and configure automatically, it essentially does the same thing VS does, without connection restriction.

    The third method manually achieves the purpose, while we can definitely rely on the automation above.