com.microsoft.azure.management.resources.fluentcore.utils.Utils.extractAzureEnvironment()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(4.8k)|赞(0)|评价(0)|浏览(92)

本文整理了Java中com.microsoft.azure.management.resources.fluentcore.utils.Utils.extractAzureEnvironment()方法的一些代码示例,展示了Utils.extractAzureEnvironment()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Utils.extractAzureEnvironment()方法的具体详情如下:
包路径:com.microsoft.azure.management.resources.fluentcore.utils.Utils
类名称:Utils
方法名:extractAzureEnvironment

Utils.extractAzureEnvironment介绍

[英]Try to extract the environment the client is authenticated to based on the information on the rest client.
[中]尝试根据rest客户机上的信息提取客户机经过身份验证的环境。

代码示例

代码示例来源:origin: Azure/azure-libraries-for-java

void exportAuthFile(ServicePrincipalImpl servicePrincipal) {
  if (authFile == null) {
    return;
  }
  RestClient restClient = servicePrincipal.manager().roleInner().restClient();
  AzureEnvironment environment = Utils.extractAzureEnvironment(restClient);
  StringBuilder builder = new StringBuilder("{\n");
  builder.append("  ").append(String.format("\"clientId\": \"%s\",", servicePrincipal.applicationId())).append("\n");
  builder.append("  ").append(String.format("\"clientCertificate\": \"%s\",", privateKeyPath.replace("\\", "\\\\"))).append("\n");
  builder.append("  ").append(String.format("\"clientCertificatePassword\": \"%s\",", privateKeyPassword)).append("\n");
  builder.append("  ").append(String.format("\"tenantId\": \"%s\",", servicePrincipal.manager().tenantId())).append("\n");
  builder.append("  ").append(String.format("\"subscriptionId\": \"%s\",", servicePrincipal.assignedSubscription)).append("\n");
  builder.append("  ").append(String.format("\"activeDirectoryEndpointUrl\": \"%s\",", environment.activeDirectoryEndpoint())).append("\n");
  builder.append("  ").append(String.format("\"resourceManagerEndpointUrl\": \"%s\",", environment.resourceManagerEndpoint())).append("\n");
  builder.append("  ").append(String.format("\"activeDirectoryGraphResourceId\": \"%s\",", environment.graphEndpoint())).append("\n");
  builder.append("  ").append(String.format("\"managementEndpointUrl\": \"%s\"", environment.managementEndpoint())).append("\n");
  builder.append("}");
  try {
    authFile.write(builder.toString().getBytes());
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: Azure/azure-libraries-for-java

void exportAuthFile(ServicePrincipalImpl servicePrincipal) {
  if (authFile == null) {
    return;
  }
  RestClient restClient = servicePrincipal.manager().roleInner().restClient();
  AzureEnvironment environment = Utils.extractAzureEnvironment(restClient);
  StringBuilder builder = new StringBuilder("{\n");
  builder.append("  ").append(String.format("\"clientId\": \"%s\",", servicePrincipal.applicationId())).append("\n");
  builder.append("  ").append(String.format("\"clientSecret\": \"%s\",", value())).append("\n");
  builder.append("  ").append(String.format("\"tenantId\": \"%s\",", servicePrincipal.manager().tenantId())).append("\n");
  builder.append("  ").append(String.format("\"subscriptionId\": \"%s\",", servicePrincipal.assignedSubscription)).append("\n");
  builder.append("  ").append(String.format("\"activeDirectoryEndpointUrl\": \"%s\",", environment.activeDirectoryEndpoint())).append("\n");
  builder.append("  ").append(String.format("\"resourceManagerEndpointUrl\": \"%s\",", environment.resourceManagerEndpoint())).append("\n");
  builder.append("  ").append(String.format("\"activeDirectoryGraphResourceId\": \"%s\",", environment.graphEndpoint())).append("\n");
  builder.append("  ").append(String.format("\"managementEndpointUrl\": \"%s\"", environment.managementEndpoint())).append("\n");
  builder.append("}");
  try {
    authFile.write(builder.toString().getBytes());
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: Azure/azure-libraries-for-java

@Override
public String defaultHostName() {
  if (inner().defaultHostName() != null) {
    return inner().defaultHostName();
  } else {
    AzureEnvironment environment = Utils.extractAzureEnvironment(manager().restClient());
    String dns = DNS_MAP.get(environment);
    String leaf = name();
    if (this instanceof DeploymentSlotBaseImpl<?, ?, ?, ?, ?>) {
      leaf = ((DeploymentSlotBaseImpl<?, ?, ?, ?, ?>) this).parent().name() + "-" + leaf;
    }
    return leaf + "." + dns;
  }
}

相关文章