2
votes

I am using 1.0.0-beta4.1 Azure Java SDK. This is my code for authentication

    // TODO Auto-generated method stub
    String client = "xxxxxxxxxxx";
    String tenant = "xxxxxxxxxxx";
    String key = "xxxxxxxxxxx";
    String subscriptionId = "xxxxxxxxxxx";

    ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(client, tenant, key, AzureEnvironment.AZURE);
    Azure azure = Azure.authenticate(credentials).withSubscription(subscriptionId);
    System.out.println("Listing all resource groups");

The code doesn't throw any error in case of incorrect credentials. Is there any way to find whether the authentication was successful or not.

2
The current hack I am applying is to check the class variables of "azure" object is null or not and based on that deduce whether the authentication was successful or not.user1142317

2 Answers

2
votes

According to your code, it seems that missing some required methods which include configure(), please see below.

Azure azure = Azure.configure()  // Initial an Azure.Configurable object
                   .withLogLevel(HttpLoggingInterceptor.Level.BASIC)
                   .authenticate(credentials)
                   .withSubscription(subscriptionId);

Please try to use the code above instead of yours. Any update, please feel free to let me know.

0
votes

I just got the same exception and I was able to resolve it by replacing HttpLoggingInterceptor.Level.BASIC with LogLevel.BASIC.

Aso, I would like to inform that I used the dependency

<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure</artifactId>
<version>1.0.0</version>