error NU1100: Microsoft.NET.Sdk.Functions (>= 3.1.1)' for '.NETCoreApp,Version=v3.1 (new to c#, azure functions, coding in general)

Viewed 69

Errors

error NU1100: Unable to resolve 'Microsoft.NET.Sdk.Functions (>= 3.1.1)' for '.NETCoreApp,Version=v3.1'
error NU1100: Unable to resolve 'Microsoft.NETCore.App.Ref (= 3.1.0)' for '.NETCoreApp,Version=v3.1'
error NU1100: Unable to resolve 'Microsoft.WindowsDesktop.App.Ref (= 3.1.0)' for '.NETCoreApp,Version=v3.1'
error NU1100: Unable to resolve 'Microsoft.AspNetCore.App.Ref (= 3.1.10)' for '.NETCoreApp,Version=v3.1'

I'm working on a project to build a website and add azure function that will have a counter of how many people have visited the site. I am stuck at this point https://youtu.be/ieYrBWmkfno?t=1879. This is where I'm getting my error. I found a similar post here NU1100:Unable to resolve 'Microsoft.NET.Sdk.Functions (>= 3.0.3)' for '.NETCoreApp,Version=v3.1' . I will be honest I don't know enough about what I'm doing to even troubleshoot it. I'm using vscode and git bash as a terminal. I tried:

  1. Resolving the dependencies
  2. Downloading and installing the .net 6.0 sdk and runtime
    • Originally I tried this with .net version 6 when I was creating the azure function but the video used 3.0 lts so I changed it 3.1
  3. Downloading and installing the nuget

Any help would be appreciated. This is also my first post here so I did my best to follow the question guidelines

using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.AspNetCore.Http;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;

namespace Company.Function
{
    public static class GetResumeCounter
    {
        [FunctionName("GetResumeCounter")]
        public static async Task<IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Function, "get", "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            string name = req.Query["name"];

            string requestBody = await new StreamReader(req.Body).ReadToEndAsync();
            dynamic data = JsonConvert.DeserializeObject(requestBody);
            name = name ?? data?.name;

            string responseMessage = string.IsNullOrEmpty(name)
                ? "This HTTP triggered function executed successfully. Pass a name in the query string or in the request body for a personalized response."
                : $"Hello, {name}. This HTTP triggered function executed successfully.";

            return new OkObjectResult(responseMessage);
        }
    }
}

Code errors

1 Answers

You need few installed tools and packages before creating & running the Azure Functions .NET 6 Project through VS Code:

  1. Azure Functions core Tools V4
  2. .NET 6 SDK & Runtime
  3. VS Code IDE, VS Code > Extensions - Azurite, Azure Account, Azure Functions, Azure Tools and C# Extensions to be installed.

Check the above tools installed by using command prompt: dotnet --version to check the .NET version installed and func --version to check the Azure Functions core tools version installed in the system.

  1. Sign-in to the Azure Account in the VS Code IDE.

Here is the process of creating and running the Azure Function in VS Code:

enter image description here NuGet packages enhance the Azure Functions to be easier and more interactive, powerful when dealing with the dependencies and packages. Also, check the Nuget.Config is present in the location of %appdata%\NuGet\. Paste this path in Run Command prompt and click Enter. If not available, add it.

enter image description here

Related