From 6de3bc57fae7168b4083d26060dc21e3d09ddb8a Mon Sep 17 00:00:00 2001 From: Vishnu Priya Ananthu Sundaram Date: Thu, 13 Sep 2018 13:24:47 -0700 Subject: [PATCH] Allow authentication for ApplicationTokenCredentials for profiles (#2386) --- .../profile_2018_03_01_hybrid/Azure.java | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/profiles/2018-03-01-hybrid/azure/src/main/java/com/microsoft/azure/management/profile_2018_03_01_hybrid/Azure.java b/profiles/2018-03-01-hybrid/azure/src/main/java/com/microsoft/azure/management/profile_2018_03_01_hybrid/Azure.java index 4b947fd26aa0e..fb4798be7448b 100644 --- a/profiles/2018-03-01-hybrid/azure/src/main/java/com/microsoft/azure/management/profile_2018_03_01_hybrid/Azure.java +++ b/profiles/2018-03-01-hybrid/azure/src/main/java/com/microsoft/azure/management/profile_2018_03_01_hybrid/Azure.java @@ -10,6 +10,8 @@ import com.microsoft.azure.AzureResponseBuilder; import com.microsoft.azure.arm.resources.AzureConfigurable; import com.microsoft.azure.arm.resources.implementation.AzureConfigurableCoreImpl; +import com.microsoft.azure.arm.utils.ResourceManagerThrottlingInterceptor; +import com.microsoft.azure.credentials.ApplicationTokenCredentials; import com.microsoft.azure.credentials.AzureTokenCredentials; import com.microsoft.azure.management.appservice.v2016_03_01.BillingMeters; import com.microsoft.azure.management.appservice.v2016_03_01.Certificates; @@ -76,6 +78,7 @@ import com.microsoft.azure.management.network.v2017_10_01.VirtualNetworkGateways; import com.microsoft.azure.management.network.v2017_10_01.VirtualNetworkPeerings; import com.microsoft.azure.management.network.v2017_10_01.VirtualNetworks; +import com.microsoft.azure.management.resources.fluentcore.utils.ProviderRegistrationInterceptor; import com.microsoft.azure.management.resources.v2018_02_01.DeploymentOperations; import com.microsoft.azure.management.resources.v2018_02_01.Deployments; import com.microsoft.azure.management.resources.v2018_02_01.Providers; @@ -123,6 +126,18 @@ public static Azure authenticate(AzureTokenCredentials credentials, String subsc .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) .build(), subscriptionId); } + + public static Azure authenticate(ApplicationTokenCredentials credentials, String subscriptionId) { + return new Azure(new RestClient.Builder() + .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER) + .withCredentials(credentials) + .withSerializerAdapter(new AzureJacksonAdapter()) + .withResponseBuilderFactory(new AzureResponseBuilder.Factory()) + .withInterceptor(new ProviderRegistrationInterceptor(credentials)) + .withInterceptor(new ResourceManagerThrottlingInterceptor()) + .build(), subscriptionId); + } + /** * Creates an instance of Azure that exposes ContainerService resource management API entry points. *