Azure-functions-host: v3 functions.json - FileNotFoundException

Created on 20 Oct 2019  路  3Comments  路  Source: Azure/azure-functions-host

I am upgrading v2 .netcore functions to v3-preview functions based on @jeffhollan https://dev.to/azure/develop-azure-functions-using-net-core-3-0-gcm description

I do have v3 templates in VS (with the suggested environment variable). My csproj:

<PropertyGroup>
    <TargetFramework>netcoreapp3.0</TargetFramework>
    <AzureFunctionsVersion>v3-preview</AzureFunctionsVersion>
    <LangVersion>preview</LangVersion>
  </PropertyGroup>
  <ItemGroup>
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.DurableTask" Version="2.0.0-beta3" />
    <PackageReference Include="Microsoft.Azure.WebJobs.Extensions.EventHubs" Version="3.0.6" />
    <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="1.0.30-beta2" />
     ...

hosts.json:

  "version": "2.0"

I have multiple functions in the project. When I start the solution (local debug), I get an exception:
System.IO.FileNotFoundException: 'Could not find file 'C:\Users[userId]\source\repos\IotProcessor\HubProcessor\bin\Debug\netcoreapp3.0\bin\function.json'.'

While it is under
'C:\Users[userId]\source\repos\IotProcessor\HubProcessor\bin\Debug\netcoreapp3.0\ functionName1 \function.json'.'

Stacktrace
at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.StreamReader.ValidateArgsAndOpenPath(String path, Encoding encoding, Int32 bufferSize)
at System.IO.StreamReader..ctor(String path, Encoding encoding, Boolean detectEncodingFromByteOrderMarks)
at System.IO.File.InternalReadAllText(String path, Encoding encoding)
at System.IO.File.ReadAllText(String path)
at System.IO.Abstractions.FileWrapper.ReadAllText(String path)
at Microsoft.Azure.WebJobs.Script.Utility.TryReadFunctionConfig(String scriptDir, String& json, IFileSystem fileSystem) in C:\azure-functions-host\src\WebJobs.Script\Utility.cs:line 440

Most helpful comment

Workaround:

  1. Install latest VS2019 Preview
  2. Use the latest preview of Microsoft.NET.Sdk.Functions (ex: <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.0-preview2" />)
  3. It will search for function.json, but you can uncheck the box to Break on All exceptions of that type. In VS under Exception Settings, uncheck the Break when this exception type is thrown choice in the Exception popup when it appears and press Enter to continue.

All 3 comments

cc @brettsam
Assigning to @soninaren for further investigation

Workaround:

  1. Install latest VS2019 Preview
  2. Use the latest preview of Microsoft.NET.Sdk.Functions (ex: <PackageReference Include="Microsoft.NET.Sdk.Functions" Version="3.0.0-preview2" />)
  3. It will search for function.json, but you can uncheck the box to Break on All exceptions of that type. In VS under Exception Settings, uncheck the Break when this exception type is thrown choice in the Exception popup when it appears and press Enter to continue.

@TimPosey2 - You're a lifesaver, worked like a charm.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rati3l picture rati3l  路  3Comments

ElvenSpellmaker picture ElvenSpellmaker  路  3Comments

mathewc picture mathewc  路  3Comments

christopheranderson picture christopheranderson  路  4Comments

alaatm picture alaatm  路  4Comments