I’ve been working on an ASP.NET Azure Functions project that was initially based on .NET 6. However, I recently switched to macOS and encountered a series of issues:
Visual Studio is not supported on macOS for my current setup. .NET 6 is deprecated and no longer recommended.
To resolve these issues, I decided to upgrade the project and install the .NET 8 SDK. I targeted my project to use .NET 8 and after spending a couple of hours, I managed to get the project to build successfully.
But when I tried to run the project I got into "Value cannot be null. (Parameter 'provider')"
I tried searching the web and tried the following solutions but it didn't work.
- Azure Functions Code tools issue 3160 2.Error in Azure Function
- Azure Function Binding Register
I’ve been working on an ASP.NET Azure Functions project that was initially based on .NET 6. However, I recently switched to macOS and encountered a series of issues:
Visual Studio is not supported on macOS for my current setup. .NET 6 is deprecated and no longer recommended.
To resolve these issues, I decided to upgrade the project and install the .NET 8 SDK. I targeted my project to use .NET 8 and after spending a couple of hours, I managed to get the project to build successfully.
But when I tried to run the project I got into "Value cannot be null. (Parameter 'provider')"
I tried searching the web and tried the following solutions but it didn't work.
- Azure Functions Code tools issue 3160 2.Error in Azure Function
- Azure Function Binding Register
- Welcome to StackOverflow. You need to add more information for people to help. For example, show the minimum code possible from your application, e.g. relevant bits of Program.cs or similar. You also need to give more context for where the error has come from. For example, is there a stack trace to go with it. Thanks. stackoverflow/help/minimal-reproducible-example – Andrew B Commented Mar 20 at 19:32
- @Munawar Hussain Could you please provide your Program.cs and .csproj files? – Sirra Sneha Commented Mar 27 at 6:53
1 Answer
Reset to default 0Steps to resolve Value cannot be null. (Parameter 'provider') in .NET 8 isolated Azure Functions:
- Ensure Prerequisites on macOS:
brew install azure/functions/azure-functions-core-tools@4
brew install dotnet
- Update your
function.cs
file with this given file:
using Microsoft.Azure.Functions.Worker;
using Microsoft.Azure.Functions.Worker.Http;
using System.Net;
public class HttpExample
{
[Function("HttpExample")]
public HttpResponseData Run(
[HttpTrigger(AuthorizationLevel.Anonymous, "get", "post")] HttpRequestData req,
FunctionContext executionContext)
{
var response = req.CreateResponse(HttpStatusCode.OK);
response.WriteString("Hello from .NET 8 Function!");
return response;
}
}
- Update your
.csproj
file:
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="1.17.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="1.17.0" OutputItemType="Analyzer" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http" Version="3.1.0" />
</ItemGroup>
</Project>
- Update your
Program.cs
file:
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.DependencyInjection;
var host = new HostBuilder()
.ConfigureFunctionsWorkerDefaults()
.ConfigureServices(services =>
{
services.AddFunctionsWorker();
})
.Build();
host.Run();
- Update your
host.json
file:
{
"version": "2.0"
}
- Make sure to select dotnet (isolated worker model):
- Final output in the terminal:
- Function App successfully started on port: