azureasp.net-coreazure-blob-storageazure-fluent-api

conflict between Azure.Fluent.Management and Azure.Storage.Blobs packages?


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.


Solution

  • 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.