当前位置: 首页>>代码示例>>Java>>正文


Java AzureEnvironment类代码示例

本文整理汇总了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;
    }
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:17,代码来源:AzureAuthHelper.java

示例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();
    }
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:29,代码来源:ManageSqlDatabase.java

示例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();
    }
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:29,代码来源:ManageSqlDatabaseInElasticPool.java

示例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();
    }
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:29,代码来源:ManageSqlFirewallRules.java

示例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);
}
 
开发者ID:vmware,项目名称:photon-model,代码行数:20,代码来源:AzureUtils.java

示例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;
}
 
开发者ID:cloudera,项目名称:director-azure-plugin,代码行数:30,代码来源:AzureCloudEnvironment.java

示例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);
    }
}
 
开发者ID:meridor,项目名称:perspective-backend,代码行数:20,代码来源:ApiProviderImpl.java

示例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);
  }
}
 
开发者ID:cloudiator,项目名称:sword,代码行数:21,代码来源:AzureProvider.java

示例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);
    }
}
 
开发者ID:elastisys,项目名称:scale.cloudpool,代码行数:20,代码来源:TestAzureAuth.java

示例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");
        }
    }
 
开发者ID:hortonworks,项目名称:cloudbreak,代码行数:26,代码来源:AzureSetup.java

示例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);
}
 
开发者ID:petergeneric,项目名称:stdlib,代码行数:17,代码来源:ServiceClientCredentialsProvider.java

示例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"));
}
 
开发者ID:Microsoft,项目名称:azure-maven-plugins,代码行数:14,代码来源:AzureAuthHelperTest.java

示例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);
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:18,代码来源:MSIManager.java

示例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);
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:18,代码来源:MachineLearningManager.java


注:本文中的com.microsoft.azure.AzureEnvironment类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。