我使用的是1.0.0-beta4.1 Azure Java SDK。这是我的身份验证代码
// 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");
如果凭据不正确,代码不会抛出任何错误。 有没有办法找出身份验证是否成功。
答案 0 :(得分:2)
根据您的代码,似乎缺少一些包含configure()
的必需方法,请参阅下文。
Azure azure = Azure.configure() // Initial an Azure.Configurable object
.withLogLevel(HttpLoggingInterceptor.Level.BASIC)
.authenticate(credentials)
.withSubscription(subscriptionId);
请尝试使用上面的代码而不是您的代码。任何更新,请随时告诉我。
答案 1 :(得分:0)
我也遇到了同样的异常,并且可以通过将来解决它。
所以,我想告知我我使用了依赖项
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure</artifactId>
<version>1.0.0</version>