在我的项目中,我安装了 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()
时,编译器会混淆,Azure
是namespace
还是class
?显然,它会将 Azure
视为命名空间(这里,Azure
命名空间用于 blob 存储),但 Configure()
方法不会在这个命名空间中,那么就会抛出这样的错误。
关于azure - Azure.Fluent.Management 和 Azure.Storage.Blobs 包之间存在冲突吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61408760/