com.microsoft.azure.management.Azure类的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(11.4k)|赞(0)|评价(0)|浏览(250)

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

Azure介绍

[英]The entry point for accessing resource management APIs in Azure.
[中]Azure中访问资源管理API的入口点。

代码示例

代码示例来源:origin: Microsoft/spring-cloud-azure

@Override
public ResourceGroup internalGet(String key) {
  return azure.resourceGroups().getByName(key);
}

代码示例来源:origin: Microsoft/azure-maven-plugins

public static AppServicePlan getAppServicePlan(final String servicePlanName, final Azure azureClient,
                        final String resourceGroup, final String servicePlanResourceGroup) {
  if (StringUtils.isNotEmpty(servicePlanName)) {
    final String servicePlanResGrp = getAppServicePlanResourceGroup(resourceGroup, servicePlanResourceGroup);
    return azureClient.appServices().appServicePlans()
        .getByResourceGroup(servicePlanResGrp, servicePlanName);
  }
  return null;
}

代码示例来源:origin: gradle.plugin.com.intershop.gradle.plugin.azure/azurePlugin

protected Azure getClient(String subscriptionId)
{
  ApplicationTokenCredentials creds = new ApplicationTokenCredentials(clientId, domain, secret,
          AzureEnvironment.AZURE);
  return Azure.authenticate(creds).withSubscription(subscriptionId);
}

代码示例来源:origin: com.microsoft.azure/azure

/**
 * @return the currently selected subscription this client is authenticated to work with
 */
public Subscription getCurrentSubscription() {
  return this.subscriptions().getById(this.subscriptionId());
}

代码示例来源:origin: Microsoft/azure-tools-for-java

public static Map<String, DockerHost> getDockerHosts(Azure azureClient, Map<String, AzureDockerCertVault> dockerVaultsMap) {
 Map<String, DockerHost> dockerHostMap = getDockerHosts(azureClient.virtualMachines().list(), dockerVaultsMap);
 for (DockerHost dockerHost : dockerHostMap.values()) {
  dockerHost.sid = azureClient.subscriptionId();
  if (dockerHost.hostVM != null) dockerHost.hostVM.sid = azureClient.subscriptionId();
 }
 return dockerHostMap;
}

代码示例来源:origin: jenkinsci/azure-vm-agents-plugin

/**
 * Remove the IP name.
 *
 * @param resourceGroupName
 * @param vmName
 * @throws AzureCloudException
 */
public void removeIPName(String resourceGroupName,
             String vmName) throws AzureCloudException {
  final String nic = vmName + "NIC";
  try {
    LOGGER.log(Level.INFO, "Remove NIC {0}", nic);
    azureClient.networkInterfaces().deleteByResourceGroup(resourceGroupName, nic);
  } catch (Exception e) {
    LOGGER.log(Level.WARNING, "AzureVMManagementServiceDelegate: removeIPName: while deleting NIC", e);
  }
  final String ip = vmName + "IPName";
  try {
    LOGGER.log(Level.INFO, "Remove IP {0}", ip);
    azureClient.publicIPAddresses().deleteByResourceGroup(resourceGroupName, ip);
  } catch (Exception e) {
    LOGGER.log(Level.WARNING, "AzureVMManagementServiceDelegate: removeIPName: while deleting IPName", e);
  }
}

代码示例来源:origin: Microsoft/azure-tools-for-java

ResourceGroup resourceGroup = azureClient.resourceGroups()
   .define(newHost.hostVM.resourceGroupName)
   .withRegion(newHost.hostVM.region)
 vnet = azureClient.networks().getByResourceGroup(vnetResourceGroupName, vnetName);
} else {
 vnet = azureClient.networks()
   .define(newHost.hostVM.vnetName)
   .withRegion(newHost.hostVM.region)
VirtualMachine.DefinitionStages.WithLinuxRootPasswordOrPublicKeyManagedOrUnmanaged defStage1 = azureClient.virtualMachines()
  .define(newHost.hostVM.name)
  .withRegion(newHost.hostVM.region)
if (newHost.hostVM.storageAccountName.contains("@")) {
 for (StorageAccount item : azureClient.storageAccounts().list()) {
  String storageAccountName = item.name() + "@";
  if (storageAccountName.equals(newHost.hostVM.storageAccountName)) {

代码示例来源:origin: jenkinsci/azure-vm-agents-plugin

@Override
  public String call() throws Exception {
    azureClient.storageAccounts().getByResourceGroup(resourceGroupName, "CI_SYSTEM");
    return Constants.OP_SUCCESS;
  }
};

代码示例来源:origin: Microsoft/azure-maven-plugins

log.info(String.format(CREATE_SERVICE_PLAN, servicePlanName));
final AppServicePlan.DefinitionStages.WithGroup withGroup = azure.appServices().appServicePlans()
  .define(servicePlanName).withRegion(region);
  = azure.resourceGroups().contain(servicePlanResGrp) ?
  withGroup.withExistingResourceGroup(servicePlanResGrp) :
  withGroup.withNewResourceGroup(servicePlanResGrp);

代码示例来源:origin: Microsoft/azure-tools-for-java

public static void deleteAppService(WebAppDetails webAppDetails) throws IOException {
  AzureManager azureManager = AuthMethodManager.getInstance().getAzureManager();
  Azure azure = azureManager.getAzure(webAppDetails.subscriptionDetail.getSubscriptionId());
  azure.webApps().deleteById(webAppDetails.webApp.id());
  // check asp still exists
  AppServicePlan asp = azure.appServices().appServicePlans().getById(webAppDetails.appServicePlan.id());
  System.out.println("asp is " + (asp == null ? "null -> removing form cache" : asp.name()));
  // update cache
  AzureModelController.removeWebAppFromResourceGroup(webAppDetails.resourceGroup, webAppDetails.webApp);
  if (asp == null) {
    AzureModelController.removeAppServicePlanFromResourceGroup(webAppDetails.appServicePlanResourceGroup, webAppDetails.appServicePlan);
  }
}

代码示例来源:origin: Microsoft/azure-tools-for-java

try {
  fileReporter.report("Checking: Azure.authenticate(authFile)...");
  Azure.Authenticated azureAuthenticated = Azure.authenticate(authFiel);
  fileReporter.report("Checking: azureAuthenticated.subscriptions().list()...");
  azureAuthenticated.subscriptions().list();
  Azure azure = azureAuthenticated.withDefaultSubscription();
  fileReporter.report("Checking: resourceGroups().list()...");
  azure.resourceGroups().list();
  fileReporter.report("Done.");
  break;

代码示例来源:origin: Microsoft/azure-maven-plugins

public static WithCreate defineWindowsApp(final String resourceGroup,
                     final String appName,
                     final Azure azureClient, final AppServicePlan plan) throws Exception {
  assureWindowsPlan(plan);
  final ExistingWindowsPlanWithGroup existingWindowsPlanWithGroup = azureClient.webApps()
    .define(appName).withExistingWindowsPlan(plan);
  return azureClient.resourceGroups().contain(resourceGroup) ?
    existingWindowsPlanWithGroup.withExistingResourceGroup(resourceGroup) :
    existingWindowsPlanWithGroup.withNewResourceGroup(resourceGroup);
}

代码示例来源:origin: Microsoft/azure-tools-for-java

public static Map<String, Pair<Vault, KeyVaultClient>> refreshDockerVaults(List<AzureDockerSubscription> azureDockerSubscriptions) {
 Map<String, Pair<Vault, KeyVaultClient>> vaults = new HashMap<>();
 if (DEBUG) System.out.format("\tGet AzureDockerHostsManage Docker key vault: %s\n", new Date().toString());
 try {
  for (AzureDockerSubscription dockerSubscription : azureDockerSubscriptions) {
   // TODO
   for (ResourceGroup group : dockerSubscription.azureClient.resourceGroups().list()) {
    for (Vault vault : dockerSubscription.azureClient.vaults().listByResourceGroup(group.name())) {
     if (DEBUG) System.out.format("\tGet AzureDockerHostsManage Docker vault: %s at %s\n", vault.name(), new Date().toString());
     if (vault.tags().get("dockerhost") != null) {
      if (DEBUG) System.out.format("\t\t...adding Docker vault: %s at %s\n", vault.name(), new Date().toString());
      vaults.put(vault.name(), new Pair<>(vault, dockerSubscription.keyVaultClient));
     }
    }
   }
  }
 } catch (Exception e) {
  e.printStackTrace();
  DefaultLoader.getUIHelper().showError(e.getMessage(), "Error loading key vaults");
 }
 return vaults;
}

代码示例来源:origin: Microsoft/azure-tools-for-java

public static List<AzureDockerStorageAccount> getStorageAccounts(Azure azureClient) {
 List<AzureDockerStorageAccount> result = new ArrayList<>();
 if (azureClient != null) {
  for (StorageAccount storageAccount : azureClient.storageAccounts().list()) {
   AzureDockerStorageAccount dockerStorageAccount = new AzureDockerStorageAccount();
   dockerStorageAccount.name = storageAccount.name();
   dockerStorageAccount.region = storageAccount.regionName();
   dockerStorageAccount.resourceGroup = storageAccount.resourceGroupName();
   dockerStorageAccount.sid = azureClient.subscriptionId();
   dockerStorageAccount.skuType = storageAccount.sku().name().name();
   result.add(dockerStorageAccount);
  }
 }
 return result;
}

代码示例来源:origin: Microsoft/azure-tools-for-java

public static void deleteDockerHostAll(Azure azureClient, String resourceGroup, String vmName) {
 if (azureClient == null || resourceGroup == null || vmName == null ) {
  throw new AzureDockerException("Unexpected param values; Azure instance, resource group and VM name cannot be null");
 }
 VirtualMachine vm = azureClient.virtualMachines().getByResourceGroup(resourceGroup, vmName);
 if (vm == null) {
  throw new AzureDockerException(String.format("Unexpected error retrieving VM %s from Azure", vmName));
 }
 try {
  PublicIPAddress publicIp = vm.getPrimaryPublicIPAddress();
  NicIPConfiguration nicIPConfiguration = publicIp.getAssignedNetworkInterfaceIPConfiguration();
  Network vnet = nicIPConfiguration.getNetwork();
  NetworkInterface nic = vm.getPrimaryNetworkInterface();
  azureClient.virtualMachines().deleteById(vm.id());
  azureClient.networkInterfaces().deleteById(nic.id());
  azureClient.publicIPAddresses().deleteById(publicIp.id());
  azureClient.networks().deleteById(vnet.id());
 } catch (Exception e) {
  throw new AzureDockerException(String.format("Unexpected error while deleting VM %s and its associated resources", vmName));
 }
}

代码示例来源:origin: jenkinsci/azure-vm-agents-plugin

if (isImageParameterValid) {
    String imageVersion = StringUtils.isNotEmpty(template.getImageVersion()) ? template.getImageVersion() : "latest";
    VirtualMachineImage image = azureClient.virtualMachineImages().getImage(locationName,
        template.getImagePublisher(), template.getImageOffer(), template.getImageSku(), imageVersion);
    if (image != null) {
  putVariable(tmp, "startupScriptName", scriptName);
  List<StorageAccountKey> storageKeys = azureClient.storageAccounts()
      .getByResourceGroup(template.getResourceGroupName(), storageAccountName)
      .getKeys();
    template.getAzureCloud().getCloudName(), template.getResourceGroupName(), deploymentName, scriptUri);
azureClient.deployments().define(deploymentName)
    .withExistingResourceGroup(template.getResourceGroupName())
    .withTemplate(tmp.toString())

代码示例来源:origin: Microsoft/azure-maven-plugins

public Azure getAzureClient() throws AzureAuthFailureException {
  if (azure == null) {
    azure = azureAuthHelper.getAzureClient();
    if (azure == null) {
      getTelemetryProxy().trackEvent(INIT_FAILURE);
      throw new AzureAuthFailureException(AZURE_INIT_FAIL);
    } else {
      // Repopulate subscriptionId in case it is not configured.
      getTelemetryProxy().addDefaultProperty(SUBSCRIPTION_ID_KEY, azure.subscriptionId());
    }
  }
  return azure;
}

代码示例来源:origin: jenkinsci/azure-vm-agents-plugin

final Deployment dep = newAzureClient.deployments().getByName(deploymentName);
            resource);
        final VirtualMachine vm = newAzureClient.virtualMachines()
            .getByResourceGroup(resourceGroupName, resource);
        final OperatingSystemTypes osType = vm.storageProfile().osDisk().osType();

代码示例来源:origin: Microsoft/azure-maven-plugins

protected Azure.Configurable azureConfigure() {
  final String httpProxyHost = config.getHttpProxyHost();
  final int httpProxyPort = config.getHttpProxyPort();
  final Azure.Configurable configurable = Azure.configure()
      .withLogLevel(getLogLevel())
      .withUserAgent(config.getUserAgent());
  return StringUtils.isNotEmpty(httpProxyHost) ?
    configurable.withProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(httpProxyHost, httpProxyPort))) :
    configurable;                      
}

代码示例来源:origin: jenkinsci/azure-vm-agents-plugin

deployment = azureClient.deployments().
      getByResourceGroup(info.getResourceGroupName(), info.getDeploymentName());
} catch (NullPointerException e) {
      failTimeoutInMinutes);
  azureClient.deployments()
      .deleteByResourceGroup(info.getResourceGroupName(), info.getDeploymentName());
  if (StringUtils.isNotBlank(info.scriptUri)) {
      successTimeoutInMinutes);
  azureClient.deployments()
      .deleteByResourceGroup(info.getResourceGroupName(), info.getDeploymentName());
  if (StringUtils.isNotBlank(info.scriptUri)) {

相关文章