本文整理汇总了Java中com.microsoft.azure.AzureEnvironment类的典型用法代码示例。如果您正苦于以下问题:Java AzureEnvironment类的具体用法?Java AzureEnvironment怎么用?Java AzureEnvironment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AzureEnvironment类属于com.microsoft.azure包,在下文中一共展示了AzureEnvironment类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAzureEnvironment
import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
protected AzureEnvironment getAzureEnvironment(String environment) {
if (StringUtils.isEmpty(environment)) {
return AzureEnvironment.AZURE;
}
switch (environment.toUpperCase(Locale.ENGLISH)) {
case "AZURE_CHINA":
return AzureEnvironment.AZURE_CHINA;
case "AZURE_GERMANY":
return AzureEnvironment.AZURE_GERMANY;
case "AZURE_US_GOVERNMENT":
return AzureEnvironment.AZURE_US_GOVERNMENT;
default:
return AzureEnvironment.AZURE;
}
}
示例2: main
import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
/**
* Main entry point.
* @param args the parameters
*/
public static void main(String[] args) {
try {
final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));
ApplicationTokenCredentials credentials = ApplicationTokenCredentials.fromFile(credFile);
RestClient restClient = new RestClient.Builder()
.withBaseUrl(AzureEnvironment.AZURE, AzureEnvironment.Endpoint.RESOURCE_MANAGER)
.withSerializerAdapter(new AzureJacksonAdapter())
.withReadTimeout(150, TimeUnit.SECONDS)
.withLogLevel(LogLevel.BODY)
.withResponseBuilderFactory(new AzureResponseBuilder.Factory())
.withCredentials(credentials).build();
Azure azure = Azure.authenticate(restClient, credentials.domain(), credentials.defaultSubscriptionId()).withDefaultSubscription();
// Print selected subscription
System.out.println("Selected subscription: " + azure.subscriptionId());
runSample(azure);
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
示例3: main
import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
/**
* Main entry point.
* @param args the parameters
*/
public static void main(String[] args) {
try {
final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));
ApplicationTokenCredentials credentials = ApplicationTokenCredentials.fromFile(credFile);
RestClient restClient = new RestClient.Builder()
.withBaseUrl(AzureEnvironment.AZURE, AzureEnvironment.Endpoint.RESOURCE_MANAGER)
.withSerializerAdapter(new AzureJacksonAdapter())
.withReadTimeout(150, TimeUnit.SECONDS)
.withLogLevel(LogLevel.BODY)
.withResponseBuilderFactory(new AzureResponseBuilder.Factory())
.withCredentials(credentials).build();
Azure azure = Azure.authenticate(restClient, credentials.domain(), credentials.defaultSubscriptionId()).withDefaultSubscription();
// Print selected subscription
System.out.println("Selected subscription: " + azure.subscriptionId());
runSample(azure);
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
示例4: main
import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
/**
* Main entry point.
* @param args the parameters
*/
public static void main(String[] args) {
try {
final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));
ApplicationTokenCredentials credentials = ApplicationTokenCredentials.fromFile(credFile);
RestClient restClient = new RestClient.Builder()
.withBaseUrl(AzureEnvironment.AZURE, AzureEnvironment.Endpoint.RESOURCE_MANAGER)
.withSerializerAdapter(new AzureJacksonAdapter())
.withResponseBuilderFactory(new AzureResponseBuilder.Factory())
.withReadTimeout(150, TimeUnit.SECONDS)
.withLogLevel(LogLevel.BODY)
.withCredentials(credentials).build();
Azure azure = Azure.authenticate(restClient, credentials.domain(), credentials.defaultSubscriptionId()).withDefaultSubscription();
// Print selected subscription
System.out.println("Selected subscription: " + azure.subscriptionId());
runSample(azure);
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
示例5: main
import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
/**
* Main entry point.
* @param args the parameters
*/
public static void main(String[] args) {
try {
final File credFile = new File(System.getenv("AZURE_AUTH_LOCATION"));
ApplicationTokenCredentials credentials = ApplicationTokenCredentials.fromFile(credFile);
RestClient restClient = new RestClient.Builder()
.withBaseUrl(AzureEnvironment.AZURE, AzureEnvironment.Endpoint.RESOURCE_MANAGER)
.withSerializerAdapter(new AzureJacksonAdapter())
.withReadTimeout(150, TimeUnit.SECONDS)
.withLogLevel(LogLevel.BODY)
.withResponseBuilderFactory(new AzureResponseBuilder.Factory())
.withCredentials(credentials).build();
Azure azure = Azure.authenticate(restClient, credentials.domain(), credentials.defaultSubscriptionId()).withDefaultSubscription();
// Print selected subscription
System.out.println("Selected subscription: " + azure.subscriptionId());
runSample(azure);
} catch (Exception e) {
System.out.println(e.getMessage());
e.printStackTrace();
}
}
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:29,代码来源:ManageSqlDatabasesAcrossDifferentDataCenters.java
示例6: getAzureConfig
import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
/**
* Configures authentication credential for Azure.
*/
public static ApplicationTokenCredentials getAzureConfig(
AuthCredentialsServiceState parentAuth) {
String clientId = parentAuth.privateKeyId;
String clientKey = EncryptionUtils.decrypt(parentAuth.privateKey);
String tenantId = parentAuth.customProperties.get(AzureConstants.AZURE_TENANT_ID);
AzureEnvironment azureEnvironment = AzureEnvironment.AZURE;
if (AzureUtils.isAzureClientMock()) {
azureEnvironment.endpoints().put(AzureEnvironment.Endpoint.ACTIVE_DIRECTORY.toString(),
AzureUtils.getAzureBaseUri());
}
return new ApplicationTokenCredentials(clientId, tenantId, clientKey, azureEnvironment);
}
示例7: getAzureEnvironmentFromDeprecatedConfig
import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
/**
* Gets the corresponding AzureEnvironment from the deprecated plugin v1 management url.
*
* N.b. that Azure China is currently not supported.
*
* @param managementUrl plugin v1 endpoint
* @return the AzureEnvironment or null if it doesn't exist
*/
static AzureEnvironment getAzureEnvironmentFromDeprecatedConfig(String managementUrl) {
if (managementUrl == null) {
return null;
}
managementUrl = managementUrl.replaceAll("/$", "");
if (managementUrl.equals(AzureEnvironment.AZURE.managementEndpoint().replaceAll("/$", ""))) {
return AzureEnvironment.AZURE;
} else if (managementUrl.equals(AzureEnvironment.AZURE_US_GOVERNMENT.managementEndpoint()
.replaceAll("/$", ""))) {
return AzureEnvironment.AZURE_US_GOVERNMENT;
} else if (managementUrl.equals(AzureEnvironment.AZURE_GERMANY.managementEndpoint()
.replaceAll("/$", ""))) {
return AzureEnvironment.AZURE_GERMANY;
}
// Azure China is currently not supported
// the deprecated config doesn't match any AzureEnvironment; return null
return null;
}
示例8: ApiImpl
import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
ApiImpl(Cloud cloud) {
try {
AzureTokenCredentials credentials = operationUtils.fromProjectAndUserName(
cloud,
(projectName, userName) -> new ApplicationTokenCredentials(
userName,
projectName,
cloud.getCredential(),
AzureEnvironment.AZURE //This could be parameterized in properties file!
)
);
this.client = Azure.configure()
.withLogLevel(LogLevel.HEADERS)
.authenticate(credentials)
.withDefaultSubscription();
} catch (IOException e) {
throw new RuntimeException(e);
}
}
示例9: get
import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
@Override
public Azure get() {
final String[] split = cloud.credential().user().split(DELIMITER);
if (split.length != 2) {
throw new IllegalStateException("Expected user to be of format clientId:tenant");
}
String clientId = split[0];
String tenant = split[1];
String key = cloud.credential().password();
ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(clientId, tenant, key,
AzureEnvironment.AZURE);
try {
return Azure.authenticate(credentials).withDefaultSubscription();
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
示例10: azureEnvironmentParsing
import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
/**
* Only the following Azure environments should be supported: {@code AZURE},
* {@code AZURE_CHINA}, {@code AZURE_US_GOVERNMENT}, {@code AZURE_GERMANY}.
*/
@Test
public void azureEnvironmentParsing() {
assertThat(AzureAuth.parseEnvironment("AZURE"), is(AzureEnvironment.AZURE));
assertThat(AzureAuth.parseEnvironment("AZURE_CHINA"), is(AzureEnvironment.AZURE_CHINA));
assertThat(AzureAuth.parseEnvironment("AZURE_US_GOVERNMENT"), is(AzureEnvironment.AZURE_US_GOVERNMENT));
assertThat(AzureAuth.parseEnvironment("AZURE_GERMANY"), is(AzureEnvironment.AZURE_GERMANY));
try {
AzureAuth.parseEnvironment("AZURE_BELARUS");
fail("should not recognize AZURE_BELARUS");
} catch (IllegalArgumentException e) {
// expected
System.out.println(e);
}
}
示例11: validateAdlsFileSystem
import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
private void validateAdlsFileSystem(CloudCredential credential, FileSystem fileSystem) {
Map<String, Object> credentialAttributes = credential.getParameters();
String clientSecret = String.valueOf(credentialAttributes.get(AdlsFileSystemConfiguration.CREDENTIAL_SECRET_KEY));
String subscriptionId = String.valueOf(credentialAttributes.get(AdlsFileSystemConfiguration.SUBSCRIPTION_ID));
String clientId = String.valueOf(credentialAttributes.get(AdlsFileSystemConfiguration.ACCESS_KEY));
String tenantId = fileSystem.getStringParameter(AdlsFileSystemConfiguration.TENANT_ID);
String accountName = fileSystem.getStringParameter(FileSystemConfiguration.ACCOUNT_NAME);
ApplicationTokenCredentials creds = new ApplicationTokenCredentials(clientId, tenantId, clientSecret, AzureEnvironment.AZURE);
DataLakeStoreAccountManagementClient adlsClient = new DataLakeStoreAccountManagementClientImpl(creds);
adlsClient.withSubscriptionId(subscriptionId);
List<DataLakeStoreAccount> dataLakeStoreAccounts = adlsClient.accounts().list();
boolean validAccountname = false;
for (DataLakeStoreAccount account : dataLakeStoreAccounts) {
if (account.name().equalsIgnoreCase(accountName)) {
validAccountname = true;
break;
}
}
if (!validAccountname) {
throw new CloudConnectorException("The provided file system account name does not belong to a valid ADLS account");
}
}
示例12: getEnvironment
import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
private AzureEnvironment getEnvironment()
{
switch (azureEnvironmentName)
{
case "AZURE":
return AzureEnvironment.AZURE;
case "AZURE_CHINA":
return AzureEnvironment.AZURE_CHINA;
case "AZURE_GERMANY":
return AzureEnvironment.AZURE_GERMANY;
case "AZURE_US_GOVERNMENT":
return AzureEnvironment.AZURE_US_GOVERNMENT;
}
throw new IllegalArgumentException("Invalid setting for azure.environment " + azureEnvironmentName);
}
示例13: testGetAzureEnvironment
import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
@Test
public void testGetAzureEnvironment() {
final AzureAuthHelper helper = new AzureAuthHelper(mojo);
assertEquals(AzureEnvironment.AZURE, helper.getAzureEnvironment(null));
assertEquals(AzureEnvironment.AZURE, helper.getAzureEnvironment(""));
assertEquals(AzureEnvironment.AZURE, helper.getAzureEnvironment("default"));
assertEquals(AzureEnvironment.AZURE_CHINA, helper.getAzureEnvironment("AZURE_CHINA"));
assertEquals(AzureEnvironment.AZURE_CHINA, helper.getAzureEnvironment("azure_china"));
assertEquals(AzureEnvironment.AZURE_GERMANY, helper.getAzureEnvironment("AZURE_GERMANY"));
assertEquals(AzureEnvironment.AZURE_GERMANY, helper.getAzureEnvironment("azure_germany"));
assertEquals(AzureEnvironment.AZURE_US_GOVERNMENT, helper.getAzureEnvironment("AZURE_US_GOVERNMENT"));
assertEquals(AzureEnvironment.AZURE_US_GOVERNMENT, helper.getAzureEnvironment("azure_us_government"));
}
示例14: authenticate
import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
/**
* Creates an instance of MSIManager that exposes Managed Service Identity (MSI) resource management API entry points.
*
* @param credentials the credentials to use
* @param subscriptionId the subscription UUID
* @return the MSIManager
*/
public static MSIManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
return new MSIManager(new RestClient.Builder()
.withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
.withCredentials(credentials)
.withSerializerAdapter(new AzureJacksonAdapter())
.withResponseBuilderFactory(new AzureResponseBuilder.Factory())
.withInterceptor(new ProviderRegistrationInterceptor(credentials))
.withInterceptor(new ResourceManagerThrottlingInterceptor())
.build(), subscriptionId);
}
示例15: authenticate
import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
/**
* Creates an instance of MachineLearningManager that exposes MachineLearning resource management API entry points.
*
* @param credentials the credentials to use
* @param subscriptionId the subscription UUID
* @return the MachineLearningManager
*/
public static MachineLearningManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
return new MachineLearningManager(new RestClient.Builder()
.withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
.withCredentials(credentials)
.withSerializerAdapter(new AzureJacksonAdapter())
.withResponseBuilderFactory(new AzureResponseBuilder.Factory())
.withInterceptor(new ProviderRegistrationInterceptor(credentials))
.withInterceptor(new ResourceManagerThrottlingInterceptor())
.build(), subscriptionId);
}