c# - 命名空间 'Azure' 中不存在类型或命名空间 'Microsoft' - Visual Studio 2022

标签 c# azure visual-studio azure-functions

我刚刚安装了 Visual Studio 2022,正在尝试开发 BlobTrigger Azure 函数。作为创建的默认类的一部分,包含以下命名空间:

using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Host;
using Microsoft.Extensions.Logging;

但是,每条下方都会出现红线,并显示以下消息:

The type or namespace 'Azure' does not exist in the namespace 'Microsoft' 

关于我可能需要安装什么才能使其正常工作有什么想法吗?

最佳答案

The type or namespace 'Azure' does not exist in the namespace 'Microsoft'.

您应该在 Visual Studio 中安装这些软件包才能在应用程序中使用它们。

  • 要安装这些软件包,请转到“工具”>“NuGet 软件包管理器”>“软件包管理器控制台”,运行以下给定的命令。
Install-Package Microsoft.Azure.WebJobs
Install-Package Microsoft.Azure.WebJobs.Host
Install-Package Microsoft.Extensions.Logging

enter image description here

或者直接安装软件包: 转到“工具”>“NuGet 包管理器”>“管理解决方案的 Nuget 包”。

enter image description here

<小时/>

我创建了一个示例 Blob 触发器 Azure 函数。

我通过删除环境中安装的软件包重现了该问题,并且遇到了相同的错误。

enter image description here

在应用程序中安装以下软件包后,我可以修复错误并获得预期的结果。

enter image description here

输出:

enter image description here

enter image description here

关于c# - 命名空间 'Azure' 中不存在类型或命名空间 'Microsoft' - Visual Studio 2022,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75629036/

相关文章:

c# - Autofac:使用 Web API 2 设置,我缺少什么

c# - WPF - 将 List<T> 绑定(bind)为 WrapPanel 的内容

mysql - 根据 DNS 名称分配 MySQL 权限

c++ - 使用 std::wofstream 写入文件。该文件仍然是空的

c++ - Glew 不初始化

c# - 抛出 NullReferenceException?

c# - Unity 的 GetComponent 通过字符串(或通过从另一个脚本传递的其他方法)

azure - 无法连接到 Azure Pipelines 中的 docker

azure - 找不到我注册的 Azure AD 应用程序

git - 无法同步当前分支不跟踪远程分支