diff --git a/Utils/azuretools-core/src/com/microsoft/azuretools/sdkmanage/AzureManagerBase.java b/Utils/azuretools-core/src/com/microsoft/azuretools/sdkmanage/AzureManagerBase.java index f107224848..611564b9b6 100644 --- a/Utils/azuretools-core/src/com/microsoft/azuretools/sdkmanage/AzureManagerBase.java +++ b/Utils/azuretools-core/src/com/microsoft/azuretools/sdkmanage/AzureManagerBase.java @@ -33,6 +33,7 @@ import java.util.LinkedList; import java.util.List; import java.util.Map; +import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import java.util.logging.Level; import java.util.logging.Logger; @@ -237,7 +238,7 @@ protected Azure.Authenticated authTenant(String tenantId) { .withInterceptor(new TelemetryInterceptor()) .withInterceptor(new RestExceptionHandlerInterceptor()) .withUserAgent(CommonSettings.USER_AGENT) - .withProxy(new Proxy(Proxy.Type.HTTP, com.microsoft.azure.toolkit.lib.Azure.az().config().getHttpProxy())) + .withProxy(createProxyFromConfig()) .authenticate(credentials); } @@ -246,7 +247,11 @@ protected InsightsManager authApplicationInsights(String subscriptionId, String return buildAzureManager(InsightsManager.configure()) .withInterceptor(new TelemetryInterceptor()) .withInterceptor(new RestExceptionHandlerInterceptor()) - .withProxy(new Proxy(Proxy.Type.HTTP, com.microsoft.azure.toolkit.lib.Azure.az().config().getHttpProxy())) + .withProxy(createProxyFromConfig()) .authenticate(credentials, subscriptionId); } + + private static Proxy createProxyFromConfig() { + return Optional.of(com.microsoft.azure.toolkit.lib.Azure.az().config().getHttpProxy()).map(proxy -> new Proxy(Proxy.Type.HTTP, proxy)).orElse(null); + } }