diff --git a/azure-auth-helper/src/main/java/com/microsoft/azure/auth/AzureAuthHelper.java b/azure-auth-helper/src/main/java/com/microsoft/azure/auth/AzureAuthHelper.java index 54ec896795..828c7ffcc9 100644 --- a/azure-auth-helper/src/main/java/com/microsoft/azure/auth/AzureAuthHelper.java +++ b/azure-auth-helper/src/main/java/com/microsoft/azure/auth/AzureAuthHelper.java @@ -281,16 +281,18 @@ public static AzureTokenWrapper getAzureCLICredential() throws IOException { // /src/main/java/com/microsoft/azure/credentials/AzureCliCredentials.java#L48 // AzureCliCredentials.create will block using System.in.read() if user has logout using `az logout` // here we must check these two json files for empty - final List tokens = JsonUtils.fromJson(FileUtils.readFileToString(accessTokens, "utf8"), List.class); - if (tokens.isEmpty()) { - return null; - } - final Wrapper wrapper = JsonUtils.fromJson(FileUtils.readFileToString(azureProfile, "utf8"), Wrapper.class); - if (wrapper.subscriptions == null || wrapper.subscriptions.isEmpty()) { - return null; + if (azureProfile.exists() && accessTokens.exists()) { + final List tokens = JsonUtils.fromJson(FileUtils.readFileToString(accessTokens, "utf8"), List.class); + if (tokens.isEmpty()) { + return null; + } + final Wrapper wrapper = JsonUtils.fromJson(FileUtils.readFileToString(azureProfile, "utf8"), Wrapper.class); + if (wrapper.subscriptions == null || wrapper.subscriptions.isEmpty()) { + return null; + } + return new AzureTokenWrapper(AuthMethod.AZURE_CLI, + AzureCliCredentials.create(azureProfile, accessTokens), azureProfile, accessTokens); } - return new AzureTokenWrapper(AuthMethod.AZURE_CLI, - AzureCliCredentials.create(azureProfile, accessTokens), azureProfile, accessTokens); } return null; } diff --git a/azure-maven-plugin-lib/pom.xml b/azure-maven-plugin-lib/pom.xml index 583eb232ff..16e52ba977 100644 --- a/azure-maven-plugin-lib/pom.xml +++ b/azure-maven-plugin-lib/pom.xml @@ -35,7 +35,7 @@ 2.0.2 2.3.2 1.13 - 0.2.0 + 0.3.0-SNAPSHOT 0.1.0-SNAPSHOT diff --git a/azure-tools-common/pom.xml b/azure-tools-common/pom.xml index 2eecf8f1e6..ba35b2a3c7 100644 --- a/azure-tools-common/pom.xml +++ b/azure-tools-common/pom.xml @@ -71,7 +71,7 @@ com.microsoft.azure azure-auth-helper - 0.2.0 + 0.3.0-SNAPSHOT com.microsoft.azure