diff --git a/sdk/appconfiguration/test-resources.json b/sdk/appconfiguration/test-resources.json index 8430c5640997..46dc3a3cce7f 100644 --- a/sdk/appconfiguration/test-resources.json +++ b/sdk/appconfiguration/test-resources.json @@ -48,16 +48,30 @@ "defaultValue": "azconfig-net", "type": "string" }, - "endpointSuffix": { + "azConfigEndpointSuffix": { "defaultValue": ".azconfig.io", "type": "string" + }, + "keyVaultEndpointSuffix": { + "defaultValue": ".vault.azure.net", + "type": "string", + "metadata": { + "description": "Endpoint suffix for sovereign clouds, requies the preceeding '.'. The default uses the public Azure Cloud (.vault.azure.net)" + } + }, + "keyVaultSku": { + "type": "string", + "defaultValue": "premium", + "metadata": { + "description": "Key Vault SKU to deploy. The default is 'premium'" + } } }, "variables": { "roleDefinitionId": "[format('/subscriptions/{0}/providers/Microsoft.Authorization/roleDefinitions/5ae67dd6-50cb-40e7-96ff-dc2bfa4b606b', subscription().subscriptionId)]", "uniqueAzConfigName": "[format('{0}-{1}', parameters('baseName'), parameters('azConfigPrefix'))]", - "endpointValue": "[format('https://{0}-{1}.azconfig.io', parameters('baseName'), parameters('azConfigPrefix'))]", - "azureKeyVaultSecretUrl": "[format('https://{0}.vault.azure.net/secrets/TestSecret', parameters('baseName'))]" + "endpointValue": "[format('https://{0}-{1}{2}', parameters('baseName'), parameters('azConfigPrefix'), parameters('azConfigEndpointSuffix'))]", + "azureKeyVaultSecretUrl": "[format('https://{0}{1}/secrets/TestSecret', parameters('baseName'), parameters('keyVaultEndpointSuffix'))]" }, "resources": [ { @@ -89,7 +103,7 @@ "properties": { "sku": { "family": "A", - "name": "premium" + "name": "[parameters('keyVaultSku')]" }, "tenantId": "[parameters('tenantId')]", "accessPolicies": [ diff --git a/sdk/appconfiguration/tests.yml b/sdk/appconfiguration/tests.yml index 9731bacae180..70629fee7aba 100644 --- a/sdk/appconfiguration/tests.yml +++ b/sdk/appconfiguration/tests.yml @@ -4,3 +4,4 @@ extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-tests.yml parameters: ServiceDirectory: appconfiguration + Clouds: 'Public,Preview,UsGov,China' diff --git a/sdk/core/Azure.Core.TestFramework/src/TestEnvironment.cs b/sdk/core/Azure.Core.TestFramework/src/TestEnvironment.cs index b97bf1567d4e..ca61fa7484b8 100644 --- a/sdk/core/Azure.Core.TestFramework/src/TestEnvironment.cs +++ b/sdk/core/Azure.Core.TestFramework/src/TestEnvironment.cs @@ -131,7 +131,7 @@ static TestEnvironment() /// /// The URL of the Azure Authority host to be used for authentication. Recorded. /// - public string AuthorityHostUrl => GetRecordedOptionalVariable("AZURE_AUTHORITY_HOST"); + public string AuthorityHostUrl => GetRecordedOptionalVariable("AZURE_AUTHORITY_HOST") ?? "https://login.microsoftonline.com/"; /// /// The suffix for Azure Storage accounts for the active cloud environment, such as "core.windows.net". Recorded. diff --git a/sdk/eventgrid/tests.yml b/sdk/eventgrid/tests.yml index 32e927f49c34..352be8024d7e 100644 --- a/sdk/eventgrid/tests.yml +++ b/sdk/eventgrid/tests.yml @@ -4,5 +4,6 @@ extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-tests.yml parameters: ServiceDirectory: eventgrid + Clouds: 'Public,Preview,UsGov,China' EnvVars: AZURE_EVENTGRID_TEST_MODE: Live diff --git a/sdk/eventhub/tests.data.yml b/sdk/eventhub/tests.data.yml index 5706e8b7b72a..ef58d8254958 100644 --- a/sdk/eventhub/tests.data.yml +++ b/sdk/eventhub/tests.data.yml @@ -6,5 +6,5 @@ extends: MaxParallel: 6 ServiceDirectory: eventhub SDKType: data - TimeoutInMinutes: 190 - Clouds: 'Public,Canary' \ No newline at end of file + TimeoutInMinutes: 240 + Clouds: 'Public,Preview,UsGov,China,Canary' \ No newline at end of file diff --git a/sdk/eventhub/tests.yml b/sdk/eventhub/tests.yml index f02bf2b1d828..d5739511b98b 100644 --- a/sdk/eventhub/tests.yml +++ b/sdk/eventhub/tests.yml @@ -6,5 +6,5 @@ extends: MaxParallel: 6 ServiceDirectory: eventhub SDKType: client - TimeoutInMinutes: 190 - Clouds: 'Public,Canary' \ No newline at end of file + TimeoutInMinutes: 240 + Clouds: 'Public,Preview,UsGov,China,Canary' diff --git a/sdk/extensions/tests.yml b/sdk/extensions/tests.yml index b2f766ee516d..c318ec4e74ea 100644 --- a/sdk/extensions/tests.yml +++ b/sdk/extensions/tests.yml @@ -4,4 +4,4 @@ extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-tests.yml parameters: ServiceDirectory: extensions - SupportedClouds: 'Public,Canary,UsGov,China' + Clouds: 'Public,Preview,UsGov,China' diff --git a/sdk/formrecognizer/tests.yml b/sdk/formrecognizer/tests.yml index de2ac49779e6..15c7a9d3aa87 100644 --- a/sdk/formrecognizer/tests.yml +++ b/sdk/formrecognizer/tests.yml @@ -4,7 +4,7 @@ extends: template: ../../eng/pipelines/templates/stages/archetype-sdk-tests.yml parameters: ServiceDirectory: formrecognizer - TimeoutInMinutes: 90 + TimeoutInMinutes: 240 CloudConfig: Public: SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources) @@ -18,4 +18,4 @@ extends: China: SubscriptionConfiguration: $(sub-config-cn-test-resources) Location: 'chinaeast2' - SupportedClouds: 'Public,Canary,UsGov,China' + Clouds: 'Public,UsGov,China,Canary' diff --git a/sdk/identity/Azure.Identity/tests/ClientCertificateCredentialLiveTests.cs b/sdk/identity/Azure.Identity/tests/ClientCertificateCredentialLiveTests.cs index 31ef0c16776a..58221ef0b210 100644 --- a/sdk/identity/Azure.Identity/tests/ClientCertificateCredentialLiveTests.cs +++ b/sdk/identity/Azure.Identity/tests/ClientCertificateCredentialLiveTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using System.IO; using System.Security.Cryptography.X509Certificates; using System.Threading.Tasks; @@ -35,7 +36,7 @@ public async Task FromCertificatePath(bool usePem) var credential = InstrumentClient(new ClientCertificateCredential(tenantId, clientId, certPath, options)); - var tokenRequestContext = new TokenRequestContext(new[] { AzureAuthorityHosts.GetDefaultScope(AzureAuthorityHosts.AzurePublicCloud) }); + var tokenRequestContext = new TokenRequestContext(new[] { AzureAuthorityHosts.GetDefaultScope(new Uri(TestEnvironment.AuthorityHostUrl)) }); // ensure we can initially acquire a token AccessToken token = await credential.GetTokenAsync(tokenRequestContext); @@ -70,7 +71,7 @@ public async Task FromX509Certificate2() var credential = InstrumentClient(new ClientCertificateCredential(tenantId, clientId, cert, options)); - var tokenRequestContext = new TokenRequestContext(new[] { AzureAuthorityHosts.GetDefaultScope(AzureAuthorityHosts.AzurePublicCloud) }); + var tokenRequestContext = new TokenRequestContext(new[] { AzureAuthorityHosts.GetDefaultScope(new Uri(TestEnvironment.AuthorityHostUrl)) }); // ensure we can initially acquire a token AccessToken token = await credential.GetTokenAsync(tokenRequestContext); @@ -105,7 +106,7 @@ public async Task IncludeX5CClaimHeader() var credential = InstrumentClient(new ClientCertificateCredential(tenantId, clientId, certPath, options)); - var tokenRequestContext = new TokenRequestContext(new[] { AzureAuthorityHosts.GetDefaultScope(AzureAuthorityHosts.AzurePublicCloud) }); + var tokenRequestContext = new TokenRequestContext(new[] { AzureAuthorityHosts.GetDefaultScope(new Uri(TestEnvironment.AuthorityHostUrl)) }); // ensure we can initially acquire a token AccessToken token = await credential.GetTokenAsync(tokenRequestContext); @@ -124,7 +125,7 @@ public void IncorrectCertificate() var credential = InstrumentClient(new ClientCertificateCredential(tenantId, clientId, new X509Certificate2(certPath), options)); - var tokenRequestContext = new TokenRequestContext(new[] { AzureAuthorityHosts.GetDefaultScope(AzureAuthorityHosts.AzurePublicCloud) }); + var tokenRequestContext = new TokenRequestContext(new[] { AzureAuthorityHosts.GetDefaultScope(new Uri(TestEnvironment.AuthorityHostUrl)) }); // ensure the incorrect client claim is rejected, handled and wrapped in AuthenticationFailedException Assert.ThrowsAsync(async () => await credential.GetTokenAsync(tokenRequestContext)); diff --git a/sdk/identity/Azure.Identity/tests/ClientSecretCredentialLiveTests.cs b/sdk/identity/Azure.Identity/tests/ClientSecretCredentialLiveTests.cs index 631cede7422b..37cfa2aebcd6 100644 --- a/sdk/identity/Azure.Identity/tests/ClientSecretCredentialLiveTests.cs +++ b/sdk/identity/Azure.Identity/tests/ClientSecretCredentialLiveTests.cs @@ -1,6 +1,7 @@ // Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. +using System; using System.Threading.Tasks; using Azure.Core; using Azure.Core.TestFramework; @@ -32,7 +33,7 @@ public async Task GetToken() var credential = InstrumentClient(new ClientSecretCredential(tenantId, clientId, secret, options)); - var tokenRequestContext = new TokenRequestContext(new[] { AzureAuthorityHosts.GetDefaultScope(AzureAuthorityHosts.AzurePublicCloud) }); + var tokenRequestContext = new TokenRequestContext(new[] { AzureAuthorityHosts.GetDefaultScope(new Uri(TestEnvironment.AuthorityHostUrl)) }); // ensure we can initially acquire a token AccessToken token = await credential.GetTokenAsync(tokenRequestContext); @@ -66,7 +67,7 @@ public void GetTokenIncorrectPassword() var credential = InstrumentClient(new ClientSecretCredential(tenantId, clientId, secret, options)); - var tokenRequestContext = new TokenRequestContext(new[] { AzureAuthorityHosts.GetDefaultScope(AzureAuthorityHosts.AzurePublicCloud) }); + var tokenRequestContext = new TokenRequestContext(new[] { AzureAuthorityHosts.GetDefaultScope(new Uri(TestEnvironment.AuthorityHostUrl)) }); // ensure we can initially acquire a token Assert.ThrowsAsync(async () => await credential.GetTokenAsync(tokenRequestContext)); diff --git a/sdk/identity/Azure.Identity/tests/CredentialTestHelpers.cs b/sdk/identity/Azure.Identity/tests/CredentialTestHelpers.cs index 253318ac0e84..d18cf6548f0f 100644 --- a/sdk/identity/Azure.Identity/tests/CredentialTestHelpers.cs +++ b/sdk/identity/Azure.Identity/tests/CredentialTestHelpers.cs @@ -135,13 +135,15 @@ public static async Task GetRefreshTokenAsync(IdentityTestEnvironment te var clientId = "aebc6443-996d-45c2-90f0-388ff96faa56"; var username = testEnvironment.Username; var password = testEnvironment.Password; + var authorityUri = new Uri(new Uri(testEnvironment.AuthorityHostUrl), testEnvironment.TestTenantId).ToString(); var client = PublicClientApplicationBuilder.Create(clientId) + .WithAuthority(authorityUri) .WithTenantId(testEnvironment.TestTenantId) .Build(); var retriever = new RefreshTokenRetriever(client.UserTokenCache); - await client.AcquireTokenByUsernamePassword(new[] {".default"}, username, password.ToSecureString()).ExecuteAsync(); + await client.AcquireTokenByUsernamePassword(new[] { ".default" }, username, password.ToSecureString()).ExecuteAsync(); StaticCachesUtilities.ClearStaticMetadataProviderCache(); StaticCachesUtilities.ClearAuthorityEndpointResolutionManagerCache(); diff --git a/sdk/identity/Azure.Identity/tests/DefaultAzureCredentialLiveTests.cs b/sdk/identity/Azure.Identity/tests/DefaultAzureCredentialLiveTests.cs index 88ca86ca54f2..dc8e58cf40ba 100644 --- a/sdk/identity/Azure.Identity/tests/DefaultAzureCredentialLiveTests.cs +++ b/sdk/identity/Azure.Identity/tests/DefaultAzureCredentialLiveTests.cs @@ -45,7 +45,7 @@ public async Task DefaultAzureCredential_UseVisualStudioCredential() using (ClientDiagnosticListener diagnosticListener = new ClientDiagnosticListener(s => s.StartsWith("Azure.Identity"))) { - token = await credential.GetTokenAsync(new TokenRequestContext(new[] {"https://vault.azure.net/.default"}), CancellationToken.None); + token = await credential.GetTokenAsync(new TokenRequestContext(new[] {TestEnvironment.KeyvaultScope}), CancellationToken.None); scopes = diagnosticListener.Scopes; } @@ -66,6 +66,7 @@ public async Task DefaultAzureCredential_UseVisualStudioCodeCredential() ExcludeEnvironmentCredential = true, ExcludeInteractiveBrowserCredential = true, ExcludeSharedTokenCacheCredential = true, + ExcludeManagedIdentityCredential = true, VisualStudioCodeTenantId = TestEnvironment.TestTenantId }); @@ -82,7 +83,7 @@ public async Task DefaultAzureCredential_UseVisualStudioCodeCredential() using (await CredentialTestHelpers.CreateRefreshTokenFixtureAsync(TestEnvironment, Mode, ExpectedServiceName, cloudName)) using (ClientDiagnosticListener diagnosticListener = new ClientDiagnosticListener(s => s.StartsWith("Azure.Identity"))) { - token = await credential.GetTokenAsync(new TokenRequestContext(new[] {"https://vault.azure.net/.default"}), CancellationToken.None); + token = await credential.GetTokenAsync(new TokenRequestContext(new[] {TestEnvironment.KeyvaultScope}), CancellationToken.None); scopes = diagnosticListener.Scopes; } @@ -102,6 +103,7 @@ public async Task DefaultAzureCredential_UseVisualStudioCodeCredential_ParallelC ExcludeEnvironmentCredential = true, ExcludeInteractiveBrowserCredential = true, ExcludeSharedTokenCacheCredential = true, + ExcludeManagedIdentityCredential = true, VisualStudioCodeTenantId = TestEnvironment.TestTenantId }); @@ -117,7 +119,7 @@ public async Task DefaultAzureCredential_UseVisualStudioCodeCredential_ParallelC { for (int i = 0; i < 10; i++) { - tasks.Add(Task.Run(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] {"https://vault.azure.net/.default"}), CancellationToken.None))); + tasks.Add(Task.Run(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] {TestEnvironment.KeyvaultScope}), CancellationToken.None))); } await Task.WhenAll(tasks); @@ -153,7 +155,7 @@ public async Task DefaultAzureCredential_UseAzureCliCredential() using (ClientDiagnosticListener diagnosticListener = new ClientDiagnosticListener(s => s.StartsWith("Azure.Identity"))) { - token = await credential.GetTokenAsync(new TokenRequestContext(new[] {"https://vault.azure.net/.default"}), CancellationToken.None); + token = await credential.GetTokenAsync(new TokenRequestContext(new[] {TestEnvironment.KeyvaultScope}), CancellationToken.None); scopes = diagnosticListener.Scopes; } @@ -187,7 +189,7 @@ public async Task DefaultAzureCredential_UseAzureCliCredential_ParallelCalls() var tasks = new List>(); for (int i = 0; i < 10; i++) { - tasks.Add(Task.Run(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] {"https://vault.azure.net/.default"}), CancellationToken.None))); + tasks.Add(Task.Run(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] {TestEnvironment.KeyvaultScope}), CancellationToken.None))); } await Task.WhenAll(tasks); @@ -218,7 +220,7 @@ public void DefaultAzureCredential_AllCredentialsHaveFailed_CredentialUnavailabl using (ClientDiagnosticListener diagnosticListener = new ClientDiagnosticListener(s => s.StartsWith("Azure.Identity"))) { - Assert.CatchAsync(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] {"https://vault.azure.net/.default"}), CancellationToken.None)); + Assert.CatchAsync(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] {TestEnvironment.KeyvaultScope}), CancellationToken.None)); scopes = diagnosticListener.Scopes; } @@ -274,7 +276,7 @@ public void DefaultAzureCredential_AllCredentialsHaveFailed_LastAuthenticationFa using (ClientDiagnosticListener diagnosticListener = new ClientDiagnosticListener(s => s.StartsWith("Azure.Identity"))) { - Assert.CatchAsync(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] {"https://vault.azure.net/.default"}), CancellationToken.None)); + Assert.CatchAsync(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] {TestEnvironment.KeyvaultScope}), CancellationToken.None)); scopes = diagnosticListener.Scopes; } diff --git a/sdk/identity/Azure.Identity/tests/DeviceCodeCredentialTests.cs b/sdk/identity/Azure.Identity/tests/DeviceCodeCredentialTests.cs index fe4f4c4ce4c1..fc409a358cf0 100644 --- a/sdk/identity/Azure.Identity/tests/DeviceCodeCredentialTests.cs +++ b/sdk/identity/Azure.Identity/tests/DeviceCodeCredentialTests.cs @@ -176,6 +176,7 @@ public async Task AuthenticateWithDeviceCodeMockVerifyCallbackCancellationAsync( [Test] public void AuthenticateWithDeviceCodeCallbackThrowsAsync() { + IdentityTestEnvironment testEnvironment = new IdentityTestEnvironment(); var expectedCode = Guid.NewGuid().ToString(); var expectedToken = Guid.NewGuid().ToString(); @@ -188,7 +189,7 @@ public void AuthenticateWithDeviceCodeCallbackThrowsAsync() var cred = InstrumentClient(new DeviceCodeCredential(ThrowingDeviceCodeCallback, ClientId, options: options)); - var ex = Assert.ThrowsAsync(async () => await cred.GetTokenAsync(new TokenRequestContext(new string[] { "https://vault.azure.net/.default" }), cancelSource.Token)); + var ex = Assert.ThrowsAsync(async () => await cred.GetTokenAsync(new TokenRequestContext(new string[] { testEnvironment.KeyvaultScope }), cancelSource.Token)); Assert.IsInstanceOf(typeof(MockException), ex.InnerException); } @@ -196,11 +197,12 @@ public void AuthenticateWithDeviceCodeCallbackThrowsAsync() [Test] public void DisableAutomaticAuthenticationException() { + IdentityTestEnvironment testEnvironment = new IdentityTestEnvironment(); var expectedCode = Guid.NewGuid().ToString(); var cred = InstrumentClient(new DeviceCodeCredential(new DeviceCodeCredentialOptions { DisableAutomaticAuthentication = true, DeviceCodeCallback = (code, cancelToken) => VerifyDeviceCode(code, expectedCode) })); - var expTokenRequestContext = new TokenRequestContext(new string[] { "https://vault.azure.net/.default" }, Guid.NewGuid().ToString()); + var expTokenRequestContext = new TokenRequestContext(new string[] { testEnvironment.KeyvaultScope }, Guid.NewGuid().ToString()); var ex = Assert.ThrowsAsync(async () => await cred.GetTokenAsync(expTokenRequestContext)); @@ -209,24 +211,25 @@ public void DisableAutomaticAuthenticationException() private MockResponse ProcessMockRequest(MockRequest mockRequest, string code, string token) { + IdentityTestEnvironment testEnvironment = new IdentityTestEnvironment(); string requestUrl = mockRequest.Uri.ToUri().AbsoluteUri; - if (requestUrl.StartsWith("https://login.microsoftonline.com/common/discovery/instance")) + if (requestUrl.StartsWith(new Uri(new Uri(testEnvironment.AuthorityHostUrl), "common/discovery/instance").ToString())) { return DiscoveryInstanceResponse; } - if (requestUrl.StartsWith("https://login.microsoftonline.com/organizations/v2.0/.well-known/openid-configuration")) + if (requestUrl.StartsWith(new Uri(new Uri(testEnvironment.AuthorityHostUrl), "organizations/v2.0/.well-known/openid-configuration").ToString())) { return OpenIdConfigurationResponse; } - if (requestUrl.StartsWith("https://login.microsoftonline.com/organizations/oauth2/v2.0/devicecode")) + if (requestUrl.StartsWith(new Uri(new Uri(testEnvironment.AuthorityHostUrl), "organizations/oauth2/v2.0/devicecode").ToString()) || requestUrl.StartsWith("https://login.partner.microsoftonline.cn/organizations/oauth2/v2.0/devicecode")) { return CreateDeviceCodeResponse(code); } - if (requestUrl.StartsWith("https://login.microsoftonline.com/organizations/oauth2/v2.0/token")) + if (requestUrl.StartsWith(new Uri(new Uri(testEnvironment.AuthorityHostUrl), "organizations/oauth2/v2.0/token").ToString()) || requestUrl.StartsWith($"https://login.partner.microsoftonline.cn/organizations/oauth2/v2.0/token")) { return CreateTokenResponse(code, token); } diff --git a/sdk/identity/Azure.Identity/tests/IdentityTestEnvironment.cs b/sdk/identity/Azure.Identity/tests/IdentityTestEnvironment.cs index 47c0843b6e0b..88f1b08e5681 100644 --- a/sdk/identity/Azure.Identity/tests/IdentityTestEnvironment.cs +++ b/sdk/identity/Azure.Identity/tests/IdentityTestEnvironment.cs @@ -31,6 +31,7 @@ public class IdentityTestEnvironment : TestEnvironment public string TestPassword => GetOptionalVariable("AZURE_IDENTITY_TEST_PASSWORD") ?? "SANITIZED"; public string TestTenantId => GetRecordedOptionalVariable("TENANT_ID") ?? GetRecordedVariable("AZURE_IDENTITY_TEST_TENANTID"); + public string KeyvaultScope => GetOptionalVariable("AZURE_KEYVAULT_SCOPE") ?? "https://vault.azure.net/.default"; public string ServicePrincipalClientId => GetRecordedVariable("IDENTITY_SP_CLIENT_ID"); public string ServicePrincipalTenantId => GetRecordedVariable("IDENTITY_SP_TENANT_ID"); diff --git a/sdk/identity/Azure.Identity/tests/UsernamePasswordCredentialLiveTests.cs b/sdk/identity/Azure.Identity/tests/UsernamePasswordCredentialLiveTests.cs index dae494a713de..d4079f8481af 100644 --- a/sdk/identity/Azure.Identity/tests/UsernamePasswordCredentialLiveTests.cs +++ b/sdk/identity/Azure.Identity/tests/UsernamePasswordCredentialLiveTests.cs @@ -72,7 +72,7 @@ public async Task GetToken() var cred = InstrumentClient(new UsernamePasswordCredential(username, password, tenantId, ClientId, options)); - AccessToken token = await cred.GetTokenAsync(new TokenRequestContext(new string[] { "https://vault.azure.net/.default" })); + AccessToken token = await cred.GetTokenAsync(new TokenRequestContext(new string[] { TestEnvironment.KeyvaultScope })); Assert.IsNotNull(token.Token); } @@ -107,7 +107,7 @@ public async Task AuthenticateWithContext() var cred = InstrumentClient(new UsernamePasswordCredential(username, password, tenantId, ClientId, options)); - AuthenticationRecord record = await cred.AuthenticateAsync(new TokenRequestContext(new[] { "https://vault.azure.net/.default" })); + AuthenticationRecord record = await cred.AuthenticateAsync(new TokenRequestContext(new[] { TestEnvironment.KeyvaultScope })); Assert.IsNotNull(record); diff --git a/sdk/identity/Azure.Identity/tests/VisualStudioCodeCredentialLiveTests.cs b/sdk/identity/Azure.Identity/tests/VisualStudioCodeCredentialLiveTests.cs index 18af2a9dfd2f..bb5872789d5e 100644 --- a/sdk/identity/Azure.Identity/tests/VisualStudioCodeCredentialLiveTests.cs +++ b/sdk/identity/Azure.Identity/tests/VisualStudioCodeCredentialLiveTests.cs @@ -20,17 +20,29 @@ public VisualStudioCodeCredentialLiveTests(bool isAsync) : base(isAsync) } [Test] - [RunOnlyOnPlatforms(Windows = true, OSX = true, ContainerNames = new[] { "ubuntu_netcore_keyring" })] + [RunOnlyOnPlatforms(Windows = true, OSX = true, ContainerNames = new[] { "ubuntu_netcore2_keyring" })] public async Task AuthenticateWithVscCredential() { - var cloudName = Guid.NewGuid().ToString(); + var cloudName = "Azure"; + switch (TestEnvironment.AuthorityHostUrl) + { + case "https://login.microsoftonline.com": + cloudName = "Azure"; + break; + case "https://login.microsoftonline.us": + cloudName = "AzureChina"; + break; + case "https://login.chinacloudapi.cn": + cloudName = "AzureUSGovernment"; + break; + } var fileSystem = CredentialTestHelpers.CreateFileSystemForVisualStudioCode(TestEnvironment, cloudName); using IDisposable fixture = await CredentialTestHelpers.CreateRefreshTokenFixtureAsync(TestEnvironment, Mode, ExpectedServiceName, cloudName); var options = InstrumentClientOptions(new VisualStudioCodeCredentialOptions { TenantId = TestEnvironment.TestTenantId }); VisualStudioCodeCredential credential = InstrumentClient(new VisualStudioCodeCredential(options, default, default, fileSystem, default)); - AccessToken token = await credential.GetTokenAsync(new TokenRequestContext(new[] {"https://vault.azure.net/.default"}), CancellationToken.None); + AccessToken token = await credential.GetTokenAsync(new TokenRequestContext(new[] { TestEnvironment.KeyvaultScope}), CancellationToken.None); Assert.IsNotNull(token.Token); } @@ -43,7 +55,7 @@ public async Task AuthenticateWithVscCredential_NoSettingsFile() var options = InstrumentClientOptions(new VisualStudioCodeCredentialOptions { TenantId = TestEnvironment.TestTenantId }); VisualStudioCodeCredential credential = InstrumentClient(new VisualStudioCodeCredential(options, default, default, fileSystemService, vscAdapter)); - AccessToken token = await credential.GetTokenAsync(new TokenRequestContext(new[] {"https://vault.azure.net/.default"}), CancellationToken.None); + AccessToken token = await credential.GetTokenAsync(new TokenRequestContext(new[] { TestEnvironment.KeyvaultScope}), CancellationToken.None); Assert.IsNotNull(token.Token); } @@ -56,7 +68,7 @@ public async Task AuthenticateWithVscCredential_BrokenSettingsFile() var options = InstrumentClientOptions(new VisualStudioCodeCredentialOptions { TenantId = TestEnvironment.TestTenantId }); VisualStudioCodeCredential credential = InstrumentClient(new VisualStudioCodeCredential(options, default, default, fileSystemService, vscAdapter)); - AccessToken token = await credential.GetTokenAsync(new TokenRequestContext(new[] {"https://vault.azure.net/.default"}), CancellationToken.None); + AccessToken token = await credential.GetTokenAsync(new TokenRequestContext(new[] {TestEnvironment.KeyvaultScope}), CancellationToken.None); Assert.IsNotNull(token.Token); } @@ -70,12 +82,12 @@ public async Task AuthenticateWithVscCredential_EmptySettingsFile() var options = InstrumentClientOptions(new VisualStudioCodeCredentialOptions { TenantId = TestEnvironment.TestTenantId }); VisualStudioCodeCredential credential = InstrumentClient(new VisualStudioCodeCredential(options, default, default, fileSystemService, vscAdapter)); - AccessToken token = await credential.GetTokenAsync(new TokenRequestContext(new[] {"https://vault.azure.net/.default"}), CancellationToken.None); + AccessToken token = await credential.GetTokenAsync(new TokenRequestContext(new[] {TestEnvironment.KeyvaultScope}), CancellationToken.None); Assert.IsNotNull(token.Token); } [Test] - [RunOnlyOnPlatforms(Windows = true, OSX = true, ContainerNames = new[] { "ubuntu_netcore_keyring" })] + [RunOnlyOnPlatforms(Windows = true, OSX = true, ContainerNames = new[] { "ubuntu_netcore2_keyring" })] public async Task AuthenticateWithVscCredential_TenantInSettings() { var cloudName = Guid.NewGuid().ToString(); @@ -86,12 +98,12 @@ public async Task AuthenticateWithVscCredential_TenantInSettings() var options = InstrumentClientOptions(new VisualStudioCodeCredentialOptions { TenantId = Guid.NewGuid().ToString() }); VisualStudioCodeCredential credential = InstrumentClient(new VisualStudioCodeCredential(options, default, default, fileSystemService, default)); - AccessToken token = await credential.GetTokenAsync(new TokenRequestContext(new[] {"https://vault.azure.net/.default"}), CancellationToken.None); + AccessToken token = await credential.GetTokenAsync(new TokenRequestContext(new[] {TestEnvironment.KeyvaultScope}), CancellationToken.None); Assert.IsNotNull(token.Token); } [Test] - [RunOnlyOnPlatforms(Windows = true, OSX = true, ContainerNames = new[] { "ubuntu_netcore_keyring" })] + [RunOnlyOnPlatforms(Windows = true, OSX = true, ContainerNames = new[] { "ubuntu_netcore2_keyring" })] public void AuthenticateWithVscCredential_NoVscInstalled() { var cloudName = Guid.NewGuid().ToString(); @@ -100,7 +112,7 @@ public void AuthenticateWithVscCredential_NoVscInstalled() var options = InstrumentClientOptions(new VisualStudioCodeCredentialOptions { TenantId = TestEnvironment.TestTenantId }); VisualStudioCodeCredential credential = InstrumentClient(new VisualStudioCodeCredential(options, default, default, fileSystem, default)); - Assert.CatchAsync(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] {"https://vault.azure.net/.default"}), CancellationToken.None)); + Assert.CatchAsync(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] {TestEnvironment.KeyvaultScope}), CancellationToken.None)); } [Test] @@ -113,7 +125,7 @@ public void AuthenticateWithVscCredential_NoRefreshToken() var options = InstrumentClientOptions(new VisualStudioCodeCredentialOptions { TenantId = tenantId }); VisualStudioCodeCredential credential = InstrumentClient(new VisualStudioCodeCredential(options, default, default, fileSystem, vscAdapter)); - Assert.ThrowsAsync(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] {"https://vault.azure.net/.default"}), CancellationToken.None)); + Assert.CatchAsync(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] {TestEnvironment.KeyvaultScope}), CancellationToken.None)); } [Test] @@ -126,7 +138,7 @@ public void AuthenticateWithVscCredential_AuthenticationCodeInsteadOfRefreshToke var options = InstrumentClientOptions(new VisualStudioCodeCredentialOptions { TenantId = tenantId }); VisualStudioCodeCredential credential = InstrumentClient(new VisualStudioCodeCredential(options, default, default, fileSystemService, vscAdapter)); - Assert.ThrowsAsync(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] {"https://vault.azure.net/.default"}), CancellationToken.None)); + Assert.ThrowsAsync(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] {TestEnvironment.KeyvaultScope}), CancellationToken.None)); } [Test] @@ -139,7 +151,7 @@ public void AuthenticateWithVscCredential_InvalidRefreshToken() var options = InstrumentClientOptions(new VisualStudioCodeCredentialOptions { TenantId = tenantId }); VisualStudioCodeCredential credential = InstrumentClient(new VisualStudioCodeCredential(options, default, default, fileSystemService, vscAdapter)); - Assert.ThrowsAsync(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] {".default"}), CancellationToken.None)); + Assert.ThrowsAsync(async () => await credential.GetTokenAsync(new TokenRequestContext(new[] { TestEnvironment.KeyvaultScope }), CancellationToken.None)); } } } diff --git a/sdk/identity/tests.yml b/sdk/identity/tests.yml index 283c27f8af09..759ff1c21411 100644 --- a/sdk/identity/tests.yml +++ b/sdk/identity/tests.yml @@ -16,6 +16,7 @@ extends: Selection: sparse GenerateContainerJobs: true ServiceDirectory: identity + Clouds: 'Public,UsGov,China,Canary' PreSteps: - pwsh: Install-Module -Name Az -Scope CurrentUser -AllowClobber -Force -Verbose displayName: Install Azure PowerShell module diff --git a/sdk/keyvault/tests.yml b/sdk/keyvault/tests.yml index f0927b51f621..1f541e42037d 100644 --- a/sdk/keyvault/tests.yml +++ b/sdk/keyvault/tests.yml @@ -5,6 +5,7 @@ extends: parameters: ServiceDirectory: keyvault TimeoutInMinutes: 120 + Clouds: 'Public,Preview,UsGov,China,Canary' EnvVars: # Runs samples with live tests. # THIS VARIABLE IS A ONE-OFF WORKAROUND FOR KEYVAULT TESTS SPECIFICALLY, DON'T COPY IT diff --git a/sdk/search/tests.yml b/sdk/search/tests.yml index 756092dab3ee..8f5ce60a0098 100644 --- a/sdk/search/tests.yml +++ b/sdk/search/tests.yml @@ -6,7 +6,7 @@ extends: ServiceDirectory: search TimeoutInMinutes: 240 MaxParallel: 2 - UnsupportedClouds: 'Canary' - SupportedClouds: 'Public,UsGov,China' + UnsupportedClouds: Canary + Clouds: 'Public,Preview,UsGov,China' EnvVars: AZURE_SEARCH_TEST_MODE: Live diff --git a/sdk/servicebus/tests.data.yml b/sdk/servicebus/tests.data.yml index 547bea6f51ee..c9efc0a92782 100644 --- a/sdk/servicebus/tests.data.yml +++ b/sdk/servicebus/tests.data.yml @@ -7,4 +7,4 @@ extends: ServiceDirectory: servicebus SDKType: data TimeoutInMinutes: 120 - Clouds: 'Public,Canary' + Clouds: 'Public,Preview,UsGov,China,Canary' diff --git a/sdk/servicebus/tests.yml b/sdk/servicebus/tests.yml index 7f7fc126880b..cd7fcc032f9d 100644 --- a/sdk/servicebus/tests.yml +++ b/sdk/servicebus/tests.yml @@ -7,4 +7,4 @@ extends: ServiceDirectory: servicebus SDKType: client TimeoutInMinutes: 120 - Clouds: 'Public,Canary' + Clouds: 'Public,Preview,UsGov,China,Canary' diff --git a/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs b/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs index 28b9b93b3b44..d56e5cdd55de 100644 --- a/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs +++ b/sdk/storage/Azure.Storage.Blobs/tests/ContainerClientTests.cs @@ -2523,7 +2523,8 @@ public async Task GetBlobClient_SpecialCharacters(string blobName) // Arrange await using DisposingContainer test = await GetTestContainerAsync(); - Uri expectedUri = new Uri($"https://{TestConfigDefault.AccountName}.blob.core.windows.net/{test.Container.Name}/{Uri.EscapeDataString(blobName)}"); + string endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; + Uri expectedUri = new Uri($"https://{TestConfigDefault.AccountName}.blob.{endpointSuffix}/{test.Container.Name}/{Uri.EscapeDataString(blobName)}"); BlobClient initalBlob = new BlobClient( TestConfigDefault.ConnectionString, @@ -2572,7 +2573,8 @@ public async Task GetBlobClients_SpecialCharacters(string blobName) { // Arrange await using DisposingContainer test = await GetTestContainerAsync(); - Uri expectedUri = new Uri($"https://{TestConfigDefault.AccountName}.blob.core.windows.net/{test.Container.Name}/{Uri.EscapeDataString(blobName)}"); + string endPointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; + Uri expectedUri = new Uri($"https://{TestConfigDefault.AccountName}.blob.{endPointSuffix}/{test.Container.Name}/{Uri.EscapeDataString(blobName)}"); BlobClient blobClientFromContainer = InstrumentClient(test.Container.GetBlobClient(blobName)); BlobClient blobClientFromConnectionString = new BlobClient( diff --git a/sdk/storage/Azure.Storage.Common/src/Shared/StorageConnectionString.cs b/sdk/storage/Azure.Storage.Common/src/Shared/StorageConnectionString.cs index 2b102eeb69fe..f642fb952e79 100644 --- a/sdk/storage/Azure.Storage.Common/src/Shared/StorageConnectionString.cs +++ b/sdk/storage/Azure.Storage.Common/src/Shared/StorageConnectionString.cs @@ -860,7 +860,7 @@ internal static (Uri, Uri) ConstructBlobEndpoint(string scheme, string accountNa if (string.IsNullOrEmpty(endpointSuffix)) { - endpointSuffix = Constants.ConnectionStrings.DefaultEndpointSuffix; + endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; } return ConstructUris(scheme, accountName, Constants.ConnectionStrings.DefaultBlobHostnamePrefix, endpointSuffix, sasToken); @@ -899,7 +899,7 @@ internal static (Uri, Uri) ConstructFileEndpoint(string scheme, string accountNa if (string.IsNullOrEmpty(endpointSuffix)) { - endpointSuffix = Constants.ConnectionStrings.DefaultEndpointSuffix; + endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; } return ConstructUris(scheme, accountName, Constants.ConnectionStrings.DefaultFileHostnamePrefix, endpointSuffix, sasToken); @@ -938,7 +938,7 @@ internal static (Uri, Uri) ConstructQueueEndpoint(string scheme, string accountN if (string.IsNullOrEmpty(endpointSuffix)) { - endpointSuffix = Constants.ConnectionStrings.DefaultEndpointSuffix; + endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; } return ConstructUris(scheme, accountName, Constants.ConnectionStrings.DefaultQueueHostnamePrefix, endpointSuffix, sasToken); @@ -977,7 +977,7 @@ internal static (Uri, Uri) ConstructTableEndpoint(string scheme, string accountN if (string.IsNullOrEmpty(endpointSuffix)) { - endpointSuffix = Constants.ConnectionStrings.DefaultEndpointSuffix; + endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; } return ConstructUris(scheme, accountName, Constants.ConnectionStrings.DefaultTableHostnamePrefix, endpointSuffix, sasToken); diff --git a/sdk/storage/Azure.Storage.Common/tests/Shared/TestExtensions.cs b/sdk/storage/Azure.Storage.Common/tests/Shared/TestExtensions.cs index 2fe727db4c18..b7f2d24517c6 100644 --- a/sdk/storage/Azure.Storage.Common/tests/Shared/TestExtensions.cs +++ b/sdk/storage/Azure.Storage.Common/tests/Shared/TestExtensions.cs @@ -102,6 +102,10 @@ internal static StorageConnectionString CreateStorageConnectionString( string endpointSuffix = Constants.ConnectionStrings.DefaultEndpointSuffix, bool useHttps = true) { + if (!string.IsNullOrEmpty(endpointSuffix)) + { + endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; + } var conn = new StorageConnectionString(storageCredentials); if (storageCredentials == null) { diff --git a/sdk/storage/Azure.Storage.Common/tests/StorageConnectionStringTests.cs b/sdk/storage/Azure.Storage.Common/tests/StorageConnectionStringTests.cs index 9c321b7d1477..f5832286324d 100644 --- a/sdk/storage/Azure.Storage.Common/tests/StorageConnectionStringTests.cs +++ b/sdk/storage/Azure.Storage.Common/tests/StorageConnectionStringTests.cs @@ -118,20 +118,21 @@ public void DevelopmentStorageAccount() [Description("Regular account with HTTP")] public void DefaultStorageAccountWithHttp() { + string endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; var cred = new StorageSharedKeyCredential(TestConfigurations.DefaultTargetTenant.AccountName, TestConfigurations.DefaultTargetTenant.AccountKey); var conn = TestExtensions.CreateStorageConnectionString(cred, false); Assert.AreEqual(conn.BlobEndpoint, - new Uri(string.Format("http://{0}.blob.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName))); + new Uri(string.Format("http://{0}.blob.{1}", TestConfigurations.DefaultTargetTenant.AccountName, endpointSuffix))); Assert.AreEqual(conn.QueueEndpoint, - new Uri(string.Format("http://{0}.queue.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName))); + new Uri(string.Format("http://{0}.queue.{1}", TestConfigurations.DefaultTargetTenant.AccountName, endpointSuffix))); Assert.AreEqual(conn.FileEndpoint, - new Uri(string.Format("http://{0}.file.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName))); + new Uri(string.Format("http://{0}.file.{1}", TestConfigurations.DefaultTargetTenant.AccountName, endpointSuffix))); Assert.AreEqual(conn.BlobStorageUri.SecondaryUri, - new Uri(string.Format("http://{0}-secondary.blob.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName))); + new Uri(string.Format("http://{0}-secondary.blob.{1}", TestConfigurations.DefaultTargetTenant.AccountName, endpointSuffix))); Assert.AreEqual(conn.QueueStorageUri.SecondaryUri, - new Uri(string.Format("http://{0}-secondary.queue.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName))); + new Uri(string.Format("http://{0}-secondary.queue.{1}", TestConfigurations.DefaultTargetTenant.AccountName, endpointSuffix))); Assert.AreEqual(conn.FileStorageUri.SecondaryUri, - new Uri(string.Format("http://{0}-secondary.file.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName))); + new Uri(string.Format("http://{0}-secondary.file.{1}", TestConfigurations.DefaultTargetTenant.AccountName, endpointSuffix))); _ = conn.ToString(); var storageConnectionStringToStringWithSecrets = conn.ToString(true); var testAccount = StorageConnectionString.Parse(storageConnectionStringToStringWithSecrets); @@ -144,20 +145,21 @@ public void DefaultStorageAccountWithHttp() [Description("Regular account with HTTPS")] public void DefaultStorageAccountWithHttps() { + string endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; var cred = new StorageSharedKeyCredential(TestConfigurations.DefaultTargetTenant.AccountName, TestConfigurations.DefaultTargetTenant.AccountKey); var conn = TestExtensions.CreateStorageConnectionString(cred, true); Assert.AreEqual(conn.BlobEndpoint, - new Uri(string.Format("https://{0}.blob.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName))); + new Uri(string.Format("https://{0}.blob.{1}", TestConfigurations.DefaultTargetTenant.AccountName, endpointSuffix))); Assert.AreEqual(conn.QueueEndpoint, - new Uri(string.Format("https://{0}.queue.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName))); + new Uri(string.Format("https://{0}.queue.{1}", TestConfigurations.DefaultTargetTenant.AccountName, endpointSuffix))); Assert.AreEqual(conn.FileEndpoint, - new Uri(string.Format("https://{0}.file.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName))); + new Uri(string.Format("https://{0}.file.{1}", TestConfigurations.DefaultTargetTenant.AccountName, endpointSuffix))); Assert.AreEqual(conn.BlobStorageUri.SecondaryUri, - new Uri(string.Format("https://{0}-secondary.blob.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName))); + new Uri(string.Format("https://{0}-secondary.blob.{1}", TestConfigurations.DefaultTargetTenant.AccountName, endpointSuffix))); Assert.AreEqual(conn.QueueStorageUri.SecondaryUri, - new Uri(string.Format("https://{0}-secondary.queue.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName))); + new Uri(string.Format("https://{0}-secondary.queue.{1}", TestConfigurations.DefaultTargetTenant.AccountName, endpointSuffix))); Assert.AreEqual(conn.FileStorageUri.SecondaryUri, - new Uri(string.Format("https://{0}-secondary.file.core.windows.net", TestConfigurations.DefaultTargetTenant.AccountName))); + new Uri(string.Format("https://{0}-secondary.file.{1}", TestConfigurations.DefaultTargetTenant.AccountName, endpointSuffix))); var storageConnectionStringToStringWithSecrets = conn.ToString(true); var testAccount = StorageConnectionString.Parse(storageConnectionStringToStringWithSecrets); diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs index 4765cedc9923..0cedc12df025 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/DirectoryClientTests.cs @@ -785,10 +785,11 @@ await TestHelper.AssertExpectedExceptionAsync( public async Task RenameAsync_DestinationSpecialCharacters(string destDirectoryName) { await using DisposingFileSystem test = await GetNewFileSystem(); + string endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; // Arrange DataLakeDirectoryClient sourceDirectory = await test.FileSystem.CreateDirectoryAsync(GetNewDirectoryName()); - Uri expectedDestDirectoryUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.core.windows.net/{test.FileSystem.Name}/{Uri.EscapeDataString(destDirectoryName)}"); + Uri expectedDestDirectoryUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.{endpointSuffix}/{test.FileSystem.Name}/{Uri.EscapeDataString(destDirectoryName)}"); // Act DataLakeDirectoryClient destDirectory = await sourceDirectory.RenameAsync(destinationPath: destDirectoryName); @@ -808,11 +809,12 @@ public async Task RenameAsync_DestinationSpecialCharacters(string destDirectoryN public async Task RenameAsync_SourceSpecialCharacters(string sourceDirectoryName) { await using DisposingFileSystem test = await GetNewFileSystem(); + string endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; // Arrange string destDirectoryName = GetNewDirectoryName(); DataLakeDirectoryClient sourceDirectory = await test.FileSystem.CreateDirectoryAsync(sourceDirectoryName); - Uri expectedDestDirectoryUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.core.windows.net/{test.FileSystem.Name}/{destDirectoryName}"); + Uri expectedDestDirectoryUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.{endpointSuffix}/{test.FileSystem.Name}/{destDirectoryName}"); // Act DataLakeDirectoryClient destDirectory = await sourceDirectory.RenameAsync(destinationPath: destDirectoryName); @@ -4733,8 +4735,10 @@ public async Task GetSubDirectoryClient_SpecialCharacters(string directoryName, DataLakeDirectoryClient directory = await test.FileSystem.CreateDirectoryAsync(directoryName); DataLakeDirectoryClient subDirectory = InstrumentClient(directory.GetSubDirectoryClient(subDirectoryName)); - Uri blobUri = new Uri($"https://{test.FileSystem.AccountName}.blob.core.windows.net/{test.FileSystem.Name}/{Uri.EscapeDataString(directoryName)}/{Uri.EscapeDataString(subDirectoryName)}"); - Uri dfsUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.core.windows.net/{test.FileSystem.Name}/{Uri.EscapeDataString(directoryName)}/{Uri.EscapeDataString(subDirectoryName)}"); + + string endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; + Uri blobUri = new Uri($"https://{test.FileSystem.AccountName}.blob.{endpointSuffix}/{test.FileSystem.Name}/{Uri.EscapeDataString(directoryName)}/{Uri.EscapeDataString(subDirectoryName)}"); + Uri dfsUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.{endpointSuffix}/{test.FileSystem.Name}/{Uri.EscapeDataString(directoryName)}/{Uri.EscapeDataString(subDirectoryName)}"); string expectedPath = $"{directoryName}/{subDirectoryName}"; // Act @@ -4779,8 +4783,11 @@ public async Task GetFileClient_SpecialCharacters(string directoryName, string f await using DisposingFileSystem test = await GetNewFileSystem(); DataLakeDirectoryClient directory = await test.FileSystem.CreateDirectoryAsync(directoryName); DataLakeFileClient file = InstrumentClient(directory.GetFileClient(fileName)); - Uri blobUri = new Uri($"https://{test.FileSystem.AccountName}.blob.core.windows.net/{test.FileSystem.Name}/{Uri.EscapeDataString(directoryName)}/{Uri.EscapeDataString(fileName)}"); - Uri dfsUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.core.windows.net/{test.FileSystem.Name}/{Uri.EscapeDataString(directoryName)}/{Uri.EscapeDataString(fileName)}"); + + string endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; + Uri blobUri = new Uri($"https://{test.FileSystem.AccountName}.blob.{endpointSuffix}/{test.FileSystem.Name}/{Uri.EscapeDataString(directoryName)}/{Uri.EscapeDataString(fileName)}"); + Uri dfsUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.{endpointSuffix}/{test.FileSystem.Name}/{Uri.EscapeDataString(directoryName)}/{Uri.EscapeDataString(fileName)}"); + string expectedPath = $"{directoryName}/{fileName}"; // Act diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs index 35477734f2ee..c8393b8fdf42 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileClientTests.cs @@ -764,10 +764,11 @@ public async Task RenameAsync_DestinationSpecialCharacters(string destFileName) // Arrange await using DisposingFileSystem test = await GetNewFileSystem(); string directoryName = GetNewDirectoryName(); + string endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; DataLakeDirectoryClient directory = InstrumentClient(test.FileSystem.GetDirectoryClient(directoryName)); await directory.CreateAsync(); DataLakeFileClient sourceFile = await test.FileSystem.CreateFileAsync(GetNewFileName()); - Uri expectedDestFileUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.core.windows.net/{test.FileSystem.Name}/{directoryName}/{Uri.EscapeDataString(destFileName)}"); + Uri expectedDestFileUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.{endpointSuffix}/{test.FileSystem.Name}/{directoryName}/{Uri.EscapeDataString(destFileName)}"); string destFilePath = $"{directoryName}/{destFileName}"; // Act @@ -789,12 +790,13 @@ public async Task RenameAsync_SourceSpecialCharacters(string sourceFileName) { // Arrange await using DisposingFileSystem test = await GetNewFileSystem(); + string endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; string directoryName = GetNewDirectoryName(); DataLakeDirectoryClient directory = InstrumentClient(test.FileSystem.GetDirectoryClient(directoryName)); await directory.CreateAsync(); DataLakeFileClient sourceFile = await test.FileSystem.CreateFileAsync(sourceFileName); string destFileName = GetNewFileName(); - Uri expectedDestFileUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.core.windows.net/{test.FileSystem.Name}/{directoryName}/{destFileName}"); + Uri expectedDestFileUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.{endpointSuffix}/{test.FileSystem.Name}/{directoryName}/{destFileName}"); string destFilePath = $"{directoryName}/{destFileName}"; // Act diff --git a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs index f76752e1705e..615263d983a9 100644 --- a/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.DataLake/tests/FileSystemClientTests.cs @@ -1989,8 +1989,10 @@ public async Task GetDirectoryClient_SpecialCharacters(string directoryName) // Arrange await using DisposingFileSystem test = await GetNewFileSystem(); DataLakeDirectoryClient directory = InstrumentClient(test.FileSystem.GetDirectoryClient(directoryName)); - Uri blobUri = new Uri($"https://{test.FileSystem.AccountName}.blob.core.windows.net/{test.FileSystem.Name}/{Uri.EscapeDataString(directoryName)}"); - Uri dfsUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.core.windows.net/{test.FileSystem.Name}/{Uri.EscapeDataString(directoryName)}"); + + string endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; + Uri blobUri = new Uri($"https://{test.FileSystem.AccountName}.blob.{endpointSuffix}/{test.FileSystem.Name}/{Uri.EscapeDataString(directoryName)}"); + Uri dfsUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.{endpointSuffix}/{test.FileSystem.Name}/{Uri.EscapeDataString(directoryName)}"); // Act Response createResponse = await directory.CreateAsync(); @@ -2027,8 +2029,10 @@ public async Task GetFileClient_SpecialCharacters(string fileName) // Arrange await using DisposingFileSystem test = await GetNewFileSystem(); DataLakeFileClient file = InstrumentClient(test.FileSystem.GetFileClient(fileName)); - Uri blobUri = new Uri($"https://{test.FileSystem.AccountName}.blob.core.windows.net/{test.FileSystem.Name}/{Uri.EscapeDataString(fileName)}"); - Uri dfsUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.core.windows.net/{test.FileSystem.Name}/{Uri.EscapeDataString(fileName)}"); + + string endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; + Uri blobUri = new Uri($"https://{test.FileSystem.AccountName}.blob.{endpointSuffix}/{test.FileSystem.Name}/{Uri.EscapeDataString(fileName)}"); + Uri dfsUri = new Uri($"https://{test.FileSystem.AccountName}.dfs.{endpointSuffix}/{test.FileSystem.Name}/{Uri.EscapeDataString(fileName)}"); // Act Response createResponse = await file.CreateAsync(); diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs b/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs index 65d5102e0dd6..dc581b2670a6 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/DirectoryClientTests.cs @@ -1050,7 +1050,8 @@ public async Task GetFileClient_SpecialCharacters(string directoryName, string f ShareFileClient fileFromDirectoryClient = InstrumentClient(directoryClient.GetFileClient(fileName)); Response createResponse = await fileFromDirectoryClient.CreateAsync(Constants.KB); - Uri expectedUri = new Uri($"https://{TestConfigDefault.AccountName}.file.core.windows.net/{test.Share.Name}/{Uri.EscapeDataString(directoryName)}/{Uri.EscapeDataString(fileName)}"); + string endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; + Uri expectedUri = new Uri($"https://{TestConfigDefault.AccountName}.file.{endpointSuffix}/{test.Share.Name}/{Uri.EscapeDataString(directoryName)}/{Uri.EscapeDataString(fileName)}"); ShareFileClient fileFromConstructor = new ShareFileClient( TestConfigDefault.ConnectionString, @@ -1113,7 +1114,8 @@ public async Task GetSubDirectoryClient_SpecialCharacters(string directoryName, ShareDirectoryClient directoryFromDirectoryClient = InstrumentClient(directoryClient.GetSubdirectoryClient(subDirectoryName)); Response createResponse = await directoryFromDirectoryClient.CreateAsync(); - Uri expectedUri = new Uri($"https://{TestConfigDefault.AccountName}.file.core.windows.net/{test.Share.Name}/{Uri.EscapeDataString(directoryName)}/{Uri.EscapeDataString(subDirectoryName)}"); + string endPointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; + Uri expectedUri = new Uri($"https://{TestConfigDefault.AccountName}.file.{endPointSuffix}/{test.Share.Name}/{Uri.EscapeDataString(directoryName)}/{Uri.EscapeDataString(subDirectoryName)}"); ShareDirectoryClient directoryFromConstructor = new ShareDirectoryClient( TestConfigDefault.ConnectionString, diff --git a/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs b/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs index 76ba0f170381..fee42e09abdb 100644 --- a/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs +++ b/sdk/storage/Azure.Storage.Files.Shares/tests/ShareClientTests.cs @@ -1621,7 +1621,9 @@ public async Task GetDirectoryClient_SpecialCharacters(string directoryName) // Arrange await using DisposingShare test = await GetTestShareAsync(); ShareDirectoryClient directoryFromShareClient = InstrumentClient(test.Share.GetDirectoryClient(directoryName)); - Uri expectedUri = new Uri($"https://{TestConfigDefault.AccountName}.file.core.windows.net/{test.Share.Name}/{Uri.EscapeDataString(directoryName)}"); + + string endpointSuffix = Environment.GetEnvironmentVariable("STORAGE_ENDPOINT_SUFFIX") ?? Constants.ConnectionStrings.DefaultEndpointSuffix; + Uri expectedUri = new Uri($"https://{TestConfigDefault.AccountName}.file.{endpointSuffix}/{test.Share.Name}/{Uri.EscapeDataString(directoryName)}"); // Act Response createResponse = await directoryFromShareClient.CreateAsync(); diff --git a/sdk/storage/test-resources-post.ps1 b/sdk/storage/test-resources-post.ps1 index 5624064ad09c..910de0df95a1 100644 --- a/sdk/storage/test-resources-post.ps1 +++ b/sdk/storage/test-resources-post.ps1 @@ -22,6 +22,8 @@ $PremiumAccountName = $DeploymentOutputs['PREMIUM_STORAGE_ACCOUNT_NAME'] $PremiumAccountKey = $DeploymentOutputs['PREMIUM_STORAGE_ACCOUNT_KEY'] $DataLakeAccountName = $DeploymentOutputs['DATALAKE_STORAGE_ACCOUNT_NAME'] $DataLakeAccountKey = $DeploymentOutputs['DATALAKE_STORAGE_ACCOUNT_KEY'] +$StorageEndpointSuffix = $DeploymentOutputs['STORAGE_ENDPOINT_SUFFIX'] +$AzureAuthorityHost = $DeploymentOutputs['AZURE_AUTHORITY_HOST'] $SoftDeleteAccountName = $DeploymentOutputs['SOFT_DELETE_ACCOUNT_NAME'] $SoftDeleteAccountKey = $DeploymentOutputs['SOFT_DELETE_ACCOUNT_KEY'] $PremiumFileAccountName = $DeploymentOutputs['PREMIUM_FILE_STORAGE_ACCOUNT_NAME'] @@ -46,44 +48,44 @@ $content = Cloud $PrimaryAccountName $PrimaryAccountKey - https://$PrimaryAccountName.blob.core.windows.net - https://$PrimaryAccountName.queue.core.windows.net - https://$PrimaryAccountName.table.core.windows.net - https://$PrimaryAccountName.file.core.windows.net - https://$PrimaryAccountName-secondary.blob.core.windows.net - https://$PrimaryAccountName-secondary.queue.core.windows.net - https://$PrimaryAccountName-secondary.file.core.windows.net - https://$PrimaryAccountName-secondary.table.core.windows.net - DefaultEndpointsProtocol=https;AccountName=$PrimaryAccountName;AccountKey=$PrimaryAccountKey;EndpointSuffix=core.windows.net + https://$PrimaryAccountName.blob.$StorageEndpointSuffix + https://$PrimaryAccountName.queue.$StorageEndpointSuffix + https://$PrimaryAccountName.table.$StorageEndpointSuffix + https://$PrimaryAccountName.file.$StorageEndpointSuffix + https://$PrimaryAccountName-secondary.blob.$StorageEndpointSuffix + https://$PrimaryAccountName-secondary.queue.$StorageEndpointSuffix + https://$PrimaryAccountName-secondary.file.$StorageEndpointSuffix + https://$PrimaryAccountName-secondary.table.$StorageEndpointSuffix + DefaultEndpointsProtocol=https;AccountName=$PrimaryAccountName;AccountKey=$PrimaryAccountKey;EndpointSuffix=$StorageEndpointSuffix PremiumTenant Cloud $PremiumAccountName $PremiumAccountKey - https://$PremiumAccountName.blob.core.windows.net - https://$PremiumAccountName.queue.core.windows.net - https://$PremiumAccountName.table.core.windows.net - https://$PremiumAccountName.file.core.windows.net - https://$PremiumAccountName-secondary.blob.core.windows.net - https://$PremiumAccountName-secondary.queue.core.windows.net - https://$PremiumAccountName-secondary.file.core.windows.net - https://$PremiumAccountName-secondary.table.core.windows.net - DefaultEndpointsProtocol=https;AccountName=$PremiumAccountName;AccountKey=$PremiumAccountKey;EndpointSuffix=core.windows.net + https://$PremiumAccountName.blob.$StorageEndpointSuffix + https://$PremiumAccountName.queue.$StorageEndpointSuffix + https://$PremiumAccountName.table.$StorageEndpointSuffix + https://$PremiumAccountName.file.$StorageEndpointSuffix + https://$PremiumAccountName-secondary.blob.$StorageEndpointSuffix + https://$PremiumAccountName-secondary.queue.$StorageEndpointSuffix + https://$PremiumAccountName-secondary.file.$StorageEndpointSuffix + https://$PremiumAccountName-secondary.table.$StorageEndpointSuffix + DefaultEndpointsProtocol=https;AccountName=$PremiumAccountName;AccountKey=$PremiumAccountKey;EndpointSuffix=$StorageEndpointSuffix ProductionTenant2 Cloud $SecondaryAccountName $SecondaryAccountKey - https://$SecondaryAccountName.blob.core.windows.net - https://$SecondaryAccountName.queue.core.windows.net - https://$SecondaryAccountName.table.core.windows.net - https://$SecondaryAccountName.file.core.windows.net - https://$SecondaryAccountName-secondary.blob.core.windows.net - https://$SecondaryAccountName-secondary.queue.core.windows.net - https://$SecondaryAccountName-secondary.file.core.windows.net - https://$SecondaryAccountName-secondary.table.core.windows.net + https://$SecondaryAccountName.blob.$StorageEndpointSuffix + https://$SecondaryAccountName.queue.$StorageEndpointSuffix + https://$SecondaryAccountName.table.$StorageEndpointSuffix + https://$SecondaryAccountName.file.$StorageEndpointSuffix + https://$SecondaryAccountName-secondary.blob.$StorageEndpointSuffix + https://$SecondaryAccountName-secondary.queue.$StorageEndpointSuffix + https://$SecondaryAccountName-secondary.file.$StorageEndpointSuffix + https://$SecondaryAccountName-secondary.table.$StorageEndpointSuffix OAuthTenant @@ -93,16 +95,16 @@ $content = $TestApplicationId $TestApplicationSecret $TenantId - https://login.microsoftonline.com/ - https://$PrimaryAccountName.blob.core.windows.net - https://$PrimaryAccountName.queue.core.windows.net - https://$PrimaryAccountName.table.core.windows.net - https://$PrimaryAccountName.file.core.windows.net - https://$PrimaryAccountName-secondary.blob.core.windows.net - https://$PrimaryAccountName-secondary.queue.core.windows.net - https://$PrimaryAccountName-secondary.file.core.windows.net - https://$PrimaryAccountName-secondary.table.core.windows.net - DefaultEndpointsProtocol=https;AccountName=$PrimaryAccountName;AccountKey=$PrimaryAccountKey;EndpointSuffix=core.windows.net + $AzureAuthorityHost + https://$PrimaryAccountName.blob.$StorageEndpointSuffix + https://$PrimaryAccountName.queue.$StorageEndpointSuffix + https://$PrimaryAccountName.table.$StorageEndpointSuffix + https://$PrimaryAccountName.file.$StorageEndpointSuffix + https://$PrimaryAccountName-secondary.blob.$StorageEndpointSuffix + https://$PrimaryAccountName-secondary.queue.$StorageEndpointSuffix + https://$PrimaryAccountName-secondary.file.$StorageEndpointSuffix + https://$PrimaryAccountName-secondary.table.$StorageEndpointSuffix + DefaultEndpointsProtocol=https;AccountName=$PrimaryAccountName;AccountKey=$PrimaryAccountKey;EndpointSuffix=$StorageEndpointSuffix NamespaceTenant @@ -112,29 +114,29 @@ $content = $TestApplicationId $TestApplicationSecret $TenantId - https://login.microsoftonline.com/ - https://$DataLakeAccountName.blob.core.windows.net - https://$DataLakeAccountName.queue.core.windows.net - https://$DataLakeAccountName.table.core.windows.net - https://$DataLakeAccountName.file.core.windows.net - https://$DataLakeAccountName-secondary.blob.core.windows.net - https://$DataLakeAccountName-secondary.queue.core.windows.net - https://$DataLakeAccountName-secondary.file.core.windows.net - https://$DataLakeAccountName-secondary.table.core.windows.net + $AzureAuthorityHost + https://$DataLakeAccountName.blob.$StorageEndpointSuffix + https://$DataLakeAccountName.queue.$StorageEndpointSuffix + https://$DataLakeAccountName.table.$StorageEndpointSuffix + https://$DataLakeAccountName.file.$StorageEndpointSuffix + https://$DataLakeAccountName-secondary.blob.$StorageEndpointSuffix + https://$DataLakeAccountName-secondary.queue.$StorageEndpointSuffix + https://$DataLakeAccountName-secondary.file.$StorageEndpointSuffix + https://$DataLakeAccountName-secondary.table.$StorageEndpointSuffix SoftDeleteTenant Cloud $SoftDeleteAccountName $SoftDeleteAccountKey - https://$SoftDeleteAccountName.blob.core.windows.net - https://$SoftDeleteAccountName.queue.core.windows.net - https://$SoftDeleteAccountName.table.core.windows.net - https://$SoftDeleteAccountName.file.core.windows.net - https://$SoftDeleteAccountName-secondary.blob.core.windows.net - https://$SoftDeleteAccountName-secondary.queue.core.windows.net - https://$SoftDeleteAccountName-secondary.file.core.windows.net - https://$SoftDeleteAccountName-secondary.table.core.windows.net + https://$SoftDeleteAccountName.blob.$StorageEndpointSuffix + https://$SoftDeleteAccountName.queue.$StorageEndpointSuffix + https://$SoftDeleteAccountName.table.$StorageEndpointSuffix + https://$SoftDeleteAccountName.file.$StorageEndpointSuffix + https://$SoftDeleteAccountName-secondary.blob.$StorageEndpointSuffix + https://$SoftDeleteAccountName-secondary.queue.$StorageEndpointSuffix + https://$SoftDeleteAccountName-secondary.file.$StorageEndpointSuffix + https://$SoftDeleteAccountName-secondary.table.$StorageEndpointSuffix PremiumFileTenant @@ -158,7 +160,7 @@ $content = $TestApplicationId $TestApplicationSecret $TenantId - https://login.microsoftonline.com/ + $AzureAuthorityHost " diff --git a/sdk/storage/test-resources.json b/sdk/storage/test-resources.json index 18cc1d9071f6..644ef199e819 100644 --- a/sdk/storage/test-resources.json +++ b/sdk/storage/test-resources.json @@ -17,6 +17,41 @@ "metadata": { "description": "The principal to assign the role to. This is application object id." } + }, + "storageEndpointSuffix": { + "type": "string", + "defaultValue": "core.windows.net", + "metadata": { + "description": "The storage endpoint suffix. Its value will be changed for different clouds test." + } + }, + "keyVaultEndpointSuffix": { + "defaultValue": ".vault.azure.net", + "type": "string", + "metadata": { + "description": "Endpoint suffix for sovereign clouds, requies the preceeding '.'. The default uses the public Azure Cloud (.vault.azure.net)" + } + }, + "azureAuthorityHost": { + "type": "string", + "defaultValue": "https://login.microsoftonline.com", + "metadata": { + "description": "The azure authority host. Its value will be changed for different clouds test." + } + }, + "keyVaultSku": { + "type": "string", + "defaultValue": "premium", + "metadata": { + "description": "Key Vault SKU to deploy. The default is 'premium'" + } + }, + "enableStorageVersioning": { + "type": "bool", + "metadata": { + "description": "Enable Versioning enabled setting, default value is true" + }, + "defaultValue": true } }, "variables": { @@ -35,7 +70,7 @@ "webjobsPrimaryAccountName": "[concat(parameters('baseName'), 'wjprim')]", "webjobsSecondaryAccountName": "[concat(parameters('baseName'), 'wjsec')]", "keyvaultName": "[concat(parameters('baseName'), 'kvlt')]", - "azureKeyVaultUrl": "[format('https://{0}.vault.azure.net', variables('keyvaultName'))]", + "azureKeyVaultUrl": "[format('https://{0}{1}', variables('keyvaultName'), parameters('keyVaultEndpointSuffix'))]", "location": "[resourceGroup().location]", "encryption": { "services": { @@ -53,7 +88,21 @@ "virtualNetworkRules": [], "ipRules": [], "defaultAction": "Allow" - } + }, + "versioningEnableProperties": { + "isVersioningEnabled": true, + "lastAccessTimeTrackingPolicy": { + "enable": true, + "name": "AccessTimeTracking", + "trackingGranularityInDays": 1, + "blobType": [ + "blockBlob" + ] + } + }, + "nullProperties": { + }, + "locationsProperty": "[if(parameters('enableStorageVersioning'), variables('versioningEnableProperties'), variables('nullProperties'))]" }, "resources": [ { @@ -113,17 +162,7 @@ "type": "Microsoft.Storage/storageAccounts/blobServices", "apiVersion": "[variables('mgmtApiVersion')]", "name": "[concat(variables('primaryAccountName'), '/default')]", - "properties": { - "isVersioningEnabled": true, - "lastAccessTimeTrackingPolicy": { - "enable": true, - "name": "AccessTimeTracking", - "trackingGranularityInDays": 1, - "blobType": [ - "blockBlob" - ] - } - }, + "properties": "[variables('locationsProperty')]", "dependsOn": [ "[variables('primaryAccountName')]" ] @@ -302,7 +341,7 @@ "properties": { "sku": { "family": "A", - "name": "premium" + "name": "[parameters('keyVaultSku')]" }, "tenantId": "[parameters('tenantId')]", "accessPolicies": [ @@ -407,6 +446,14 @@ "type": "string", "value": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('dataLakeAccountName')), variables('mgmtApiVersion')).keys[0].value]" }, + "STORAGE_ENDPOINT_SUFFIX": { + "type": "string", + "value": "[parameters('storageEndpointSuffix')]" + }, + "AZURE_AUTHORITY_HOST": { + "type": "string", + "value": "[parameters('azureAuthorityHost')]" + }, "SOFT_DELETE_ACCOUNT_NAME": { "type": "string", "value": "[variables('softDeleteAccountName')]" diff --git a/sdk/storage/tests.yml b/sdk/storage/tests.yml index 3ee45fe51ffd..072e66ed2288 100644 --- a/sdk/storage/tests.yml +++ b/sdk/storage/tests.yml @@ -6,8 +6,15 @@ extends: ServiceDirectory: storage BuildInParallel: true TimeoutInMinutes: 180 - Location: canadacentral - Clouds: Preview + CloudConfig: + Preview: + SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources-preview-test) + Location: 'canadacentral' + UsGov: + SubscriptionConfiguration: $(sub-config-gov-test-resources-test) + China: + SubscriptionConfiguration: $(sub-config-cn-test-resources-test) + Clouds: 'Preview,UsGov,China' TestSetupSteps: - template: /sdk/storage/tests-install-azurite.yml EnvVars: diff --git a/sdk/tables/test-resources.json b/sdk/tables/test-resources.json index b19d8f98dd2d..b8a484d848c9 100644 --- a/sdk/tables/test-resources.json +++ b/sdk/tables/test-resources.json @@ -74,7 +74,7 @@ }, "locations": [ { - "locationName": "[variables('location')]", + "locationName": "[parameters('cosmosdblocation')]", "provisioningState": "Succeeded", "failoverPriority": 0, "isZoneRedundant": false diff --git a/sdk/tables/tests.yml b/sdk/tables/tests.yml index 90a0c125b70a..28f4fea455c8 100644 --- a/sdk/tables/tests.yml +++ b/sdk/tables/tests.yml @@ -5,3 +5,4 @@ extends: parameters: ServiceDirectory: tables TimeoutInMinutes: 120 + Clouds: 'Public,Preview,UsGov,China' diff --git a/sdk/textanalytics/test-resources.json b/sdk/textanalytics/test-resources.json index e853ca16271d..3851ecca2625 100644 --- a/sdk/textanalytics/test-resources.json +++ b/sdk/textanalytics/test-resources.json @@ -44,15 +44,25 @@ "defaultValue": "textanalytics", "type": "string" }, - "endpointSuffix": { + "cognitiveServicesEndpointSuffix": { "defaultValue": ".cognitiveservices.azure.com", - "type": "string" + "type": "string", + "metadata": { + "description": "Endpoint suffix for sovereign clouds, requies the preceeding '.'. The default uses the public Azure Cloud (.cognitiveservices.azure.com)" + } + }, + "textAnalyticsSku": { + "type": "string", + "defaultValue": "S", + "metadata": { + "description": "Text Analytics SKU to deploy. The default is 'S'" + } } }, "variables": { "roleDefinitionId": "[concat('/subscriptions/', subscription().subscriptionId, '/providers/Microsoft.Authorization/roleDefinitions/a97b65f3-24c7-4388-baec-2e87135dc908')]", "uniqueSubDomainName": "[format('{0}-{1}', parameters('baseName'), parameters('endpointPrefix'))]", - "endpointValue": "[format('https://{0}-{1}{2}', parameters('baseName'), parameters('endpointPrefix'), parameters('endpointSuffix'))]" + "endpointValue": "[format('https://{0}-{1}{2}', parameters('baseName'), parameters('endpointPrefix'), parameters('cognitiveServicesEndpointSuffix'))]" }, "resources": [ { @@ -61,7 +71,7 @@ "name": "[variables('uniqueSubDomainName')]", "location":"[parameters('location')]", "sku": { - "name": "S" + "name": "[parameters('textAnalyticsSku')]" }, "kind": "TextAnalytics", "properties": { diff --git a/sdk/textanalytics/tests.yml b/sdk/textanalytics/tests.yml index 0214321c2d5d..b1e1125e0ea7 100644 --- a/sdk/textanalytics/tests.yml +++ b/sdk/textanalytics/tests.yml @@ -9,4 +9,8 @@ extends: SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources) Canary: SubscriptionConfiguration: $(sub-config-azure-cloud-test-resources) - Location: 'centraluseuap' \ No newline at end of file + Location: 'centraluseuap' + UsGov: + SubscriptionConfiguration: $(sub-config-gov-test-resources-test) + Clouds: 'Public,Canary,UsGov' + UnsupportedClouds: 'China'