3

In my project I had installed the Microsoft.Azure.Management.Fluent package (version 1.27) to do resource management for my azure subscription. My connection object looks like this:

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

This worked fine. Today, I installed Azure.Storage.Blobs package with Nuget (version 12.4). After installing this package, I got an error:

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

When I uninstall the Azure.Storage.Blobs package, the error disappears. What might be going on here? I am using it in a Net Core 2.2 MVC project.

CMorgan
  • 645
  • 2
  • 11
  • 33

1 Answers1

5

You should use the full-qualified class name instead of Azure class to solve the confilict, the code below is ok:

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

The reason is that after installed Azure.Storage.Blobs, there is a namespace Azure included for blob storage. So in the code, when you type Azure.Configure(), the compliler will confuse, the Azure is namespace or class? Apprantely, it will consider Azure as a namespace(here, the Azure namespace is for blob storage), but the Configure() method does not in this namespce, then it will throw such error.

Ivan Glasenberg
  • 29,865
  • 2
  • 44
  • 60
  • thank you, that was indeed the problem. Just a follow up question: Is this a design glitch, or something that cannot be avoided? It seemed weird to me since they are both Microsoft libraries, and Visual Studio didn't suggest a solution for it. – CMorgan Apr 26 '20 at 16:32
  • @CMorgan, I don't know if it's a design glitch. I think the vs will always use namespace over a class if they have the same name. – Ivan Glasenberg Apr 27 '20 at 01:10