• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java AzureEnvironment类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.microsoft.azure.AzureEnvironment的典型用法代码示例。如果您正苦于以下问题:Java AzureEnvironment类的具体用法?Java AzureEnvironment怎么用?Java AzureEnvironment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



AzureEnvironment类属于com.microsoft.azure包,在下文中一共展示了AzureEnvironment类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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


示例16: authenticate

import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
/**
 * Creates an instance of ContainerInstanceManager that exposes resource management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription
 * @return the ContainerInstanceManager
 */
public static ContainerInstanceManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new ContainerInstanceManager(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,代码来源:ContainerInstanceManager.java


示例17: authenticate

import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
/**
 * Creates an instance of StorageManager that exposes storage resource management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription UUID
 * @return the StorageManager
 */
public static StorageManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new StorageManager(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,代码来源:StorageManager.java


示例18: authenticate

import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
/**
* Creates an instance of AuthorizationManager that exposes Authorization resource management API entry points.
*
* @param credentials the credentials to use
* @param subscriptionId the subscription UUID
* @return the AuthorizationManager
*/
public static AuthorizationManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new AuthorizationManager(new RestClient.Builder()
        .withBaseUrl(credentials.environment(), AzureEnvironment.Endpoint.RESOURCE_MANAGER)
        .withCredentials(credentials)
        .withSerializerAdapter(new AzureJacksonAdapter())
        .withResponseBuilderFactory(new AzureResponseBuilder.Factory())
        .withInterceptor(new ProviderRegistrationInterceptor(credentials))
        .build(), subscriptionId);
}
 
开发者ID:Azure,项目名称:azure-libraries-for-java,代码行数:17,代码来源:AuthorizationManager.java


示例19: authenticate

import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
/**
* Creates an instance of CognitiveServicesManager that exposes CognitiveServices resource management API entry points.
*
* @param credentials the credentials to use
* @param subscriptionId the subscription UUID
* @return the CognitiveServicesManager
*/
public static CognitiveServicesManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new CognitiveServicesManager(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,代码来源:CognitiveServicesManager.java


示例20: authenticate

import com.microsoft.azure.AzureEnvironment; //导入依赖的package包/类
/**
 * Creates an instance of ContainerRegistryManager that exposes Registry resource management API entry points.
 *
 * @param credentials the credentials to use
 * @param subscriptionId the subscription
 * @return the ContainerRegistryManager
 */
public static ContainerRegistryManager authenticate(AzureTokenCredentials credentials, String subscriptionId) {
    return new ContainerRegistryManager(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,代码来源:ContainerRegistryManager.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IOUtils类代码示例发布时间:2022-05-22
下一篇:
Java BaseDatabaseMeta类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap