I am having problems debugging my azure functions app in VSCode on a macbook. I have a functions v4 project that was created on my Windows machine and moved over to my mac. When I tried to run the function app with func start --csharp
and it wouldn't run so I ran func --version
and it said it was running on function v3. I did an npm global install for version 4 and it worked using the func start
command. However, when I try to debug the project. I get the following info in the console:
Executing task: func host start
Azure Functions Core Tools
Core Tools Version: 3.0.5682 Commit hash: N/A (64-bit)
Function Runtime Version: 3.22.0.0
It then gives me the following error:
[2024-12-09T13:46:18.629Z] A host error has occurred during startup operation '208b4c31-f120-4954-8bf8-d4b306fc3f88'.
[2024-12-09T13:46:18.629Z] Microsoft.Azure.WebJobs.Script: Failed to start Language Worker Channel for language :dotnet-isolated. Microsoft.Azure.WebJobs.Script.Grpc: WorkerCofig for runtime: dotnet-isolated not found.
Value cannot be null. (Parameter 'provider')
[2024-12-09T13:46:18.762Z] A host error has occurred during startup operation '6c079412-f787-4e0a-a448-6ec6d5baaf81'.
[2024-12-09T13:46:18.763Z] Microsoft.Extensions.DependencyInjection: Cannot access a disposed object.
[2024-12-09T13:46:18.763Z] Object name: 'IServiceProvider'.
It seems as though the debugger is using Azure Functions Core Tools 3. How do I change this to version 4?
--- edit ---
My app is an isolated function. Here is the local.settings.json
{
"IsEncrypted": false,
"Values": {
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated"
},
"Host": {
"CORS": "*",
"CORS_ALLOWED_ORIGINS": [
"https://localhost:4200"
]
}
}
Here is my .csproj file:
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<UserSecretsId>4ae23a55-0673-43dd-b460-c9025ce15b4f</UserSecretsId>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.20.1" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Abstractions" Version="1.3.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="1.2.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.16.4" />
<PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.21.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="1.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.UserSecrets" Version="9.0.0" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="9.0.0" />
<PackageReference Include="Microsoft.IdentityModel.Protocols.OpenIdConnect" Version="8.2.1" />
<PackageReference Include="System.IdentityModel.Tokens.Jwt" Version="8.2.1" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\CriticalPass.Managers\CriticalPass.Managers.csproj" />
<ProjectReference Include="..\CriticalPass.Models\CriticalPass.Models.csproj" />
<ProjectReference Include="..\CriticalPass.MsGraph\CriticalPass.MsGraph.csproj" />
<ProjectReference Include="..\CriticalPass.Utils\CriticalPass.Utils.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="host.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="local.settings.json">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<CopyToPublishDirectory>Never</CopyToPublishDirectory>
</None>
</ItemGroup>
<ItemGroup>
<Using Include="System.Threading.ExecutionContext" Alias="ExecutionContext" />
</ItemGroup>
</Project>
I found the problem. I installed an earlier version of the Azure Functions Core Tools a little while ago to get an older version of the app running which ran on functions v3. I was not able to do so, so I upgraded the app. When I tried to run it, it said version 3 was installed. So I ran npm install to install the latest version globally. When I shut down and started VSCode again I got an error message that said two versions of func cli were installed and gave me the option to delete the one from npm or the one from brew. I tried uninstalling and running each one separately but no luck. However I noticed when I uninstalled npm and ran brew, it said v3 was running, even though I had uninstalled it and reinstalled the new version. I also tried running brew upgrade azure-functions-core-tools
and it still said v3 was running. When I uninstalled it it still said v3 was running.
When I ran brew unlink azure-functions-core-tools@3
and ran func -version
it showed there was no func cli installed. I then ran brew install azure-functions-core-tools@4
and then it shows that v4 was running. When I hit F5 the debugger ran properly.