diff --git a/sdk/appservice/mgmt/src/test/java/com/azure/management/appservice/WarDeployTests.java b/sdk/appservice/mgmt/src/test/java/com/azure/management/appservice/WarDeployTests.java index 7c31bafcbacf4..8e728e269c5fe 100644 --- a/sdk/appservice/mgmt/src/test/java/com/azure/management/appservice/WarDeployTests.java +++ b/sdk/appservice/mgmt/src/test/java/com/azure/management/appservice/WarDeployTests.java @@ -79,7 +79,7 @@ public void canDeployMultipleWars() throws Exception { Assertions.assertNotNull(body); Assertions.assertTrue(body.contains("Azure Samples Hello World")); - response = curl("http://" + webappName + "." + "azurewebsites.net/app2"); + response = curl("http://" + webappName + "." + "azurewebsites.net/app2/"); Assertions.assertEquals(200, response.getStatusCode()); body = response.getValue(); Assertions.assertNotNull(body); diff --git a/sdk/appservice/mgmt/src/test/java/com/azure/management/appservice/WebAppsWebDeployTests.java b/sdk/appservice/mgmt/src/test/java/com/azure/management/appservice/WebAppsWebDeployTests.java index 57f3c69b62560..7c3264cd46bbb 100644 --- a/sdk/appservice/mgmt/src/test/java/com/azure/management/appservice/WebAppsWebDeployTests.java +++ b/sdk/appservice/mgmt/src/test/java/com/azure/management/appservice/WebAppsWebDeployTests.java @@ -59,7 +59,7 @@ public void canDeployWarFile() throws Exception { Assertions.assertNotNull(deployment); if (!isPlaybackMode()) { SdkContext.sleep(10000); - Response response = curl("http://" + webApp1.defaultHostName() + "/helloworld"); + Response response = curl("http://" + webApp1.defaultHostName() + "/helloworld/"); Assertions.assertEquals(200, response.getStatusCode()); String body = response.getValue(); Assertions.assertNotNull(body); diff --git a/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageLinuxWebAppSourceControl.java b/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageLinuxWebAppSourceControl.java index 0d51bbd86af1c..8b013c5c32546 100644 --- a/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageLinuxWebAppSourceControl.java +++ b/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageLinuxWebAppSourceControl.java @@ -127,10 +127,10 @@ public static boolean runSample(Azure azure) { // warm up System.out.println("Warming up " + app2Url + "/helloworld..."); - Utils.curl("http://" + app2Url + "/helloworld"); + Utils.curl("http://" + app2Url + "/helloworld/"); SdkContext.sleep(5000); System.out.println("CURLing " + app2Url + "/helloworld..."); - System.out.println(Utils.curl("http://" + app2Url + "/helloworld")); + System.out.println(Utils.curl("http://" + app2Url + "/helloworld/")); //============================================================ // Create a 3rd web app with a public GitHub repo in Azure-Samples diff --git a/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageLinuxWebAppStorageAccountConnection.java b/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageLinuxWebAppStorageAccountConnection.java index ed4a6697f616d..971c44e5ecb1b 100644 --- a/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageLinuxWebAppStorageAccountConnection.java +++ b/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageLinuxWebAppStorageAccountConnection.java @@ -4,6 +4,7 @@ package com.azure.management.appservice.samples; import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; import com.azure.core.management.AzureEnvironment; import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.management.Azure; @@ -79,7 +80,7 @@ public static boolean runSample(Azure azure) { System.out.println("Uploading 2 blobs to container " + containerName + "..."); - BlobContainerClient container = setUpStorageAccount(connectionString, containerName); + BlobContainerClient container = setUpStorageAccount(connectionString, containerName, storageAccount.manager().httpPipeline().getHttpClient()); uploadFileToContainer(container, "helloworld.war", ManageLinuxWebAppStorageAccountConnection.class.getResource("/helloworld.war").getPath()); uploadFileToContainer(container, "install_apache.sh", ManageLinuxWebAppStorageAccountConnection.class.getResource("/install_apache.sh").getPath()); @@ -170,10 +171,11 @@ public static void main(String[] args) { } } - private static BlobContainerClient setUpStorageAccount(String connectionString, String containerName) { + private static BlobContainerClient setUpStorageAccount(String connectionString, String containerName, HttpClient httpClient) { BlobContainerClient blobContainerClient = new BlobContainerClientBuilder() .connectionString(connectionString) .containerName(containerName) + .httpClient(httpClient) .buildClient(); blobContainerClient.create(); diff --git a/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageWebAppCosmosDbByMsi.java b/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageWebAppCosmosDbByMsi.java index 6c25f6cf442a4..8f2e5e1c2a708 100644 --- a/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageWebAppCosmosDbByMsi.java +++ b/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageWebAppCosmosDbByMsi.java @@ -86,6 +86,7 @@ public static boolean runSample(Azure azure, TokenCredential credential, String SecretClient client = new SecretClientBuilder() .vaultUrl(vault.vaultUri()) .credential(credential) + .httpClient(vault.manager().httpPipeline().getHttpClient()) .buildClient(); //============================================================ diff --git a/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageWebAppStorageAccountConnection.java b/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageWebAppStorageAccountConnection.java index 200cac0e9c9c3..89d5b48506479 100644 --- a/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageWebAppStorageAccountConnection.java +++ b/sdk/management/samples/src/main/java/com/azure/management/appservice/samples/ManageWebAppStorageAccountConnection.java @@ -4,6 +4,7 @@ package com.azure.management.appservice.samples; import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; import com.azure.core.management.AzureEnvironment; import com.azure.identity.DefaultAzureCredentialBuilder; import com.azure.management.Azure; @@ -80,7 +81,7 @@ public static boolean runSample(Azure azure) { System.out.println("Uploading 2 blobs to container " + containerName + "..."); - BlobContainerClient container = setUpStorageAccount(connectionString, containerName); + BlobContainerClient container = setUpStorageAccount(connectionString, containerName, storageAccount.manager().httpPipeline().getHttpClient()); uploadFileToContainer(container, "helloworld.war", ManageWebAppStorageAccountConnection.class.getResource("/helloworld.war").getPath()); uploadFileToContainer(container, "install_apache.sh", ManageWebAppStorageAccountConnection.class.getResource("/install_apache.sh").getPath()); @@ -171,10 +172,11 @@ public static void main(String[] args) { } } - private static BlobContainerClient setUpStorageAccount(String connectionString, String containerName) { + private static BlobContainerClient setUpStorageAccount(String connectionString, String containerName, HttpClient httpClient) { BlobContainerClient blobContainerClient = new BlobContainerClientBuilder() .connectionString(connectionString) .containerName(containerName) + .httpClient(httpClient) .buildClient(); blobContainerClient.create(); diff --git a/sdk/management/samples/src/main/java/com/azure/management/monitor/samples/QueryMetricsAndActivityLogs.java b/sdk/management/samples/src/main/java/com/azure/management/monitor/samples/QueryMetricsAndActivityLogs.java index 3d16cc6271cf4..eb1ac6822cfaf 100644 --- a/sdk/management/samples/src/main/java/com/azure/management/monitor/samples/QueryMetricsAndActivityLogs.java +++ b/sdk/management/samples/src/main/java/com/azure/management/monitor/samples/QueryMetricsAndActivityLogs.java @@ -4,6 +4,7 @@ package com.azure.management.monitor.samples; import com.azure.core.credential.TokenCredential; +import com.azure.core.http.HttpClient; import com.azure.core.http.policy.HttpLogDetailLevel; import com.azure.core.http.rest.PagedIterable; import com.azure.core.management.AzureEnvironment; @@ -84,7 +85,7 @@ public static boolean runSample(Azure azure) { storageAccountKeys.get(0).value()); // Add some blob transaction events - addBlobTransactions(storageConnectionString); + addBlobTransactions(storageConnectionString, storageAccount.manager().httpPipeline().getHttpClient()); OffsetDateTime recordDateTime = azure.sdkContext().dateTimeNow(); // get metric definitions for storage account. @@ -197,7 +198,7 @@ public static void main(String[] args) { } } - private static void addBlobTransactions(String storageConnectionString) throws IOException { + private static void addBlobTransactions(String storageConnectionString, HttpClient httpClient) throws IOException { // Get the script to upload // try (InputStream scriptFileAsStream = QueryMetricsAndActivityLogs.class.getResourceAsStream("/install_apache.sh")) { @@ -213,6 +214,7 @@ private static void addBlobTransactions(String storageConnectionString) throws I BlobContainerClient blobContainerClient = new BlobContainerClientBuilder() .connectionString(storageConnectionString) .containerName("scripts") + .httpClient(httpClient) .buildClient(); blobContainerClient.create(); @@ -220,6 +222,7 @@ private static void addBlobTransactions(String storageConnectionString) throws I // Get the service properties. BlobServiceClient blobServiceClient = new BlobServiceClientBuilder() .connectionString(storageConnectionString) + .httpClient(httpClient) .buildClient(); BlobServiceProperties serviceProps = blobServiceClient.getProperties(); diff --git a/sdk/management/samples/src/main/java/com/azure/management/network/samples/ManageNetworkWatcher.java b/sdk/management/samples/src/main/java/com/azure/management/network/samples/ManageNetworkWatcher.java index a99df1e9919a6..aaecf9a2f5043 100644 --- a/sdk/management/samples/src/main/java/com/azure/management/network/samples/ManageNetworkWatcher.java +++ b/sdk/management/samples/src/main/java/com/azure/management/network/samples/ManageNetworkWatcher.java @@ -257,7 +257,10 @@ public static boolean runSample(Azure azure) { String connectionString = String.format("DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s", storageAccount.name(), accountKey); - BlobServiceClient blobServiceClient = new BlobServiceClientBuilder().connectionString(connectionString).buildClient(); + BlobServiceClient blobServiceClient = new BlobServiceClientBuilder() + .connectionString(connectionString) + .httpClient(storageAccount.manager().httpPipeline().getHttpClient()) + .buildClient(); BlobContainerClient blobContainerClient = blobServiceClient.getBlobContainerClient(packetCaptureStorageContainer); // iterate over subfolders structure to get the file BlobItem item = blobContainerClient.listBlobs().iterator().next(); diff --git a/sdk/management/samples/src/main/java/com/azure/management/network/samples/ManageVpnGatewayVNet2VNetConnection.java b/sdk/management/samples/src/main/java/com/azure/management/network/samples/ManageVpnGatewayVNet2VNetConnection.java index 09c5e36efd48c..02f837e664d3f 100644 --- a/sdk/management/samples/src/main/java/com/azure/management/network/samples/ManageVpnGatewayVNet2VNetConnection.java +++ b/sdk/management/samples/src/main/java/com/azure/management/network/samples/ManageVpnGatewayVNet2VNetConnection.java @@ -139,7 +139,10 @@ public static boolean runSample(Azure azure) { // Create storage container to store troubleshooting results String accountKey = storageAccount.getKeys().get(0).value(); String connectionString = String.format("DefaultEndpointsProtocol=https;AccountName=%s;AccountKey=%s", storageAccount.name(), accountKey); - BlobServiceClient blobServiceClient = new BlobServiceClientBuilder().connectionString(connectionString).buildClient(); + BlobServiceClient blobServiceClient = new BlobServiceClientBuilder() + .connectionString(connectionString) + .httpClient(storageAccount.manager().httpPipeline().getHttpClient()) + .buildClient(); BlobContainerClient containerClient = blobServiceClient.getBlobContainerClient(storageContainerName); containerClient.create(); diff --git a/sdk/management/samples/src/test/java/com/azure/management/samples/MonitorTests.java b/sdk/management/samples/src/test/java/com/azure/management/samples/MonitorTests.java index e65940e501088..3f119dbac1a5d 100644 --- a/sdk/management/samples/src/test/java/com/azure/management/samples/MonitorTests.java +++ b/sdk/management/samples/src/test/java/com/azure/management/samples/MonitorTests.java @@ -9,15 +9,16 @@ import com.azure.management.monitor.samples.SecurityBreachOrRiskActivityLogAlerts; import com.azure.management.monitor.samples.WebAppPerformanceMonitoringAlerts; import org.junit.jupiter.api.Assertions; -import org.junit.jupiter.api.Disabled; import org.junit.jupiter.api.Test; public class MonitorTests extends SamplesTestBase { @Test - @Disabled("Live only sample due to the need to call non-management endpoints.") public void testQueryMetricsAndActivityLogs() { - Assertions.assertTrue(QueryMetricsAndActivityLogs.runSample(azure)); + // Skip test in "playback" mode due to HTTP calls made outside of the management plane which can not be recorded at this time + if (!isPlaybackMode()) { + Assertions.assertTrue(QueryMetricsAndActivityLogs.runSample(azure)); + } } @Test @@ -31,8 +32,10 @@ public void testWebAppPerformanceMonitoringAlerts() { } @Test - @Disabled("Live only sample due to the need to call non-management endpoints.") public void testAutoscaleSettingsBasedOnPerformanceOrSchedule() { - Assertions.assertTrue(AutoscaleSettingsBasedOnPerformanceOrSchedule.runSample(azure)); + // Skip test in "playback" mode due to HTTP calls made outside of the management plane which can not be recorded at this time + if (!isPlaybackMode()) { + Assertions.assertTrue(AutoscaleSettingsBasedOnPerformanceOrSchedule.runSample(azure)); + } } } diff --git a/sdk/management/samples/src/test/java/com/azure/management/samples/SqlSampleTests.java b/sdk/management/samples/src/test/java/com/azure/management/samples/SqlSampleTests.java index 2fb043a9f01aa..fd63a7af7dd00 100644 --- a/sdk/management/samples/src/test/java/com/azure/management/samples/SqlSampleTests.java +++ b/sdk/management/samples/src/test/java/com/azure/management/samples/SqlSampleTests.java @@ -22,13 +22,6 @@ import java.nio.file.Paths; public class SqlSampleTests extends SamplesTestBase { -// @Override -// protected RestClient buildRestClient(RestClient.Builder builder, boolean isMocked) { -// if (!isMocked) { -// return super.buildRestClient(builder, isMocked); -// } -// return super.buildRestClient(builder.withReadTimeout(200, TimeUnit.SECONDS), isMocked); -// } @Test public void testManageSqlDatabase() { diff --git a/sdk/resources/mgmt/src/test/java/com/azure/management/resources/core/TestBase.java b/sdk/resources/mgmt/src/test/java/com/azure/management/resources/core/TestBase.java index f5dac08f42135..461b9590a10fd 100644 --- a/sdk/resources/mgmt/src/test/java/com/azure/management/resources/core/TestBase.java +++ b/sdk/resources/mgmt/src/test/java/com/azure/management/resources/core/TestBase.java @@ -253,7 +253,7 @@ null, profile, null, new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AN } httpPipeline = HttpPipelineProvider.buildHttpPipeline( credential, profile, null, new HttpLogOptions().setLogLevel(HttpLogDetailLevel.BODY_AND_HEADERS), - null, new RetryPolicy(), policies, null); + null, new RetryPolicy(), policies, generateHttpClientWithProxy(null)); interceptorManager.addTextReplacementRule(profile.subscriptionId(), ZERO_SUBSCRIPTION); interceptorManager.addTextReplacementRule(profile.tenantId(), ZERO_TENANT); diff --git a/sdk/sql/mgmt/src/main/java/com/azure/management/sql/implementation/SqlDatabaseExportRequestImpl.java b/sdk/sql/mgmt/src/main/java/com/azure/management/sql/implementation/SqlDatabaseExportRequestImpl.java index 0f94af47c65b9..974fc0447a229 100644 --- a/sdk/sql/mgmt/src/main/java/com/azure/management/sql/implementation/SqlDatabaseExportRequestImpl.java +++ b/sdk/sql/mgmt/src/main/java/com/azure/management/sql/implementation/SqlDatabaseExportRequestImpl.java @@ -93,6 +93,7 @@ private Mono getOrCreateStorageAccountContainer( new BlobServiceClientBuilder() .endpoint(storageAccount.endPoints().primary().blob()) .sasToken(storageAccountKey.value()) + .httpClient(sqlServerManager.httpPipeline().getHttpClient()) .buildClient(); blobServiceClient.createBlobContainer(containerName); } catch (IndexOutOfBoundsException indexOutOfBoundsException) {