diff --git a/sdk/resourcemanager/azure-resourcemanager-appplatform/pom.xml b/sdk/resourcemanager/azure-resourcemanager-appplatform/pom.xml
index f63cd6f317220..e9a94d499da20 100644
--- a/sdk/resourcemanager/azure-resourcemanager-appplatform/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-appplatform/pom.xml
@@ -131,6 +131,29 @@
+
+ java-lts
+
+ [11,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M3
+
+
+
+ --add-exports com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm.implementation=ALL-UNNAMED
+
+ --add-opens com.azure.resourcemanager.appplatform/com.azure.resourcemanager.appplatform=ALL-UNNAMED
+
+
+
+
+
+
diff --git a/sdk/resourcemanager/azure-resourcemanager-appplatform/src/main/java/com/azure/resourcemanager/appplatform/AppPlatformManager.java b/sdk/resourcemanager/azure-resourcemanager-appplatform/src/main/java/com/azure/resourcemanager/appplatform/AppPlatformManager.java
index b68b7da4d4e21..9ab470502d079 100644
--- a/sdk/resourcemanager/azure-resourcemanager-appplatform/src/main/java/com/azure/resourcemanager/appplatform/AppPlatformManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-appplatform/src/main/java/com/azure/resourcemanager/appplatform/AppPlatformManager.java
@@ -46,7 +46,7 @@ public static AppPlatformManager authenticate(TokenCredential credential, AzureP
* @param profile the profile to use
* @return the AppPlatformManager
*/
- public static AppPlatformManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static AppPlatformManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new AppPlatformManager(httpPipeline, profile);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-appplatform/src/test/java/com/azure/resourcemanager/appplatform/AppPlatformTest.java b/sdk/resourcemanager/azure-resourcemanager-appplatform/src/test/java/com/azure/resourcemanager/appplatform/AppPlatformTest.java
index 1841cb8a8f984..63668cac1d6d6 100644
--- a/sdk/resourcemanager/azure-resourcemanager-appplatform/src/test/java/com/azure/resourcemanager/appplatform/AppPlatformTest.java
+++ b/sdk/resourcemanager/azure-resourcemanager-appplatform/src/test/java/com/azure/resourcemanager/appplatform/AppPlatformTest.java
@@ -54,10 +54,10 @@ protected HttpPipeline buildHttpPipeline(
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
rgName = generateRandomResourceName("rg", 20);
- appPlatformManager = AppPlatformManager.authenticate(httpPipeline, profile);
- appServiceManager = AppServiceManager.authenticate(httpPipeline, profile);
- dnsZoneManager = DnsZoneManager.authenticate(httpPipeline, profile);
- keyVaultManager = KeyVaultManager.authenticate(httpPipeline, profile);
+ appPlatformManager = buildManager(AppPlatformManager.class, httpPipeline, profile);
+ appServiceManager = buildManager(AppServiceManager.class, httpPipeline, profile);
+ dnsZoneManager = buildManager(DnsZoneManager.class, httpPipeline, profile);
+ keyVaultManager = buildManager(KeyVaultManager.class, httpPipeline, profile);
}
@Override
diff --git a/sdk/resourcemanager/azure-resourcemanager-appservice/pom.xml b/sdk/resourcemanager/azure-resourcemanager-appservice/pom.xml
index bfd1044287d9a..26ee8a4c2abbf 100644
--- a/sdk/resourcemanager/azure-resourcemanager-appservice/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-appservice/pom.xml
@@ -164,6 +164,7 @@
--add-opens com.azure.resourcemanager.msi/com.azure.resourcemanager.msi=ALL-UNNAMED
--add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources=ALL-UNNAMED
--add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm=ALL-UNNAMED
+ --add-opens com.azure.resourcemanager.storage/com.azure.resourcemanager.storage=ALL-UNNAMED
diff --git a/sdk/resourcemanager/azure-resourcemanager-appservice/src/main/java/com/azure/resourcemanager/appservice/AppServiceManager.java b/sdk/resourcemanager/azure-resourcemanager-appservice/src/main/java/com/azure/resourcemanager/appservice/AppServiceManager.java
index 559af38051528..7eb5395b3e3a7 100644
--- a/sdk/resourcemanager/azure-resourcemanager-appservice/src/main/java/com/azure/resourcemanager/appservice/AppServiceManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-appservice/src/main/java/com/azure/resourcemanager/appservice/AppServiceManager.java
@@ -71,7 +71,7 @@ public static AppServiceManager authenticate(TokenCredential credential, AzurePr
* @param profile the profile to use
* @return the StorageManager
*/
- public static AppServiceManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static AppServiceManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new AppServiceManager(httpPipeline, profile);
}
@@ -103,10 +103,15 @@ private AppServiceManager(HttpPipeline httpPipeline, AzureProfile profile) {
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
.subscriptionId(profile.getSubscriptionId())
.buildClient());
- keyVaultManager = KeyVaultManager.authenticate(httpPipeline, profile);
- storageManager = StorageManager.authenticate(httpPipeline, profile);
- authorizationManager = AuthorizationManager.authenticate(httpPipeline, profile);
- dnsZoneManager = DnsZoneManager.authenticate(httpPipeline, profile);
+ keyVaultManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, KeyVaultManager.configure())
+ .authenticate(null, profile);
+ storageManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, StorageManager.configure())
+ .authenticate(null, profile);
+ authorizationManager = AzureConfigurableImpl
+ .configureHttpPipeline(httpPipeline, AuthorizationManager.configure())
+ .authenticate(null, profile);
+ dnsZoneManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, DnsZoneManager.configure())
+ .authenticate(null, profile);
}
/** @return the authorization manager instance. */
diff --git a/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/AppServiceTest.java b/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/AppServiceTest.java
index 33643411c8ce5..f5a4e7b8bb1f1 100644
--- a/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/AppServiceTest.java
+++ b/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/AppServiceTest.java
@@ -92,11 +92,11 @@ protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
ResourceManagerUtils.InternalRuntimeContext internalContext = new ResourceManagerUtils.InternalRuntimeContext();
internalContext.setIdentifierFunction(name -> new TestIdentifierProvider(testResourceNamer));
- resourceManager =
- ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- keyVaultManager = KeyVaultManager.authenticate(httpPipeline, profile);
- appServiceManager = AppServiceManager.authenticate(httpPipeline, profile);
- msiManager = MsiManager.authenticate(httpPipeline, profile);
+
+ keyVaultManager = buildManager(KeyVaultManager.class, httpPipeline, profile);
+ appServiceManager = buildManager(AppServiceManager.class, httpPipeline, profile);
+ msiManager = buildManager(MsiManager.class, httpPipeline, profile);
+ resourceManager = appServiceManager.resourceManager();
setInternalContext(internalContext, appServiceManager, msiManager);
// useExistingDomainAndCertificate();
diff --git a/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/FunctionAppsTests.java b/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/FunctionAppsTests.java
index 25e42edac75b6..1e026c9447e81 100644
--- a/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/FunctionAppsTests.java
+++ b/sdk/resourcemanager/azure-resourcemanager-appservice/src/test/java/com/azure/resourcemanager/appservice/FunctionAppsTests.java
@@ -55,7 +55,7 @@ protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile
rgName1 = generateRandomResourceName("javacsmrg", 20);
rgName2 = generateRandomResourceName("javacsmrg", 20);
- storageManager = StorageManager.authenticate(httpPipeline, profile);
+ storageManager = buildManager(StorageManager.class, httpPipeline, profile);
super.initializeClients(httpPipeline, profile);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-authorization/pom.xml b/sdk/resourcemanager/azure-resourcemanager-authorization/pom.xml
index 8a98346d17ed3..1f504ec3f6f21 100644
--- a/sdk/resourcemanager/azure-resourcemanager-authorization/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-authorization/pom.xml
@@ -96,6 +96,28 @@
+
+ java-lts
+
+ [11,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M3
+
+
+
+ --add-opens com.azure.resourcemanager.authorization/com.azure.resourcemanager.authorization=ALL-UNNAMED
+ --add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources=ALL-UNNAMED
+
+
+
+
+
+
diff --git a/sdk/resourcemanager/azure-resourcemanager-authorization/src/main/java/com/azure/resourcemanager/authorization/AuthorizationManager.java b/sdk/resourcemanager/azure-resourcemanager-authorization/src/main/java/com/azure/resourcemanager/authorization/AuthorizationManager.java
index cc57d38405bcb..d237bb52a5f6a 100644
--- a/sdk/resourcemanager/azure-resourcemanager-authorization/src/main/java/com/azure/resourcemanager/authorization/AuthorizationManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-authorization/src/main/java/com/azure/resourcemanager/authorization/AuthorizationManager.java
@@ -63,7 +63,7 @@ public static AuthorizationManager authenticate(TokenCredential credential, Azur
* @param profile the profile used in Active Directory
* @return the AuthorizationManager instance
*/
- public static AuthorizationManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static AuthorizationManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new AuthorizationManager(httpPipeline, profile);
}
@@ -98,7 +98,7 @@ public interface Configurable extends AzureConfigurable {
private static class ConfigurableImpl extends AzureConfigurableImpl implements Configurable {
public AuthorizationManager authenticate(TokenCredential credential, AzureProfile profile) {
return AuthorizationManager
- .authenticate(HttpPipelineProvider.buildHttpPipeline(credential, profile), profile);
+ .authenticate(buildHttpPipeline(credential, profile), profile);
}
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-authorization/src/test/java/com/azure/resourcemanager/authorization/GraphRbacManagementTest.java b/sdk/resourcemanager/azure-resourcemanager-authorization/src/test/java/com/azure/resourcemanager/authorization/GraphRbacManagementTest.java
index 2ccccf529a5c8..7fd3b81dc0b41 100644
--- a/sdk/resourcemanager/azure-resourcemanager-authorization/src/test/java/com/azure/resourcemanager/authorization/GraphRbacManagementTest.java
+++ b/sdk/resourcemanager/azure-resourcemanager-authorization/src/test/java/com/azure/resourcemanager/authorization/GraphRbacManagementTest.java
@@ -48,9 +48,8 @@ protected HttpPipeline buildHttpPipeline(
@Override
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
- authorizationManager = AuthorizationManager.authenticate(httpPipeline, profile);
- resourceManager =
- ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
+ authorizationManager = buildManager(AuthorizationManager.class, httpPipeline, profile);
+ resourceManager = buildManager(ResourceManager.class, httpPipeline, profile);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-cdn/pom.xml b/sdk/resourcemanager/azure-resourcemanager-cdn/pom.xml
index cfc5799b0b4d4..21387c45ef2ed 100644
--- a/sdk/resourcemanager/azure-resourcemanager-cdn/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-cdn/pom.xml
@@ -90,6 +90,27 @@
+
+ java-lts
+
+ [11,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M3
+
+
+
+ --add-opens com.azure.resourcemanager.cdn/com.azure.resourcemanager.cdn=ALL-UNNAMED
+
+
+
+
+
+
diff --git a/sdk/resourcemanager/azure-resourcemanager-cdn/src/main/java/com/azure/resourcemanager/cdn/CdnManager.java b/sdk/resourcemanager/azure-resourcemanager-cdn/src/main/java/com/azure/resourcemanager/cdn/CdnManager.java
index ac4d1229b8b2c..5c768f881cd70 100644
--- a/sdk/resourcemanager/azure-resourcemanager-cdn/src/main/java/com/azure/resourcemanager/cdn/CdnManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-cdn/src/main/java/com/azure/resourcemanager/cdn/CdnManager.java
@@ -50,7 +50,7 @@ public static CdnManager authenticate(TokenCredential credential, AzureProfile p
* @param profile the profile to use
* @return the CDN Manager
*/
- public static CdnManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static CdnManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new CdnManager(httpPipeline, profile);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-cdn/src/test/java/com/azure/resourcemanager/cdn/CdnManagementTest.java b/sdk/resourcemanager/azure-resourcemanager-cdn/src/test/java/com/azure/resourcemanager/cdn/CdnManagementTest.java
index 6c82acdcf630b..7f2a6186ca2c5 100644
--- a/sdk/resourcemanager/azure-resourcemanager-cdn/src/test/java/com/azure/resourcemanager/cdn/CdnManagementTest.java
+++ b/sdk/resourcemanager/azure-resourcemanager-cdn/src/test/java/com/azure/resourcemanager/cdn/CdnManagementTest.java
@@ -45,8 +45,7 @@ protected HttpPipeline buildHttpPipeline(
@Override
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
- resourceManager =
- ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- cdnManager = CdnManager.authenticate(httpPipeline, profile);
+ cdnManager = buildManager(CdnManager.class, httpPipeline, profile);
+ resourceManager = cdnManager.resourceManager();
}
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-compute/pom.xml b/sdk/resourcemanager/azure-resourcemanager-compute/pom.xml
index a8147c661dbf2..c493c802f8834 100644
--- a/sdk/resourcemanager/azure-resourcemanager-compute/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-compute/pom.xml
@@ -166,11 +166,15 @@
+ --add-exports com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm.implementation=ALL-UNNAMED
+
--add-opens com.azure.resourcemanager.authorization/com.azure.resourcemanager.authorization=ALL-UNNAMED
--add-opens com.azure.resourcemanager.msi/com.azure.resourcemanager.msi=ALL-UNNAMED
+ --add-opens com.azure.resourcemanager.network/com.azure.resourcemanager.network=ALL-UNNAMED
--add-opens com.azure.resourcemanager.compute/com.azure.resourcemanager.compute=ALL-UNNAMED
--add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources=ALL-UNNAMED
--add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm=ALL-UNNAMED
+ --add-opens com.azure.resourcemanager.storage/com.azure.resourcemanager.storage=ALL-UNNAMED
diff --git a/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/ComputeManager.java b/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/ComputeManager.java
index 1ea42a4308889..1c4d4eb5cf2c7 100644
--- a/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/ComputeManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-compute/src/main/java/com/azure/resourcemanager/compute/ComputeManager.java
@@ -107,7 +107,7 @@ public static ComputeManager authenticate(TokenCredential credential, AzureProfi
* @param profile the profile to use
* @return the ComputeManager
*/
- public static ComputeManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static ComputeManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new ComputeManager(httpPipeline, profile);
}
@@ -139,9 +139,13 @@ private ComputeManager(HttpPipeline httpPipeline, AzureProfile profile) {
.pipeline(httpPipeline)
.subscriptionId(profile.getSubscriptionId())
.buildClient());
- storageManager = StorageManager.authenticate(httpPipeline, profile);
- networkManager = NetworkManager.authenticate(httpPipeline, profile);
- authorizationManager = AuthorizationManager.authenticate(httpPipeline, profile);
+ storageManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, StorageManager.configure())
+ .authenticate(null, profile);
+ networkManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, NetworkManager.configure())
+ .authenticate(null, profile);
+ authorizationManager = AzureConfigurableImpl
+ .configureHttpPipeline(httpPipeline, AuthorizationManager.configure())
+ .authenticate(null, profile);
}
/** @return the availability set resource management API entry point */
diff --git a/sdk/resourcemanager/azure-resourcemanager-compute/src/test/java/com/azure/resourcemanager/compute/ComputeManagementTest.java b/sdk/resourcemanager/azure-resourcemanager-compute/src/test/java/com/azure/resourcemanager/compute/ComputeManagementTest.java
index dae1c1bc3650e..2d4c9376024e9 100644
--- a/sdk/resourcemanager/azure-resourcemanager-compute/src/test/java/com/azure/resourcemanager/compute/ComputeManagementTest.java
+++ b/sdk/resourcemanager/azure-resourcemanager-compute/src/test/java/com/azure/resourcemanager/compute/ComputeManagementTest.java
@@ -70,14 +70,13 @@ protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
ResourceManagerUtils.InternalRuntimeContext internalContext = new ResourceManagerUtils.InternalRuntimeContext();
internalContext.setIdentifierFunction(name -> new TestIdentifierProvider(testResourceNamer));
- resourceManager =
- ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- computeManager = ComputeManager.authenticate(httpPipeline, profile);
- networkManager = NetworkManager.authenticate(httpPipeline, profile);
- storageManager = StorageManager.authenticate(httpPipeline, profile);
- keyVaultManager = KeyVaultManager.authenticate(httpPipeline, profile);
- authorizationManager = AuthorizationManager.authenticate(httpPipeline, profile);
- msiManager = MsiManager.authenticate(httpPipeline, profile);
+ computeManager = buildManager(ComputeManager.class, httpPipeline, profile);
+ networkManager = buildManager(NetworkManager.class, httpPipeline, profile);
+ storageManager = buildManager(StorageManager.class, httpPipeline, profile);
+ keyVaultManager = buildManager(KeyVaultManager.class, httpPipeline, profile);
+ authorizationManager = buildManager(AuthorizationManager.class, httpPipeline, profile);
+ msiManager = buildManager(MsiManager.class, httpPipeline, profile);
+ resourceManager = computeManager.resourceManager();
setInternalContext(internalContext, computeManager, networkManager, keyVaultManager, msiManager);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-containerinstance/src/main/java/com/azure/resourcemanager/containerinstance/ContainerInstanceManager.java b/sdk/resourcemanager/azure-resourcemanager-containerinstance/src/main/java/com/azure/resourcemanager/containerinstance/ContainerInstanceManager.java
index 1aee028f57092..b5cb93375fe29 100644
--- a/sdk/resourcemanager/azure-resourcemanager-containerinstance/src/main/java/com/azure/resourcemanager/containerinstance/ContainerInstanceManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-containerinstance/src/main/java/com/azure/resourcemanager/containerinstance/ContainerInstanceManager.java
@@ -55,7 +55,7 @@ public static ContainerInstanceManager authenticate(TokenCredential credential,
* @param profile the profile to use
* @return the ContainerInstanceManager
*/
- public static ContainerInstanceManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static ContainerInstanceManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new ContainerInstanceManager(httpPipeline, profile);
}
@@ -89,9 +89,13 @@ private ContainerInstanceManager(HttpPipeline httpPipeline, AzureProfile profile
.subscriptionId(profile.getSubscriptionId())
.buildClient());
- this.storageManager = StorageManager.authenticate(httpPipeline, profile);
- this.authorizationManager = AuthorizationManager.authenticate(httpPipeline, profile);
- this.networkManager = NetworkManager.authenticate(httpPipeline, profile);
+ this.storageManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, StorageManager.configure())
+ .authenticate(null, profile);
+ this.authorizationManager = AzureConfigurableImpl
+ .configureHttpPipeline(httpPipeline, AuthorizationManager.configure())
+ .authenticate(null, profile);
+ this.networkManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, NetworkManager.configure())
+ .authenticate(null, profile);
}
/** @return the storage manager in container instance manager */
diff --git a/sdk/resourcemanager/azure-resourcemanager-containerinstance/src/test/java/com/azure/resourcemanager/containerinstance/ContainerInstanceManagementTest.java b/sdk/resourcemanager/azure-resourcemanager-containerinstance/src/test/java/com/azure/resourcemanager/containerinstance/ContainerInstanceManagementTest.java
index 9ec12746febaf..ace6306efd868 100644
--- a/sdk/resourcemanager/azure-resourcemanager-containerinstance/src/test/java/com/azure/resourcemanager/containerinstance/ContainerInstanceManagementTest.java
+++ b/sdk/resourcemanager/azure-resourcemanager-containerinstance/src/test/java/com/azure/resourcemanager/containerinstance/ContainerInstanceManagementTest.java
@@ -47,7 +47,7 @@ protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile
ResourceManagerUtils.InternalRuntimeContext internalContext = new ResourceManagerUtils.InternalRuntimeContext();
internalContext.setIdentifierFunction(name -> new TestIdentifierProvider(testResourceNamer));
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
- containerInstanceManager = ContainerInstanceManager.authenticate(httpPipeline, profile);
+ containerInstanceManager = buildManager(ContainerInstanceManager.class, httpPipeline, profile);
setInternalContext(internalContext, containerInstanceManager);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-containerregistry/pom.xml b/sdk/resourcemanager/azure-resourcemanager-containerregistry/pom.xml
index 1e85db41efd82..06f983dfece17 100644
--- a/sdk/resourcemanager/azure-resourcemanager-containerregistry/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-containerregistry/pom.xml
@@ -97,6 +97,27 @@
+
+ java-lts
+
+ [11,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M3
+
+
+
+ --add-opens com.azure.resourcemanager.containerregistry/com.azure.resourcemanager.containerregistry=ALL-UNNAMED
+
+
+
+
+
+
diff --git a/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/main/java/com/azure/resourcemanager/containerregistry/ContainerRegistryManager.java b/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/main/java/com/azure/resourcemanager/containerregistry/ContainerRegistryManager.java
index 88d1cc5f076f3..69c54cd0b14a5 100644
--- a/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/main/java/com/azure/resourcemanager/containerregistry/ContainerRegistryManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/main/java/com/azure/resourcemanager/containerregistry/ContainerRegistryManager.java
@@ -56,7 +56,7 @@ public static ContainerRegistryManager authenticate(TokenCredential credential,
* @param profile the profile to use
* @return the ContainerRegistryManager
*/
- public static ContainerRegistryManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static ContainerRegistryManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new ContainerRegistryManager(httpPipeline, profile);
}
@@ -95,7 +95,8 @@ private ContainerRegistryManager(HttpPipeline httpPipeline, AzureProfile profile
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
.subscriptionId(profile.getSubscriptionId())
.buildClient());
- this.storageManager = StorageManager.authenticate(httpPipeline, profile);
+ this.storageManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, StorageManager.configure())
+ .authenticate(null, profile);
}
/** @return the availability set resource management API entry point */
diff --git a/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/test/java/com/azure/resourcemanager/containerregistry/RegistryTest.java b/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/test/java/com/azure/resourcemanager/containerregistry/RegistryTest.java
index b05b223b49132..e07c6b4c7a817 100644
--- a/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/test/java/com/azure/resourcemanager/containerregistry/RegistryTest.java
+++ b/sdk/resourcemanager/azure-resourcemanager-containerregistry/src/test/java/com/azure/resourcemanager/containerregistry/RegistryTest.java
@@ -43,9 +43,8 @@ protected HttpPipeline buildHttpPipeline(
@Override
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
- resourceManager =
- ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- registryManager = ContainerRegistryManager.authenticate(httpPipeline, profile);
+ registryManager = buildManager(ContainerRegistryManager.class, httpPipeline, profile);
+ resourceManager = registryManager.resourceManager();
rgName = generateRandomResourceName("rgacr", 10);
}
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-containerservice/pom.xml b/sdk/resourcemanager/azure-resourcemanager-containerservice/pom.xml
index 06b623e6e356c..8e64b8faed222 100644
--- a/sdk/resourcemanager/azure-resourcemanager-containerservice/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-containerservice/pom.xml
@@ -92,6 +92,27 @@
+
+ java-lts
+
+ [11,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M3
+
+
+
+ --add-opens com.azure.resourcemanager.containerservice/com.azure.resourcemanager.containerservice=ALL-UNNAMED
+
+
+
+
+
+
diff --git a/sdk/resourcemanager/azure-resourcemanager-containerservice/src/main/java/com/azure/resourcemanager/containerservice/ContainerServiceManager.java b/sdk/resourcemanager/azure-resourcemanager-containerservice/src/main/java/com/azure/resourcemanager/containerservice/ContainerServiceManager.java
index 77258abaea044..4986ad15bc5a1 100644
--- a/sdk/resourcemanager/azure-resourcemanager-containerservice/src/main/java/com/azure/resourcemanager/containerservice/ContainerServiceManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-containerservice/src/main/java/com/azure/resourcemanager/containerservice/ContainerServiceManager.java
@@ -49,7 +49,7 @@ public static ContainerServiceManager authenticate(TokenCredential credential, A
* @param profile the profile to use
* @return the ContainerServiceManager
*/
- public static ContainerServiceManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static ContainerServiceManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new ContainerServiceManager(httpPipeline, profile);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-containerservice/src/test/java/com/azure/resourcemanager/containerservice/ContainerServiceManagementTest.java b/sdk/resourcemanager/azure-resourcemanager-containerservice/src/test/java/com/azure/resourcemanager/containerservice/ContainerServiceManagementTest.java
index 49c8919ec7c6e..708aabe97585e 100644
--- a/sdk/resourcemanager/azure-resourcemanager-containerservice/src/test/java/com/azure/resourcemanager/containerservice/ContainerServiceManagementTest.java
+++ b/sdk/resourcemanager/azure-resourcemanager-containerservice/src/test/java/com/azure/resourcemanager/containerservice/ContainerServiceManagementTest.java
@@ -47,8 +47,8 @@ protected HttpPipeline buildHttpPipeline(
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
rgName = generateRandomResourceName("javaacsrg", 15);
- resourceManager = ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- containerServiceManager = ContainerServiceManager.authenticate(httpPipeline, profile);
+ containerServiceManager = buildManager(ContainerServiceManager.class, httpPipeline, profile);
+ resourceManager = containerServiceManager.resourceManager();
resourceManager.resourceGroups().define(rgName).withRegion(Region.US_EAST).create();
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-cosmos/pom.xml b/sdk/resourcemanager/azure-resourcemanager-cosmos/pom.xml
index b17195df4a4c6..701963548dc4b 100644
--- a/sdk/resourcemanager/azure-resourcemanager-cosmos/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-cosmos/pom.xml
@@ -120,6 +120,8 @@
--add-exports com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm.collection.implementation=ALL-UNNAMED
--add-exports com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm.models.implementation=ALL-UNNAMED
+
+ --add-opens com.azure.resourcemanager.cosmos/com.azure.resourcemanager.cosmos=ALL-UNNAMED
diff --git a/sdk/resourcemanager/azure-resourcemanager-cosmos/src/main/java/com/azure/resourcemanager/cosmos/CosmosManager.java b/sdk/resourcemanager/azure-resourcemanager-cosmos/src/main/java/com/azure/resourcemanager/cosmos/CosmosManager.java
index 9d5c96d05852a..a804af78dbc9b 100644
--- a/sdk/resourcemanager/azure-resourcemanager-cosmos/src/main/java/com/azure/resourcemanager/cosmos/CosmosManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-cosmos/src/main/java/com/azure/resourcemanager/cosmos/CosmosManager.java
@@ -45,7 +45,7 @@ public static CosmosManager authenticate(TokenCredential credential, AzureProfil
* @param profile the profile
* @return the ComputeManager
*/
- public static CosmosManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static CosmosManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new CosmosManager(httpPipeline, profile);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-cosmos/src/test/java/com/azure/resourcemanager/cosmos/CosmosDBTests.java b/sdk/resourcemanager/azure-resourcemanager-cosmos/src/test/java/com/azure/resourcemanager/cosmos/CosmosDBTests.java
index eac927fc1fbcc..1129a49a61226 100644
--- a/sdk/resourcemanager/azure-resourcemanager-cosmos/src/test/java/com/azure/resourcemanager/cosmos/CosmosDBTests.java
+++ b/sdk/resourcemanager/azure-resourcemanager-cosmos/src/test/java/com/azure/resourcemanager/cosmos/CosmosDBTests.java
@@ -64,9 +64,9 @@ protected HttpPipeline buildHttpPipeline(
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
rgName = generateRandomResourceName("rgcosmosdb", 20);
- resourceManager = ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- cosmosManager = CosmosManager.authenticate(httpPipeline, profile);
- networkManager = NetworkManager.authenticate(httpPipeline, profile);
+ cosmosManager = buildManager(CosmosManager.class, httpPipeline, profile);
+ networkManager = buildManager(NetworkManager.class, httpPipeline, profile);
+ resourceManager = cosmosManager.resourceManager();
}
@Override
diff --git a/sdk/resourcemanager/azure-resourcemanager-dns/pom.xml b/sdk/resourcemanager/azure-resourcemanager-dns/pom.xml
index dcfa7320b6d2a..024301c35d917 100644
--- a/sdk/resourcemanager/azure-resourcemanager-dns/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-dns/pom.xml
@@ -102,6 +102,27 @@
+
+ java-lts
+
+ [11,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M3
+
+
+
+ --add-opens com.azure.resourcemanager.dns/com.azure.resourcemanager.dns=ALL-UNNAMED
+
+
+
+
+
+
diff --git a/sdk/resourcemanager/azure-resourcemanager-dns/src/main/java/com/azure/resourcemanager/dns/DnsZoneManager.java b/sdk/resourcemanager/azure-resourcemanager-dns/src/main/java/com/azure/resourcemanager/dns/DnsZoneManager.java
index 413dc7bb00b5c..b7d0e93871fe4 100644
--- a/sdk/resourcemanager/azure-resourcemanager-dns/src/main/java/com/azure/resourcemanager/dns/DnsZoneManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-dns/src/main/java/com/azure/resourcemanager/dns/DnsZoneManager.java
@@ -47,7 +47,7 @@ public static DnsZoneManager authenticate(TokenCredential credential, AzureProfi
* @param profile the profile to use
* @return the DnsZoneManager
*/
- public static DnsZoneManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static DnsZoneManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new DnsZoneManager(httpPipeline, profile);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-dns/src/test/java/com/azure/resourcemanager/dns/DnsZoneRecordSetETagTests.java b/sdk/resourcemanager/azure-resourcemanager-dns/src/test/java/com/azure/resourcemanager/dns/DnsZoneRecordSetETagTests.java
index c9cab709c550e..49839bd696467 100644
--- a/sdk/resourcemanager/azure-resourcemanager-dns/src/test/java/com/azure/resourcemanager/dns/DnsZoneRecordSetETagTests.java
+++ b/sdk/resourcemanager/azure-resourcemanager-dns/src/test/java/com/azure/resourcemanager/dns/DnsZoneRecordSetETagTests.java
@@ -59,9 +59,8 @@ protected HttpPipeline buildHttpPipeline(
@Override
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
- resourceManager =
- ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- zoneManager = DnsZoneManager.authenticate(httpPipeline, profile);
+ zoneManager = buildManager(DnsZoneManager.class, httpPipeline, profile);
+ resourceManager = zoneManager.resourceManager();
rgName = generateRandomResourceName("dnsetagtest", 15);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-eventhubs/pom.xml b/sdk/resourcemanager/azure-resourcemanager-eventhubs/pom.xml
index 1ace451a02415..56aac58db225f 100644
--- a/sdk/resourcemanager/azure-resourcemanager-eventhubs/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-eventhubs/pom.xml
@@ -95,6 +95,28 @@
+
+ java-lts
+
+ [11,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M3
+
+
+
+ --add-opens com.azure.resourcemanager.eventhubs/com.azure.resourcemanager.eventhubs=ALL-UNNAMED
+ --add-opens com.azure.resourcemanager.storage/com.azure.resourcemanager.storage=ALL-UNNAMED
+
+
+
+
+
+
diff --git a/sdk/resourcemanager/azure-resourcemanager-eventhubs/src/main/java/com/azure/resourcemanager/eventhubs/EventHubsManager.java b/sdk/resourcemanager/azure-resourcemanager-eventhubs/src/main/java/com/azure/resourcemanager/eventhubs/EventHubsManager.java
index ec637cef720d6..9206762fcc750 100644
--- a/sdk/resourcemanager/azure-resourcemanager-eventhubs/src/main/java/com/azure/resourcemanager/eventhubs/EventHubsManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-eventhubs/src/main/java/com/azure/resourcemanager/eventhubs/EventHubsManager.java
@@ -69,7 +69,7 @@ public static EventHubsManager authenticate(TokenCredential credential, AzurePro
* @param profile the profile to use
* @return the EventHubsManager
*/
- public static EventHubsManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static EventHubsManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new EventHubsManager(httpPipeline, profile);
}
@@ -103,7 +103,8 @@ private EventHubsManager(HttpPipeline httpPipeline, AzureProfile profile) {
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
.subscriptionId(profile.getSubscriptionId())
.buildClient());
- storageManager = StorageManager.authenticate(httpPipeline, profile);
+ storageManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, StorageManager.configure())
+ .authenticate(null, profile);
}
/**
diff --git a/sdk/resourcemanager/azure-resourcemanager-eventhubs/src/test/java/com/azure/resourcemanager/eventhubs/EventHubTests.java b/sdk/resourcemanager/azure-resourcemanager-eventhubs/src/test/java/com/azure/resourcemanager/eventhubs/EventHubTests.java
index 1e08c5e4b7022..89444eb717f0c 100644
--- a/sdk/resourcemanager/azure-resourcemanager-eventhubs/src/test/java/com/azure/resourcemanager/eventhubs/EventHubTests.java
+++ b/sdk/resourcemanager/azure-resourcemanager-eventhubs/src/test/java/com/azure/resourcemanager/eventhubs/EventHubTests.java
@@ -74,11 +74,9 @@ protected HttpPipeline buildHttpPipeline(
@Override
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
- eventHubsManager = EventHubsManager.authenticate(httpPipeline, profile);
- storageManager = StorageManager.authenticate(httpPipeline, profile);
- resourceManager = ResourceManager
- .authenticate(httpPipeline, profile)
- .withDefaultSubscription();
+ eventHubsManager = buildManager(EventHubsManager.class, httpPipeline, profile);
+ storageManager = buildManager(StorageManager.class, httpPipeline, profile);
+ resourceManager = eventHubsManager.resourceManager();
}
@Override
diff --git a/sdk/resourcemanager/azure-resourcemanager-keyvault/pom.xml b/sdk/resourcemanager/azure-resourcemanager-keyvault/pom.xml
index 16379dc70d713..b5539c0295329 100644
--- a/sdk/resourcemanager/azure-resourcemanager-keyvault/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-keyvault/pom.xml
@@ -123,6 +123,28 @@
+
+ java-lts
+
+ [11,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M3
+
+
+
+ --add-opens com.azure.resourcemanager.authorization/com.azure.resourcemanager.authorization=ALL-UNNAMED
+ --add-opens com.azure.resourcemanager.keyvault/com.azure.resourcemanager.keyvault=ALL-UNNAMED
+
+
+
+
+
+
diff --git a/sdk/resourcemanager/azure-resourcemanager-keyvault/src/main/java/com/azure/resourcemanager/keyvault/KeyVaultManager.java b/sdk/resourcemanager/azure-resourcemanager-keyvault/src/main/java/com/azure/resourcemanager/keyvault/KeyVaultManager.java
index 262b77000b774..2abbff6c414eb 100644
--- a/sdk/resourcemanager/azure-resourcemanager-keyvault/src/main/java/com/azure/resourcemanager/keyvault/KeyVaultManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-keyvault/src/main/java/com/azure/resourcemanager/keyvault/KeyVaultManager.java
@@ -53,7 +53,7 @@ public static KeyVaultManager authenticate(TokenCredential credential, AzureProf
* @param profile the profile to use
* @return the KeyVaultManager
*/
- public static KeyVaultManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static KeyVaultManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new KeyVaultManager(httpPipeline, profile);
}
@@ -88,7 +88,9 @@ private KeyVaultManager(
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
.subscriptionId(profile.getSubscriptionId())
.buildClient());
- authorizationManager = AuthorizationManager.authenticate(httpPipeline, profile);
+ authorizationManager = AzureConfigurableImpl
+ .configureHttpPipeline(httpPipeline, AuthorizationManager.configure())
+ .authenticate(null, profile);
this.tenantId = profile.getTenantId();
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-keyvault/src/test/java/com/azure/resourcemanager/keyvault/KeyVaultManagementTest.java b/sdk/resourcemanager/azure-resourcemanager-keyvault/src/test/java/com/azure/resourcemanager/keyvault/KeyVaultManagementTest.java
index 27c28a9be0567..47feedb1acfea 100644
--- a/sdk/resourcemanager/azure-resourcemanager-keyvault/src/test/java/com/azure/resourcemanager/keyvault/KeyVaultManagementTest.java
+++ b/sdk/resourcemanager/azure-resourcemanager-keyvault/src/test/java/com/azure/resourcemanager/keyvault/KeyVaultManagementTest.java
@@ -52,10 +52,9 @@ protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile
vaultName = generateRandomResourceName("java-keyvault-", 20);
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
- resourceManager =
- ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- authorizationManager = AuthorizationManager.authenticate(httpPipeline, profile);
- keyVaultManager = KeyVaultManager.authenticate(httpPipeline, profile);
+ authorizationManager = buildManager(AuthorizationManager.class, httpPipeline, profile);
+ keyVaultManager = buildManager(KeyVaultManager.class, httpPipeline, profile);
+ resourceManager = keyVaultManager.resourceManager();
}
@Override
diff --git a/sdk/resourcemanager/azure-resourcemanager-monitor/pom.xml b/sdk/resourcemanager/azure-resourcemanager-monitor/pom.xml
index 32714103c6634..323c9d69c35e3 100644
--- a/sdk/resourcemanager/azure-resourcemanager-monitor/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-monitor/pom.xml
@@ -131,8 +131,10 @@
--add-exports com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm.collection.implementation=ALL-UNNAMED
+ --add-exports com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm.implementation=ALL-UNNAMED
--add-exports com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm.models.implementation=ALL-UNNAMED
+ --add-opens com.azure.resourcemanager.monitor/com.azure.resourcemanager.monitor=ALL-UNNAMED
--add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources=ALL-UNNAMED
--add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm=ALL-UNNAMED
diff --git a/sdk/resourcemanager/azure-resourcemanager-monitor/src/main/java/com/azure/resourcemanager/monitor/MonitorManager.java b/sdk/resourcemanager/azure-resourcemanager-monitor/src/main/java/com/azure/resourcemanager/monitor/MonitorManager.java
index fbb18f27e4736..b9a44470d4e1d 100644
--- a/sdk/resourcemanager/azure-resourcemanager-monitor/src/main/java/com/azure/resourcemanager/monitor/MonitorManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-monitor/src/main/java/com/azure/resourcemanager/monitor/MonitorManager.java
@@ -61,7 +61,7 @@ public static MonitorManager authenticate(
* @param profile the profile to use
* @return the MonitorManager
*/
- public static MonitorManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static MonitorManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new MonitorManager(httpPipeline, profile);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-monitor/src/test/java/com/azure/resourcemanager/monitor/MonitorManagementTest.java b/sdk/resourcemanager/azure-resourcemanager-monitor/src/test/java/com/azure/resourcemanager/monitor/MonitorManagementTest.java
index b50ae48cf45dd..6d39f9c39f79b 100644
--- a/sdk/resourcemanager/azure-resourcemanager-monitor/src/test/java/com/azure/resourcemanager/monitor/MonitorManagementTest.java
+++ b/sdk/resourcemanager/azure-resourcemanager-monitor/src/test/java/com/azure/resourcemanager/monitor/MonitorManagementTest.java
@@ -56,12 +56,11 @@ protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
ResourceManagerUtils.InternalRuntimeContext internalContext = new ResourceManagerUtils.InternalRuntimeContext();
internalContext.setIdentifierFunction(name -> new TestIdentifierProvider(testResourceNamer));
- appServiceManager = AppServiceManager.authenticate(httpPipeline, profile);
- resourceManager =
- ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- monitorManager = MonitorManager.authenticate(httpPipeline, profile);
- computeManager = ComputeManager.authenticate(httpPipeline, profile);
- storageManager = StorageManager.authenticate(httpPipeline, profile);
+ appServiceManager = buildManager(AppServiceManager.class, httpPipeline, profile);
+ monitorManager = buildManager(MonitorManager.class, httpPipeline, profile);
+ computeManager = buildManager(ComputeManager.class, httpPipeline, profile);
+ storageManager = buildManager(StorageManager.class, httpPipeline, profile);
+ resourceManager = monitorManager.resourceManager();
setInternalContext(internalContext, computeManager);
// eventHubManager = EventHubManager
diff --git a/sdk/resourcemanager/azure-resourcemanager-msi/src/main/java/com/azure/resourcemanager/msi/MsiManager.java b/sdk/resourcemanager/azure-resourcemanager-msi/src/main/java/com/azure/resourcemanager/msi/MsiManager.java
index 52d31c04f9ccf..6cf9c156ccead 100644
--- a/sdk/resourcemanager/azure-resourcemanager-msi/src/main/java/com/azure/resourcemanager/msi/MsiManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-msi/src/main/java/com/azure/resourcemanager/msi/MsiManager.java
@@ -53,7 +53,7 @@ public static MsiManager authenticate(TokenCredential credential, AzureProfile p
* @param profile the profile to use
* @return the MsiManager
*/
- public static MsiManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static MsiManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new MsiManager(httpPipeline, profile);
}
@@ -87,7 +87,9 @@ private MsiManager(HttpPipeline httpPipeline, AzureProfile profile) {
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
.subscriptionId(profile.getSubscriptionId())
.buildClient());
- authorizationManager = AuthorizationManager.authenticate(httpPipeline, profile);
+ authorizationManager = AzureConfigurableImpl
+ .configureHttpPipeline(httpPipeline, AuthorizationManager.configure())
+ .authenticate(null, profile);
}
/**
diff --git a/sdk/resourcemanager/azure-resourcemanager-msi/src/test/java/com/azure/resourcemanager/msi/MSIIdentityManagementTests.java b/sdk/resourcemanager/azure-resourcemanager-msi/src/test/java/com/azure/resourcemanager/msi/MSIIdentityManagementTests.java
index f1780952acf76..a9591f9761591 100644
--- a/sdk/resourcemanager/azure-resourcemanager-msi/src/test/java/com/azure/resourcemanager/msi/MSIIdentityManagementTests.java
+++ b/sdk/resourcemanager/azure-resourcemanager-msi/src/test/java/com/azure/resourcemanager/msi/MSIIdentityManagementTests.java
@@ -60,7 +60,7 @@ protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
ResourceManagerUtils.InternalRuntimeContext internalContext = new ResourceManagerUtils.InternalRuntimeContext();
internalContext.setIdentifierFunction(name -> new TestIdentifierProvider(testResourceNamer));
- this.msiManager = MsiManager.authenticate(httpPipeline, profile);
+ this.msiManager = buildManager(MsiManager.class, httpPipeline, profile);
this.resourceManager = msiManager.resourceManager();
setInternalContext(internalContext, msiManager);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-network/pom.xml b/sdk/resourcemanager/azure-resourcemanager-network/pom.xml
index 445b4639497e5..843a37e5a79f0 100644
--- a/sdk/resourcemanager/azure-resourcemanager-network/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-network/pom.xml
@@ -122,6 +122,9 @@
+ --add-exports com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm.implementation=ALL-UNNAMED
+
+ --add-opens com.azure.resourcemanager.network/com.azure.resourcemanager.network=ALL-UNNAMED
--add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources=ALL-UNNAMED
--add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm=ALL-UNNAMED
diff --git a/sdk/resourcemanager/azure-resourcemanager-network/src/main/java/com/azure/resourcemanager/network/NetworkManager.java b/sdk/resourcemanager/azure-resourcemanager-network/src/main/java/com/azure/resourcemanager/network/NetworkManager.java
index 5562fedbc9fb7..316b1cf77af76 100644
--- a/sdk/resourcemanager/azure-resourcemanager-network/src/main/java/com/azure/resourcemanager/network/NetworkManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-network/src/main/java/com/azure/resourcemanager/network/NetworkManager.java
@@ -95,7 +95,7 @@ public static NetworkManager authenticate(TokenCredential credential, AzureProfi
* @param profile the profile to use
* @return the NetworkManager
*/
- public static NetworkManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static NetworkManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new NetworkManager(httpPipeline, profile);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-network/src/test/java/com/azure/resourcemanager/network/NetworkManagementTest.java b/sdk/resourcemanager/azure-resourcemanager-network/src/test/java/com/azure/resourcemanager/network/NetworkManagementTest.java
index d9ea16e1871bc..33bc063e932a4 100644
--- a/sdk/resourcemanager/azure-resourcemanager-network/src/test/java/com/azure/resourcemanager/network/NetworkManagementTest.java
+++ b/sdk/resourcemanager/azure-resourcemanager-network/src/test/java/com/azure/resourcemanager/network/NetworkManagementTest.java
@@ -53,11 +53,10 @@ protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile
ResourceManagerUtils.InternalRuntimeContext internalContext = new ResourceManagerUtils.InternalRuntimeContext();
internalContext.setIdentifierFunction(name -> new TestIdentifierProvider(testResourceNamer));
rgName = generateRandomResourceName("javanwmrg", 15);
- resourceManager =
- ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- networkManager = NetworkManager.authenticate(httpPipeline, profile);
- keyVaultManager = KeyVaultManager.authenticate(httpPipeline, profile);
- msiManager = MsiManager.authenticate(httpPipeline, profile);
+ networkManager = buildManager(NetworkManager.class, httpPipeline, profile);
+ keyVaultManager = buildManager(KeyVaultManager.class, httpPipeline, profile);
+ msiManager = buildManager(MsiManager.class, httpPipeline, profile);
+ resourceManager = networkManager.resourceManager();
setInternalContext(internalContext, networkManager);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-privatedns/pom.xml b/sdk/resourcemanager/azure-resourcemanager-privatedns/pom.xml
index 196686f65c418..86610121845d9 100644
--- a/sdk/resourcemanager/azure-resourcemanager-privatedns/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-privatedns/pom.xml
@@ -112,6 +112,8 @@
--add-exports com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm.collection.implementation=ALL-UNNAMED
--add-exports com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm.models.implementation=ALL-UNNAMED
+
+ --add-opens com.azure.resourcemanager.privatedns/com.azure.resourcemanager.privatedns=ALL-UNNAMED
diff --git a/sdk/resourcemanager/azure-resourcemanager-privatedns/src/main/java/com/azure/resourcemanager/privatedns/PrivateDnsZoneManager.java b/sdk/resourcemanager/azure-resourcemanager-privatedns/src/main/java/com/azure/resourcemanager/privatedns/PrivateDnsZoneManager.java
index 23b747f1babae..05bc818fc5681 100644
--- a/sdk/resourcemanager/azure-resourcemanager-privatedns/src/main/java/com/azure/resourcemanager/privatedns/PrivateDnsZoneManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-privatedns/src/main/java/com/azure/resourcemanager/privatedns/PrivateDnsZoneManager.java
@@ -46,7 +46,7 @@ public static PrivateDnsZoneManager authenticate(TokenCredential credential, Azu
* @param profile the profile to use
* @return the PrivateDnsZoneManager
*/
- public static PrivateDnsZoneManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static PrivateDnsZoneManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new PrivateDnsZoneManager(httpPipeline, profile);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-privatedns/src/test/java/com/azure/resourcemanager/privatedns/PrivateDnsZoneRecordSetETagTests.java b/sdk/resourcemanager/azure-resourcemanager-privatedns/src/test/java/com/azure/resourcemanager/privatedns/PrivateDnsZoneRecordSetETagTests.java
index 2fda3b647b450..4dd72d75b1f6d 100644
--- a/sdk/resourcemanager/azure-resourcemanager-privatedns/src/test/java/com/azure/resourcemanager/privatedns/PrivateDnsZoneRecordSetETagTests.java
+++ b/sdk/resourcemanager/azure-resourcemanager-privatedns/src/test/java/com/azure/resourcemanager/privatedns/PrivateDnsZoneRecordSetETagTests.java
@@ -56,9 +56,8 @@ protected HttpPipeline buildHttpPipeline(
@Override
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
- resourceManager =
- ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- privateZoneManager = PrivateDnsZoneManager.authenticate(httpPipeline, profile);
+ privateZoneManager = buildManager(PrivateDnsZoneManager.class, httpPipeline, profile);
+ resourceManager = privateZoneManager.resourceManager();
rgName = generateRandomResourceName("prdnsrstest", 15);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-privatedns/src/test/java/com/azure/resourcemanager/privatedns/VirtualNetworkLinkETagTests.java b/sdk/resourcemanager/azure-resourcemanager-privatedns/src/test/java/com/azure/resourcemanager/privatedns/VirtualNetworkLinkETagTests.java
index 77f24dfb677af..bcd7d741f7372 100644
--- a/sdk/resourcemanager/azure-resourcemanager-privatedns/src/test/java/com/azure/resourcemanager/privatedns/VirtualNetworkLinkETagTests.java
+++ b/sdk/resourcemanager/azure-resourcemanager-privatedns/src/test/java/com/azure/resourcemanager/privatedns/VirtualNetworkLinkETagTests.java
@@ -64,10 +64,9 @@ protected HttpPipeline buildHttpPipeline(
@Override
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
- resourceManager =
- ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- privateZoneManager = PrivateDnsZoneManager.authenticate(httpPipeline, profile);
- networkManager = NetworkManager.authenticate(httpPipeline, profile);
+ privateZoneManager = buildManager(PrivateDnsZoneManager.class, httpPipeline, profile);
+ networkManager = buildManager(NetworkManager.class, httpPipeline, profile);
+ resourceManager = privateZoneManager.resourceManager();
rgName = generateRandomResourceName("prdnsvnltest", 15);
topLevelDomain = "www.contoso" + generateRandomResourceName("z", 10) + ".com";
vnetName = generateRandomResourceName("prdnsvnet", 15);
diff --git a/sdk/resourcemanager/azure-resourcemanager-redis/pom.xml b/sdk/resourcemanager/azure-resourcemanager-redis/pom.xml
index b8186904d2805..e805d99bf46bb 100644
--- a/sdk/resourcemanager/azure-resourcemanager-redis/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-redis/pom.xml
@@ -118,6 +118,8 @@
--add-exports com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm.collection.implementation=ALL-UNNAMED
--add-exports com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm.models.implementation=ALL-UNNAMED
+
+ --add-opens com.azure.resourcemanager.redis/com.azure.resourcemanager.redis=ALL-UNNAMED
diff --git a/sdk/resourcemanager/azure-resourcemanager-redis/src/main/java/com/azure/resourcemanager/redis/RedisManager.java b/sdk/resourcemanager/azure-resourcemanager-redis/src/main/java/com/azure/resourcemanager/redis/RedisManager.java
index ac0e5e96b0996..c40942eb97944 100644
--- a/sdk/resourcemanager/azure-resourcemanager-redis/src/main/java/com/azure/resourcemanager/redis/RedisManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-redis/src/main/java/com/azure/resourcemanager/redis/RedisManager.java
@@ -47,7 +47,7 @@ public static RedisManager authenticate(TokenCredential credential, AzureProfile
* @param profile the profile to use
* @return the RedisManager
*/
- public static RedisManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static RedisManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new RedisManager(httpPipeline, profile);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-redis/src/test/java/com/azure/resourcemanager/redis/RedisManagementTest.java b/sdk/resourcemanager/azure-resourcemanager-redis/src/test/java/com/azure/resourcemanager/redis/RedisManagementTest.java
index 3ce111926be59..2e8df4135737c 100644
--- a/sdk/resourcemanager/azure-resourcemanager-redis/src/test/java/com/azure/resourcemanager/redis/RedisManagementTest.java
+++ b/sdk/resourcemanager/azure-resourcemanager-redis/src/test/java/com/azure/resourcemanager/redis/RedisManagementTest.java
@@ -60,10 +60,9 @@ protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile
saName = generateRandomResourceName("javacsmsa", 15);
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
- resourceManager =
- ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- redisManager = RedisManager.authenticate(httpPipeline, profile);
- storageManager = StorageManager.authenticate(httpPipeline, profile);
+ redisManager = buildManager(RedisManager.class, httpPipeline, profile);
+ storageManager = buildManager(StorageManager.class, httpPipeline, profile);
+ resourceManager = redisManager.resourceManager();
}
@Override
diff --git a/sdk/resourcemanager/azure-resourcemanager-resources/pom.xml b/sdk/resourcemanager/azure-resourcemanager-resources/pom.xml
index 60b58d785cff0..2cfe2cb862769 100644
--- a/sdk/resourcemanager/azure-resourcemanager-resources/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-resources/pom.xml
@@ -107,6 +107,27 @@
+
+ java-lts
+
+ [11,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M3
+
+
+
+ --add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources=ALL-UNNAMED
+
+
+
+
+
+
diff --git a/sdk/resourcemanager/azure-resourcemanager-resources/src/main/java/com/azure/resourcemanager/resources/ResourceManager.java b/sdk/resourcemanager/azure-resourcemanager-resources/src/main/java/com/azure/resourcemanager/resources/ResourceManager.java
index 58df17b4527dd..c554f11737d31 100644
--- a/sdk/resourcemanager/azure-resourcemanager-resources/src/main/java/com/azure/resourcemanager/resources/ResourceManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-resources/src/main/java/com/azure/resourcemanager/resources/ResourceManager.java
@@ -78,7 +78,7 @@ public static ResourceManager.Authenticated authenticate(TokenCredential credent
* @param profile the profile used in resource management
* @return the interface exposing resource management API entry points that work across subscriptions
*/
- public static ResourceManager.Authenticated authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static ResourceManager.Authenticated authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new AuthenticatedImpl(httpPipeline, profile);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-resources/src/main/java/com/azure/resourcemanager/resources/fluentcore/arm/Manager.java b/sdk/resourcemanager/azure-resourcemanager-resources/src/main/java/com/azure/resourcemanager/resources/fluentcore/arm/Manager.java
index 172ff92ed05d2..02bca749a872a 100644
--- a/sdk/resourcemanager/azure-resourcemanager-resources/src/main/java/com/azure/resourcemanager/resources/fluentcore/arm/Manager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-resources/src/main/java/com/azure/resourcemanager/resources/fluentcore/arm/Manager.java
@@ -7,6 +7,7 @@
import com.azure.core.management.AzureEnvironment;
import com.azure.core.management.profile.AzureProfile;
import com.azure.resourcemanager.resources.ResourceManager;
+import com.azure.resourcemanager.resources.fluentcore.arm.implementation.AzureConfigurableImpl;
import com.azure.resourcemanager.resources.fluentcore.model.HasServiceClient;
/**
@@ -25,7 +26,9 @@ public abstract class Manager implements HasServiceClient {
protected Manager(HttpPipeline httpPipeline, AzureProfile profile, InnerT innerManagementClient) {
this.httpPipeline = httpPipeline;
if (httpPipeline != null) {
- this.resourceManager = ResourceManager.authenticate(httpPipeline, profile)
+ this.resourceManager = AzureConfigurableImpl
+ .configureHttpPipeline(httpPipeline, ResourceManager.configure())
+ .authenticate(null, profile)
.withDefaultSubscription();
}
this.subscriptionId = profile.getSubscriptionId();
diff --git a/sdk/resourcemanager/azure-resourcemanager-resources/src/main/java/com/azure/resourcemanager/resources/fluentcore/arm/implementation/AzureConfigurableImpl.java b/sdk/resourcemanager/azure-resourcemanager-resources/src/main/java/com/azure/resourcemanager/resources/fluentcore/arm/implementation/AzureConfigurableImpl.java
index 0b0df7533f8f2..6ed9a5b82f51e 100644
--- a/sdk/resourcemanager/azure-resourcemanager-resources/src/main/java/com/azure/resourcemanager/resources/fluentcore/arm/implementation/AzureConfigurableImpl.java
+++ b/sdk/resourcemanager/azure-resourcemanager-resources/src/main/java/com/azure/resourcemanager/resources/fluentcore/arm/implementation/AzureConfigurableImpl.java
@@ -36,6 +36,22 @@ public class AzureConfigurableImpl>
private RetryPolicy retryPolicy;
private Configuration configuration;
private List tokens;
+ private HttpPipeline httpPipeline;
+
+ /**
+ * Configures the http pipeline.
+ * (Internal use only)
+ *
+ * @param httpPipeline the http pipeline
+ * @param azureConfigurable the azure configurable instance
+ * @param the type of azure configurable
+ * @return the azure configurable instance
+ */
+ public static > T configureHttpPipeline(HttpPipeline httpPipeline,
+ T azureConfigurable) {
+ ((AzureConfigurableImpl) azureConfigurable).withHttpPipeline(httpPipeline);
+ return azureConfigurable;
+ }
protected AzureConfigurableImpl() {
policies = new ArrayList<>();
@@ -125,7 +141,22 @@ public T withConfiguration(Configuration configuration) {
return (T) this;
}
+ /**
+ * Sets the http pipeline.
+ * (Internal use only)
+ *
+ * @param httpPipeline the http pipeline
+ */
+ public void withHttpPipeline(HttpPipeline httpPipeline) {
+ Objects.requireNonNull(httpPipeline);
+ this.httpPipeline = httpPipeline;
+ }
+
protected HttpPipeline buildHttpPipeline(TokenCredential credential, AzureProfile profile) {
+ // Check if this is internal build to make sure all managers could share same http pipeline in each module.
+ if (this.httpPipeline != null) {
+ return httpPipeline;
+ }
Objects.requireNonNull(credential);
if (!tokens.isEmpty()) {
policies.add(
diff --git a/sdk/resourcemanager/azure-resourcemanager-resources/src/test/java/com/azure/resourcemanager/resources/ResourceManagementTest.java b/sdk/resourcemanager/azure-resourcemanager-resources/src/test/java/com/azure/resourcemanager/resources/ResourceManagementTest.java
index 8f7f9c786dc79..4bb52b7e00f4f 100644
--- a/sdk/resourcemanager/azure-resourcemanager-resources/src/test/java/com/azure/resourcemanager/resources/ResourceManagementTest.java
+++ b/sdk/resourcemanager/azure-resourcemanager-resources/src/test/java/com/azure/resourcemanager/resources/ResourceManagementTest.java
@@ -45,9 +45,7 @@ protected HttpPipeline buildHttpPipeline(
@Override
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
- resourceClient = ResourceManager
- .authenticate(httpPipeline, profile)
- .withDefaultSubscription();
+ resourceClient = buildManager(ResourceManager.class, httpPipeline, profile);
}
@Override
diff --git a/sdk/resourcemanager/azure-resourcemanager-resources/src/test/java/com/azure/resourcemanager/resources/SubscriptionsTests.java b/sdk/resourcemanager/azure-resourcemanager-resources/src/test/java/com/azure/resourcemanager/resources/SubscriptionsTests.java
index 742c0dd3a4897..9d35f872a4420 100644
--- a/sdk/resourcemanager/azure-resourcemanager-resources/src/test/java/com/azure/resourcemanager/resources/SubscriptionsTests.java
+++ b/sdk/resourcemanager/azure-resourcemanager-resources/src/test/java/com/azure/resourcemanager/resources/SubscriptionsTests.java
@@ -3,41 +3,23 @@
package com.azure.resourcemanager.resources;
-import com.azure.core.http.HttpPipeline;
import com.azure.core.http.rest.PagedIterable;
-import com.azure.resourcemanager.test.utils.TestUtilities;
-import com.azure.core.management.profile.AzureProfile;
-import com.azure.resourcemanager.resources.fluentcore.utils.ResourceManagerUtils;
import com.azure.resourcemanager.resources.models.Location;
import com.azure.resourcemanager.resources.models.Subscription;
-import com.azure.resourcemanager.test.utils.TestDelayProvider;
+import com.azure.resourcemanager.test.utils.TestUtilities;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class SubscriptionsTests extends ResourceManagementTest {
- protected ResourceManager.Authenticated resourceManager;
-
- @Override
- protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
- ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
- resourceManager = ResourceManager
- .authenticate(httpPipeline, profile);
- }
-
- @Override
- protected void cleanUpResources() {
-
- }
-
@Test
- public void canListSubscriptions() throws Exception {
- PagedIterable subscriptions = resourceManager.subscriptions().list();
+ public void canListSubscriptions() {
+ PagedIterable subscriptions = resourceClient.subscriptions().list();
Assertions.assertTrue(TestUtilities.getSize(subscriptions) > 0);
}
@Test
- public void canListLocations() throws Exception {
- PagedIterable locations = resourceManager.subscriptions().list().iterator().next().listLocations();
+ public void canListLocations() {
+ PagedIterable locations = resourceClient.subscriptions().list().iterator().next().listLocations();
Assertions.assertTrue(TestUtilities.getSize(locations) > 0);
}
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-resources/src/test/java/com/azure/resourcemanager/resources/TenantsTests.java b/sdk/resourcemanager/azure-resourcemanager-resources/src/test/java/com/azure/resourcemanager/resources/TenantsTests.java
index f0af8cc48a441..99227fc48202b 100644
--- a/sdk/resourcemanager/azure-resourcemanager-resources/src/test/java/com/azure/resourcemanager/resources/TenantsTests.java
+++ b/sdk/resourcemanager/azure-resourcemanager-resources/src/test/java/com/azure/resourcemanager/resources/TenantsTests.java
@@ -3,34 +3,16 @@
package com.azure.resourcemanager.resources;
-import com.azure.core.http.HttpPipeline;
import com.azure.core.http.rest.PagedIterable;
-import com.azure.resourcemanager.resources.fluentcore.utils.ResourceManagerUtils;
-import com.azure.resourcemanager.test.utils.TestUtilities;
-import com.azure.core.management.profile.AzureProfile;
import com.azure.resourcemanager.resources.fluent.models.TenantIdDescriptionInner;
-import com.azure.resourcemanager.test.utils.TestDelayProvider;
+import com.azure.resourcemanager.test.utils.TestUtilities;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;
public class TenantsTests extends ResourceManagementTest {
- protected ResourceManager.Authenticated resourceManager;
-
- @Override
- protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
- ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
- resourceManager = ResourceManager
- .authenticate(httpPipeline, profile);
- }
-
- @Override
- protected void cleanUpResources() {
-
- }
-
@Test
public void canListTenants() throws Exception {
- PagedIterable tenants = resourceManager.tenants().list();
+ PagedIterable tenants = resourceClient.tenants().list();
Assertions.assertTrue(TestUtilities.getSize(tenants) > 0);
}
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-samples/src/main/java/com/azure/resourcemanager/authorization/samples/ManageServicePrincipalCredentials.java b/sdk/resourcemanager/azure-resourcemanager-samples/src/main/java/com/azure/resourcemanager/authorization/samples/ManageServicePrincipalCredentials.java
index a7e83282d0a58..68272e92879d0 100644
--- a/sdk/resourcemanager/azure-resourcemanager-samples/src/main/java/com/azure/resourcemanager/authorization/samples/ManageServicePrincipalCredentials.java
+++ b/sdk/resourcemanager/azure-resourcemanager-samples/src/main/java/com/azure/resourcemanager/authorization/samples/ManageServicePrincipalCredentials.java
@@ -35,20 +35,20 @@ public final class ManageServicePrincipalCredentials {
/**
* Main function which runs the actual sample.
*
- * @param authenticated instance of Authenticated
+ * @param azureResourceManager instance of AzureResourceManager
* @param profile the profile the sample is running in
* @return true if sample runs successfully
*/
- public static boolean runSample(AzureResourceManager.Authenticated authenticated, AzureProfile profile) throws IOException {
- final String spName = Utils.randomResourceName(authenticated, "sp", 20);
- final String appName = Utils.randomResourceName(authenticated, "app", 20);
+ public static boolean runSample(AzureResourceManager azureResourceManager, AzureProfile profile) throws IOException {
+ final String spName = Utils.randomResourceName(azureResourceManager, "sp", 20);
+ final String appName = Utils.randomResourceName(azureResourceManager, "app", 20);
final String appUrl = "https://" + appName;
- final String passwordName1 = Utils.randomResourceName(authenticated, "password", 20);
+ final String passwordName1 = Utils.randomResourceName(azureResourceManager, "password", 20);
final String password1 = "P@ssw0rd";
- final String passwordName2 = Utils.randomResourceName(authenticated, "password", 20);
+ final String passwordName2 = Utils.randomResourceName(azureResourceManager, "password", 20);
final String password2 = "StrongP@ss!12";
- final String certName1 = Utils.randomResourceName(authenticated, "cert", 20);
- final String raName = Utils.randomUuid(authenticated);
+ final String certName1 = Utils.randomResourceName(azureResourceManager, "cert", 20);
+ final String raName = Utils.randomUuid(azureResourceManager);
String servicePrincipalId = "";
try {
// ============================================================
@@ -56,7 +56,7 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
System.out.println("Creating an Active Directory service principal " + spName + "...");
- ServicePrincipal servicePrincipal = authenticated.servicePrincipals()
+ ServicePrincipal servicePrincipal = azureResourceManager.accessManagement().servicePrincipals()
.define(spName)
.withNewApplication(appUrl)
.definePasswordCredential(passwordName1)
@@ -83,7 +83,7 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
ResourceManagerUtils.sleep(Duration.ofSeconds(15));
- RoleAssignment roleAssignment = authenticated.roleAssignments()
+ RoleAssignment roleAssignment = azureResourceManager.accessManagement().roleAssignments()
.define(raName)
.forServicePrincipal(servicePrincipal)
.withBuiltInRole(BuiltInRole.CONTRIBUTOR)
@@ -99,7 +99,7 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
System.out.println("Verifying password credential " + passwordName1 + " is valid...");
TokenCredential testCredential = new ClientSecretCredentialBuilder()
- .tenantId(authenticated.tenantId())
+ .tenantId(azureResourceManager.tenantId())
.clientId(servicePrincipal.applicationId())
.clientSecret(password1)
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
@@ -115,7 +115,7 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
System.out.println("Verifying password credential " + passwordName2 + " is valid...");
testCredential = new ClientSecretCredentialBuilder()
- .tenantId(authenticated.tenantId())
+ .tenantId(azureResourceManager.tenantId())
.clientId(servicePrincipal.applicationId())
.clientSecret(password2)
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
@@ -131,7 +131,7 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
System.out.println("Verifying certificate credential " + certName1 + " is valid...");
testCredential = new ClientCertificateCredentialBuilder()
- .tenantId(authenticated.tenantId())
+ .tenantId(azureResourceManager.tenantId())
.clientId(servicePrincipal.applicationId())
.pfxCertificate(ManageServicePrincipalCredentials.class.getResource("/myTest.pfx").toString(), "Abc123")
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
@@ -162,7 +162,7 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
System.out.println("Verifying password credential " + passwordName1 + " is revoked...");
testCredential = new ClientSecretCredentialBuilder()
- .tenantId(authenticated.tenantId())
+ .tenantId(azureResourceManager.tenantId())
.clientId(servicePrincipal.applicationId())
.clientSecret(password1)
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
@@ -180,7 +180,7 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
System.out.println("Revoking role assignment " + raName + "...");
- authenticated.roleAssignments().deleteById(roleAssignment.id());
+ azureResourceManager.accessManagement().roleAssignments().deleteById(roleAssignment.id());
ResourceManagerUtils.sleep(Duration.ofSeconds(5));
@@ -190,7 +190,7 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
System.out.println("Verifying password credential " + passwordName2 + " has no access to subscription...");
testCredential = new ClientSecretCredentialBuilder()
- .tenantId(authenticated.tenantId())
+ .tenantId(azureResourceManager.tenantId())
.clientId(servicePrincipal.applicationId())
.clientSecret(password2)
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
@@ -209,7 +209,7 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
} finally {
try {
System.out.println("Deleting application: " + appName);
- authenticated.servicePrincipals().deleteById(servicePrincipalId);
+ azureResourceManager.accessManagement().servicePrincipals().deleteById(servicePrincipalId);
System.out.println("Deleted application: " + appName);
} catch (Exception e) {
System.out.println("Did not create applications in Azure. No clean up is necessary");
@@ -229,11 +229,13 @@ public static void main(String[] args) {
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
.build();
- AzureResourceManager.Authenticated authenticated = AzureResourceManager
+ AzureResourceManager azureResourceManager = AzureResourceManager
.configure()
.withLogLevel(HttpLogDetailLevel.BASIC)
- .authenticate(credential, profile);
- runSample(authenticated, profile);
+ .authenticate(credential, profile)
+ .withDefaultSubscription();
+
+ runSample(azureResourceManager, profile);
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
diff --git a/sdk/resourcemanager/azure-resourcemanager-samples/src/main/java/com/azure/resourcemanager/authorization/samples/ManageUsersGroupsAndRoles.java b/sdk/resourcemanager/azure-resourcemanager-samples/src/main/java/com/azure/resourcemanager/authorization/samples/ManageUsersGroupsAndRoles.java
index b98c44e037419..4722838f808b2 100644
--- a/sdk/resourcemanager/azure-resourcemanager-samples/src/main/java/com/azure/resourcemanager/authorization/samples/ManageUsersGroupsAndRoles.java
+++ b/sdk/resourcemanager/azure-resourcemanager-samples/src/main/java/com/azure/resourcemanager/authorization/samples/ManageUsersGroupsAndRoles.java
@@ -35,18 +35,18 @@ public final class ManageUsersGroupsAndRoles {
/**
* Main function which runs the actual sample.
*
- * @param authenticated instance of Authenticated
+ * @param azureResourceManager instance of AzureResourceManager
* @param profile the profile works with sample
* @return true if sample runs successfully
*/
- public static boolean runSample(AzureResourceManager.Authenticated authenticated, AzureProfile profile) {
- final String userEmail = Utils.randomResourceName(authenticated, "test", 15);
+ public static boolean runSample(AzureResourceManager azureResourceManager, AzureProfile profile) {
+ final String userEmail = Utils.randomResourceName(azureResourceManager, "test", 15);
final String userName = userEmail.replace("test", "Test ");
- final String spName = Utils.randomResourceName(authenticated, "sp", 15);
- final String raName1 = Utils.randomUuid(authenticated);
- final String raName2 = Utils.randomUuid(authenticated);
- final String groupEmail1 = Utils.randomResourceName(authenticated, "group1", 15);
- final String groupEmail2 = Utils.randomResourceName(authenticated, "group2", 15);
+ final String spName = Utils.randomResourceName(azureResourceManager, "sp", 15);
+ final String raName1 = Utils.randomUuid(azureResourceManager);
+ final String raName2 = Utils.randomUuid(azureResourceManager);
+ final String groupEmail1 = Utils.randomResourceName(azureResourceManager, "group1", 15);
+ final String groupEmail2 = Utils.randomResourceName(azureResourceManager, "group2", 15);
final String groupName1 = groupEmail1.replace("group1", "Group ");
final String groupName2 = groupEmail2.replace("group2", "Group ");
String spId = "";
@@ -56,7 +56,7 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
System.out.println("Creating an AD user " + userName + "...");
- ActiveDirectoryUser user = authenticated.activeDirectoryUsers()
+ ActiveDirectoryUser user = azureResourceManager.accessManagement().activeDirectoryUsers()
.define(userName)
.withEmailAlias(userEmail)
.withPassword("StrongPass!12")
@@ -68,7 +68,7 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
// ============================================================
// Assign role to AD user
- RoleAssignment roleAssignment1 = authenticated.roleAssignments()
+ RoleAssignment roleAssignment1 = azureResourceManager.accessManagement().roleAssignments()
.define(raName1)
.forUser(user)
.withBuiltInRole(BuiltInRole.READER)
@@ -80,20 +80,20 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
// ============================================================
// Revoke role from AD user
- authenticated.roleAssignments().deleteById(roleAssignment1.id());
+ azureResourceManager.accessManagement().roleAssignments().deleteById(roleAssignment1.id());
System.out.println("Revoked Role Assignment: " + roleAssignment1.id());
// ============================================================
// Get role by scope and role name
- RoleDefinition roleDefinition = authenticated.roleDefinitions()
+ RoleDefinition roleDefinition = azureResourceManager.accessManagement().roleDefinitions()
.getByScopeAndRoleName("subscriptions/" + profile.getSubscriptionId(), "Contributor");
Utils.print(roleDefinition);
// ============================================================
// Create Service Principal
- ServicePrincipal sp = authenticated.servicePrincipals().define(spName)
+ ServicePrincipal sp = azureResourceManager.accessManagement().servicePrincipals().define(spName)
.withNewApplication("http://" + spName)
.create();
// wait till service principal created and propagated
@@ -105,7 +105,7 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
// ============================================================
// Assign role to Service Principal
- RoleAssignment roleAssignment2 = authenticated.roleAssignments()
+ RoleAssignment roleAssignment2 = azureResourceManager.accessManagement().roleAssignments()
.define(raName2)
.forServicePrincipal(sp)
.withBuiltInRole(BuiltInRole.CONTRIBUTOR)
@@ -118,7 +118,7 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
// Create Active Directory groups
System.out.println("Creating Active Directory group " + groupName1 + "...");
- ActiveDirectoryGroup group1 = authenticated.activeDirectoryGroups()
+ ActiveDirectoryGroup group1 = azureResourceManager.accessManagement().activeDirectoryGroups()
.define(groupName1)
.withEmailAlias(groupEmail1)
.create();
@@ -127,7 +127,7 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
Utils.print(group1);
System.out.println("Creating Active Directory group " + groupName2 + "...");
- ActiveDirectoryGroup group2 = authenticated.activeDirectoryGroups()
+ ActiveDirectoryGroup group2 = azureResourceManager.accessManagement().activeDirectoryGroups()
.define(groupName2)
.withEmailAlias(groupEmail2)
.create();
@@ -148,7 +148,7 @@ public static boolean runSample(AzureResourceManager.Authenticated authenticated
} finally {
try {
System.out.println("Deleting Service Principal: " + spName);
- authenticated.servicePrincipals().deleteById(spId);
+ azureResourceManager.accessManagement().servicePrincipals().deleteById(spId);
System.out.println("Deleted Service Principal: " + spName);
} catch (Exception e) {
System.out.println("Did not create Service Principal in Azure. No clean up is necessary");
@@ -168,11 +168,13 @@ public static void main(String[] args) {
.authorityHost(profile.getEnvironment().getActiveDirectoryEndpoint())
.build();
- AzureResourceManager.Authenticated authenticated = AzureResourceManager
+ AzureResourceManager azureResourceManager = AzureResourceManager
.configure()
.withLogLevel(HttpLogDetailLevel.BASIC)
- .authenticate(credential, profile);
- runSample(authenticated, profile);
+ .authenticate(credential, profile)
+ .withDefaultSubscription();
+
+ runSample(azureResourceManager, profile);
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
diff --git a/sdk/resourcemanager/azure-resourcemanager-samples/src/main/java/com/azure/resourcemanager/samples/Utils.java b/sdk/resourcemanager/azure-resourcemanager-samples/src/main/java/com/azure/resourcemanager/samples/Utils.java
index 029918d630648..c913261f2413e 100644
--- a/sdk/resourcemanager/azure-resourcemanager-samples/src/main/java/com/azure/resourcemanager/samples/Utils.java
+++ b/sdk/resourcemanager/azure-resourcemanager-samples/src/main/java/com/azure/resourcemanager/samples/Utils.java
@@ -301,17 +301,6 @@ public static String randomResourceName(AzureResourceManager.Authenticated authe
return authenticated.roleAssignments().manager().internalContext().randomResourceName(prefix, maxLen);
}
- /**
- * Creates a random UUID.
- * Please provider your own implementation, or avoid using the method, if code is to be used in production.
- *
- * @param authenticated the AzureResourceManager.Authenticated instance.
- * @return the random UUID.
- */
- public static String randomUuid(AzureResourceManager.Authenticated authenticated) {
- return authenticated.roleAssignments().manager().internalContext().randomUuid();
- }
-
/**
* Print resource group info.
*
diff --git a/sdk/resourcemanager/azure-resourcemanager-samples/src/test/java/com/azure/resourcemanager/samples/AppServiceSampleLiveOnlyTests.java b/sdk/resourcemanager/azure-resourcemanager-samples/src/test/java/com/azure/resourcemanager/samples/AppServiceSampleLiveOnlyTests.java
index 984a112df89ac..3932cac0f16e0 100644
--- a/sdk/resourcemanager/azure-resourcemanager-samples/src/test/java/com/azure/resourcemanager/samples/AppServiceSampleLiveOnlyTests.java
+++ b/sdk/resourcemanager/azure-resourcemanager-samples/src/test/java/com/azure/resourcemanager/samples/AppServiceSampleLiveOnlyTests.java
@@ -142,11 +142,11 @@ public void testManageFunctionAppLogs() throws IOException {
if (skipInPlayback()) {
return;
}
- azureResourceManager = AzureResourceManager.authenticate(
+ azureResourceManager = buildManager(
+ AzureResourceManager.class,
setReadTimeout(azureResourceManager.storageAccounts().manager().httpPipeline(), Duration.ofMinutes(10)),
new AzureProfile(azureResourceManager.tenantId(), azureResourceManager.subscriptionId(), AzureEnvironment.AZURE)
- )
- .withDefaultSubscription();
+ );
Assertions.assertTrue(ManageFunctionAppLogs.runSample(azureResourceManager));
}
@@ -156,11 +156,11 @@ public void testManageWebAppLogs() throws IOException {
if (skipInPlayback()) {
return;
}
- azureResourceManager = AzureResourceManager.authenticate(
+ azureResourceManager = buildManager(
+ AzureResourceManager.class,
setReadTimeout(azureResourceManager.storageAccounts().manager().httpPipeline(), Duration.ofMinutes(10)),
new AzureProfile(azureResourceManager.tenantId(), azureResourceManager.subscriptionId(), AzureEnvironment.AZURE)
- )
- .withDefaultSubscription();
+ );
Assertions.assertTrue(ManageWebAppLogs.runSample(azureResourceManager));
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-samples/src/test/java/com/azure/resourcemanager/samples/GraphRbacTests.java b/sdk/resourcemanager/azure-resourcemanager-samples/src/test/java/com/azure/resourcemanager/samples/GraphRbacTests.java
index e4568c0f2002f..996002dccbd30 100644
--- a/sdk/resourcemanager/azure-resourcemanager-samples/src/test/java/com/azure/resourcemanager/samples/GraphRbacTests.java
+++ b/sdk/resourcemanager/azure-resourcemanager-samples/src/test/java/com/azure/resourcemanager/samples/GraphRbacTests.java
@@ -24,7 +24,7 @@
import java.util.List;
public class GraphRbacTests extends ResourceManagerTestBase {
- private AzureResourceManager.Authenticated authenticated;
+ private AzureResourceManager azureResourceManager;
private AzureProfile profile;
@Test
@@ -34,7 +34,7 @@ public void testManageUsersGroupsAndRoles() {
return;
}
- Assertions.assertTrue(ManageUsersGroupsAndRoles.runSample(authenticated, profile));
+ Assertions.assertTrue(ManageUsersGroupsAndRoles.runSample(azureResourceManager, profile));
}
// @Test
@@ -49,7 +49,7 @@ public void testManageServicePrincipalCredentials() throws IOException {
return;
}
- Assertions.assertTrue(ManageServicePrincipalCredentials.runSample(authenticated, profile));
+ Assertions.assertTrue(ManageServicePrincipalCredentials.runSample(azureResourceManager, profile));
}
@Override
@@ -72,7 +72,7 @@ protected HttpPipeline buildHttpPipeline(
@Override
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
- authenticated = AzureResourceManager.authenticate(httpPipeline, profile);
+ azureResourceManager = buildManager(AzureResourceManager.class, httpPipeline, profile);
this.profile = profile;
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-samples/src/test/java/com/azure/resourcemanager/samples/SamplesTestBase.java b/sdk/resourcemanager/azure-resourcemanager-samples/src/test/java/com/azure/resourcemanager/samples/SamplesTestBase.java
index 9c6b9b172c2c1..c1b00fe1ec4f2 100644
--- a/sdk/resourcemanager/azure-resourcemanager-samples/src/test/java/com/azure/resourcemanager/samples/SamplesTestBase.java
+++ b/sdk/resourcemanager/azure-resourcemanager-samples/src/test/java/com/azure/resourcemanager/samples/SamplesTestBase.java
@@ -46,9 +46,7 @@ protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
ResourceManagerUtils.InternalRuntimeContext internalContext = new ResourceManagerUtils.InternalRuntimeContext();
internalContext.setIdentifierFunction(name -> new TestIdentifierProvider(testResourceNamer));
- azureResourceManager = AzureResourceManager
- .authenticate(httpPipeline, profile)
- .withDefaultSubscription();
+ azureResourceManager = buildManager(AzureResourceManager.class, httpPipeline, profile);
setInternalContext(internalContext, azureResourceManager);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-servicebus/pom.xml b/sdk/resourcemanager/azure-resourcemanager-servicebus/pom.xml
index 9095fb2ad7474..7ed320b32da8e 100644
--- a/sdk/resourcemanager/azure-resourcemanager-servicebus/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-servicebus/pom.xml
@@ -90,6 +90,27 @@
+
+ java-lts
+
+ [11,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M3
+
+
+
+ --add-opens com.azure.resourcemanager.servicebus/com.azure.resourcemanager.servicebus=ALL-UNNAMED
+
+
+
+
+
+
diff --git a/sdk/resourcemanager/azure-resourcemanager-servicebus/src/main/java/com/azure/resourcemanager/servicebus/ServiceBusManager.java b/sdk/resourcemanager/azure-resourcemanager-servicebus/src/main/java/com/azure/resourcemanager/servicebus/ServiceBusManager.java
index 8d3a137c4f1c2..4b8c915be023e 100644
--- a/sdk/resourcemanager/azure-resourcemanager-servicebus/src/main/java/com/azure/resourcemanager/servicebus/ServiceBusManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-servicebus/src/main/java/com/azure/resourcemanager/servicebus/ServiceBusManager.java
@@ -49,7 +49,7 @@ public static ServiceBusManager authenticate(TokenCredential credential, AzurePr
* @param profile the profile to use
* @return the ServiceBusManager
*/
- public static ServiceBusManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static ServiceBusManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new ServiceBusManager(httpPipeline, profile);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-servicebus/src/test/java/com/azure/resourcemanager/servicebus/ServiceBusOperationsTests.java b/sdk/resourcemanager/azure-resourcemanager-servicebus/src/test/java/com/azure/resourcemanager/servicebus/ServiceBusOperationsTests.java
index b59e8c85d2301..2e4da8416f169 100644
--- a/sdk/resourcemanager/azure-resourcemanager-servicebus/src/test/java/com/azure/resourcemanager/servicebus/ServiceBusOperationsTests.java
+++ b/sdk/resourcemanager/azure-resourcemanager-servicebus/src/test/java/com/azure/resourcemanager/servicebus/ServiceBusOperationsTests.java
@@ -68,8 +68,8 @@ protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile
rgName = generateRandomResourceName("javasb", 20);
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
- resourceManager = ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- serviceBusManager = ServiceBusManager.authenticate(httpPipeline, profile);
+ serviceBusManager = buildManager(ServiceBusManager.class, httpPipeline, profile);
+ resourceManager = serviceBusManager.resourceManager();
}
@Override
diff --git a/sdk/resourcemanager/azure-resourcemanager-sql/pom.xml b/sdk/resourcemanager/azure-resourcemanager-sql/pom.xml
index 66fc5b24607c1..a91cd0e1fd2c2 100644
--- a/sdk/resourcemanager/azure-resourcemanager-sql/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-sql/pom.xml
@@ -118,6 +118,7 @@
--add-opens com.azure.resourcemanager.sql/com.azure.resourcemanager.sql=ALL-UNNAMED
--add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources=ALL-UNNAMED
--add-opens com.azure.resourcemanager.resources/com.azure.resourcemanager.resources.fluentcore.arm=ALL-UNNAMED
+ --add-opens com.azure.resourcemanager.storage/com.azure.resourcemanager.storage=ALL-UNNAMED
diff --git a/sdk/resourcemanager/azure-resourcemanager-sql/src/main/java/com/azure/resourcemanager/sql/SqlServerManager.java b/sdk/resourcemanager/azure-resourcemanager-sql/src/main/java/com/azure/resourcemanager/sql/SqlServerManager.java
index ec4607a95a4ed..5a51066bd5c6e 100644
--- a/sdk/resourcemanager/azure-resourcemanager-sql/src/main/java/com/azure/resourcemanager/sql/SqlServerManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-sql/src/main/java/com/azure/resourcemanager/sql/SqlServerManager.java
@@ -32,7 +32,8 @@ protected SqlServerManager(HttpPipeline httpPipeline, AzureProfile profile) {
.subscriptionId(profile.getSubscriptionId())
.endpoint(profile.getEnvironment().getResourceManagerEndpoint())
.buildClient());
- this.storageManager = StorageManager.authenticate(httpPipeline, profile);
+ this.storageManager = AzureConfigurableImpl.configureHttpPipeline(httpPipeline, StorageManager.configure())
+ .authenticate(null, profile);
this.tenantId = profile.getTenantId();
}
@@ -68,7 +69,7 @@ public static SqlServerManager authenticate(TokenCredential credential, AzurePro
* @param profile the profile to use
* @return the SqlServer
*/
- public static SqlServerManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static SqlServerManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new SqlServerManager(httpPipeline, profile);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-sql/src/test/java/com/azure/resourcemanager/sql/SqlServerTest.java b/sdk/resourcemanager/azure-resourcemanager-sql/src/test/java/com/azure/resourcemanager/sql/SqlServerTest.java
index 54687440ef5d3..7aac5c94b21e1 100644
--- a/sdk/resourcemanager/azure-resourcemanager-sql/src/test/java/com/azure/resourcemanager/sql/SqlServerTest.java
+++ b/sdk/resourcemanager/azure-resourcemanager-sql/src/test/java/com/azure/resourcemanager/sql/SqlServerTest.java
@@ -54,10 +54,9 @@ protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
ResourceManagerUtils.InternalRuntimeContext internalContext = new ResourceManagerUtils.InternalRuntimeContext();
internalContext.setIdentifierFunction(name -> new TestIdentifierProvider(testResourceNamer));
- resourceManager =
- ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- sqlServerManager = SqlServerManager.authenticate(httpPipeline, profile);
- storageManager = StorageManager.authenticate(httpPipeline, profile);
+ sqlServerManager = buildManager(SqlServerManager.class, httpPipeline, profile);
+ storageManager = buildManager(StorageManager.class, httpPipeline, profile);
+ resourceManager = sqlServerManager.resourceManager();
setInternalContext(internalContext, sqlServerManager);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-storage/pom.xml b/sdk/resourcemanager/azure-resourcemanager-storage/pom.xml
index dddd99b2cb566..0f68f848f79f3 100644
--- a/sdk/resourcemanager/azure-resourcemanager-storage/pom.xml
+++ b/sdk/resourcemanager/azure-resourcemanager-storage/pom.xml
@@ -90,6 +90,27 @@
+
+ java-lts
+
+ [11,)
+
+
+
+
+ org.apache.maven.plugins
+ maven-surefire-plugin
+ 3.0.0-M3
+
+
+
+ --add-opens com.azure.resourcemanager.storage/com.azure.resourcemanager.storage=ALL-UNNAMED
+
+
+
+
+
+
diff --git a/sdk/resourcemanager/azure-resourcemanager-storage/src/main/java/com/azure/resourcemanager/storage/StorageManager.java b/sdk/resourcemanager/azure-resourcemanager-storage/src/main/java/com/azure/resourcemanager/storage/StorageManager.java
index 9efa0911f8342..aaf35b24f68ed 100644
--- a/sdk/resourcemanager/azure-resourcemanager-storage/src/main/java/com/azure/resourcemanager/storage/StorageManager.java
+++ b/sdk/resourcemanager/azure-resourcemanager-storage/src/main/java/com/azure/resourcemanager/storage/StorageManager.java
@@ -62,7 +62,7 @@ public static StorageManager authenticate(TokenCredential credential, AzureProfi
* @param profile the profile to use
* @return the StorageManager
*/
- public static StorageManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
+ private static StorageManager authenticate(HttpPipeline httpPipeline, AzureProfile profile) {
return new StorageManager(httpPipeline, profile);
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-storage/src/test/java/com/azure/resourcemanager/storage/StorageManagementTest.java b/sdk/resourcemanager/azure-resourcemanager-storage/src/test/java/com/azure/resourcemanager/storage/StorageManagementTest.java
index 6628a20ac416a..af4299e253c54 100644
--- a/sdk/resourcemanager/azure-resourcemanager-storage/src/test/java/com/azure/resourcemanager/storage/StorageManagementTest.java
+++ b/sdk/resourcemanager/azure-resourcemanager-storage/src/test/java/com/azure/resourcemanager/storage/StorageManagementTest.java
@@ -45,8 +45,7 @@ protected HttpPipeline buildHttpPipeline(
@Override
protected void initializeClients(HttpPipeline httpPipeline, AzureProfile profile) {
ResourceManagerUtils.InternalRuntimeContext.setDelayProvider(new TestDelayProvider(!isPlaybackMode()));
- resourceManager =
- ResourceManager.authenticate(httpPipeline, profile).withDefaultSubscription();
- storageManager = StorageManager.authenticate(httpPipeline, profile);
+ storageManager = buildManager(StorageManager.class, httpPipeline, profile);
+ resourceManager = storageManager.resourceManager();
}
}
diff --git a/sdk/resourcemanager/azure-resourcemanager-test/src/main/java/com/azure/resourcemanager/test/ResourceManagerTestBase.java b/sdk/resourcemanager/azure-resourcemanager-test/src/main/java/com/azure/resourcemanager/test/ResourceManagerTestBase.java
index 1986e9974f629..75096598e7f6d 100644
--- a/sdk/resourcemanager/azure-resourcemanager-test/src/main/java/com/azure/resourcemanager/test/ResourceManagerTestBase.java
+++ b/sdk/resourcemanager/azure-resourcemanager-test/src/main/java/com/azure/resourcemanager/test/ResourceManagerTestBase.java
@@ -28,7 +28,9 @@
import java.io.OutputStream;
import java.io.PrintStream;
import java.io.UnsupportedEncodingException;
+import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
import java.net.InetSocketAddress;
import java.net.Proxy;
import java.net.ProxySelector;
@@ -283,10 +285,10 @@ private void addTextReplacementRules(Map rules) {
*
* @param internalContext the internal runtime context
* @param objects the manager classes to change internal context
- * @param the type of internal context
+ * @param the type of internal context
* @throws RuntimeException when field cannot be found or set.
*/
- protected void setInternalContext(InternalContext internalContext, Object... objects) {
+ protected void setInternalContext(T internalContext, Object... objects) {
try {
for (Object obj : objects) {
for (final Field field : obj.getClass().getSuperclass().getDeclaredFields()) {
@@ -321,6 +323,33 @@ private void setAccessible(final Field field) {
});
}
+ /**
+ * Builds the manager with provided http pipeline and profile in general manner.
+ *
+ * @param manager the class of the manager
+ * @param httpPipeline the http pipeline
+ * @param profile the azure profile
+ * @param the type of the manager
+ * @return the manager instance
+ * @throws RuntimeException when field cannot be found or set.
+ */
+ protected T buildManager(Class manager, HttpPipeline httpPipeline, AzureProfile profile) {
+ try {
+ Constructor constructor = manager.getDeclaredConstructor(httpPipeline.getClass(), profile.getClass());
+ AccessController.doPrivileged((PrivilegedAction