azure - Azure.Fluent.Management 和 Azure.Storage.Blobs 包之间存在冲突吗?

标签 azure asp.net-core azure-blob-storage

在我的项目中,我安装了 Microsoft.Azure.Management.Fluent 包(版本 1.27)来为我的 Azure 订阅进行资源管理。我的连接对象如下所示:

AzureCredentials credentials = GenerateCredentials(); // custom method that returns my creds.
IAzure azureConn = Azure
   .Configure()
   .Authenticate(credentials)
   .WithDefaultSubscription();

这工作得很好。今天,我使用 Nuget(版本 12.4)安装了 Azure.Storage.Blobs 包。安装此包后,出现错误:

> CS0234 C# The type or namespace name 'Configure' does not exist in the
> namespace 'Azure' (are you missing an assembly reference?)

当我卸载 Azure.Storage.Blobs 包时,错误消失。这里可能发生了什么?我在 Net Core 2.2 MVC 项目中使用它。

最佳答案

您应该使用完全限定的类名而不是Azure类来解决冲突,下面的代码可以:

IAzure azureConn = Microsoft.Azure.Management.Fluent.Azure
                  .Configure()
                  .Authenticate(credentials)
                  .WithDefaultSubscription();

原因是安装Azure.Storage.Blobs后,包含了一个用于blob存储的命名空间Azure。所以在代码中,当你输入Azure.Configure()时,编译器会混淆,Azurenamespace还是class?显然,它会将 Azure 视为命名空间(这里,Azure 命名空间用于 blob 存储),但 Configure() 方法不会在这个命名空间中,那么就会抛出这样的错误。

关于azure - Azure.Fluent.Management 和 Azure.Storage.Blobs 包之间存在冲突吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61408760/

相关文章:

azure - Terraform - 从值列表创建对象列表

azure - 在复制数据事件的 Azure datafactory 中,源设置中仅显示链接服务的前 3 个参数

c# - Windows Azure cscfg 文件,呈现枚举

java - 从Azure blob存储下载所有文件,将其压缩并在JAVA中上传zip文件

Azure Key Vault 谁做了哪些审计

c# - ASP.NET Core 5.0 JWT 身份验证抛出 401 代码

c# - 如何在 ASP.NET Core 中的 API 调用中接收 json 值

c# - 在 ASP.NET Core 中将 JSON 字符串整数反序列化为 Enum

azure - Azure 存储的 block Blob 上的小文件

azure - 在 Azure Functions 中重新启动 Poison blob