簡體   English   中英

錯誤 NU1100: Microsoft.NET.Sdk.Functions (>= 3.1.1)' for '.NETCoreApp,Version=v3.1 (new to c#, ZCF04A02E37B774FC391Z4A)

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

錯誤

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'

我正在做一個項目來建立一個網站並添加 azure function 將有多少人訪問該網站的計數器。 我被困在這一點上https://youtu.be/ieYrBWmkfno?t=1879 這是我得到錯誤的地方。 我在這里找到了類似的帖子NU1100:Unable to resolve 'Microsoft.NET.Sdk.Functions (>= 3.0.3)' for '.NETCoreApp,Version=v3.1' 老實說,我對自己在做什么甚至無法解決問題都知之甚少。 我正在使用 vscode 和 git bash 作為終端。 我試過了:

  1. 解決依賴關系
  2. 下載並安裝 .net 6.0 sdk 和運行時
    • 最初我在創建 azure function 時使用 .net 版本 6 進行了嘗試,但視頻使用了 3.0 lts 所以我更改了它
  3. 下載並安裝 nuget

任何幫助,將不勝感激。 這也是我在這里的第一篇文章,所以我盡力遵循問題指南

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);
        }
    }
}

在通過 VS 代碼創建和運行 Azure 函數 .NET 6 項目之前,您需要很少的安裝工具和包:

  1. Azure 功能核心工具V4
  2. .NET 6 SDK & 運行時
  3. VS Code IDE, VS Code > Extensions - Azurite, Azure Account, Azure Functions, Azure Tools and C# Extensions to be installed.

使用命令提示符查看以上安裝的工具: dotnet --version查看.NET 安裝的版本, func --version查看系統中安裝的Azure Functions core tools 版本。

  1. 在 VS Code IDE 中登錄 Azure 賬戶。

下面是在VS Code中創建並運行Azure Function的過程:

在此處輸入圖像描述 NuGet 包增強了 Azure 功能,使其在處理依賴項和包時更容易、更具交互性、更強大。 此外,檢查Nuget.Config是否存在於%appdata%\NuGet\的位置。 將此路徑粘貼到Run命令提示符中,然后單擊 Enter。 如果不可用,請添加它。

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM