I am new to C#
development. I tried to create a new Azure function app
by following online tutorial.
As soon as I created I am getting attached error. I tried the same in Visual Studio Code
and Visual Studio
as well.
Please help me out if I miss any reference or nuget package
.
Here is my csproj file
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
<OutputType>Exe</OutputType>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<RootNamespace>Approve_PowerApp</RootNamespace>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
<!-- Application Insights isn't enabled by default. See https://aka.ms/AAt8mw4. -->
<!-- <PackageReference Include="Microsoft.ApplicationInsights.WorkerService" Version="2.22.0" /> -->
<!-- <PackageReference Include="Microsoft.Azure.Functions.Worker.ApplicationInsights" Version="2.0.0" /> -->
<PackageReference Include="Microsoft.Azure.Functions.Worker" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Extensions.Http.AspNetCore" Version="2.0.0" />
<PackageReference Include="Microsoft.Azure.Functions.Worker.Sdk" Version="2.0.0" />
</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>
This is how my nuget package manager looks like.
After dotnet restore
command. The packages are showing error in csproj file.
Normally speaking, the error indicates that we don't have Microsoft.Azure.Functions.Worker
reference but this package exists in csproj indeed with a correct version. So that the issue is the package isn’t properly referenced or resolved.
Firstly, we'd better to check weather our project has this reference or not like what jdweng said in the comment.
If it existed, try dotnet restore
command or right click on the project and select to clean and rebuild the application, then see whether this issue still exists or not. We can also go to the project directory and delete .vs
folder then try clean and rebuild.