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

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

本文整理了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

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

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

  1. public static AppServicePlan getAppServicePlan(final String servicePlanName, final Azure azureClient,
  2. final String resourceGroup, final String servicePlanResourceGroup) {
  3. if (StringUtils.isNotEmpty(servicePlanName)) {
  4. final String servicePlanResGrp = getAppServicePlanResourceGroup(resourceGroup, servicePlanResourceGroup);
  5. return azureClient.appServices().appServicePlans()
  6. .getByResourceGroup(servicePlanResGrp, servicePlanName);
  7. }
  8. return null;
  9. }

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

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

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

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

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

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

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

  1. /**
  2. * Remove the IP name.
  3. *
  4. * @param resourceGroupName
  5. * @param vmName
  6. * @throws AzureCloudException
  7. */
  8. public void removeIPName(String resourceGroupName,
  9. String vmName) throws AzureCloudException {
  10. final String nic = vmName + "NIC";
  11. try {
  12. LOGGER.log(Level.INFO, "Remove NIC {0}", nic);
  13. azureClient.networkInterfaces().deleteByResourceGroup(resourceGroupName, nic);
  14. } catch (Exception e) {
  15. LOGGER.log(Level.WARNING, "AzureVMManagementServiceDelegate: removeIPName: while deleting NIC", e);
  16. }
  17. final String ip = vmName + "IPName";
  18. try {
  19. LOGGER.log(Level.INFO, "Remove IP {0}", ip);
  20. azureClient.publicIPAddresses().deleteByResourceGroup(resourceGroupName, ip);
  21. } catch (Exception e) {
  22. LOGGER.log(Level.WARNING, "AzureVMManagementServiceDelegate: removeIPName: while deleting IPName", e);
  23. }
  24. }

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

  1. ResourceGroup resourceGroup = azureClient.resourceGroups()
  2. .define(newHost.hostVM.resourceGroupName)
  3. .withRegion(newHost.hostVM.region)
  4. vnet = azureClient.networks().getByResourceGroup(vnetResourceGroupName, vnetName);
  5. } else {
  6. vnet = azureClient.networks()
  7. .define(newHost.hostVM.vnetName)
  8. .withRegion(newHost.hostVM.region)
  9. VirtualMachine.DefinitionStages.WithLinuxRootPasswordOrPublicKeyManagedOrUnmanaged defStage1 = azureClient.virtualMachines()
  10. .define(newHost.hostVM.name)
  11. .withRegion(newHost.hostVM.region)
  12. if (newHost.hostVM.storageAccountName.contains("@")) {
  13. for (StorageAccount item : azureClient.storageAccounts().list()) {
  14. String storageAccountName = item.name() + "@";
  15. if (storageAccountName.equals(newHost.hostVM.storageAccountName)) {

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

  1. @Override
  2. public String call() throws Exception {
  3. azureClient.storageAccounts().getByResourceGroup(resourceGroupName, "CI_SYSTEM");
  4. return Constants.OP_SUCCESS;
  5. }
  6. };

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

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

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

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

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

  1. try {
  2. fileReporter.report("Checking: Azure.authenticate(authFile)...");
  3. Azure.Authenticated azureAuthenticated = Azure.authenticate(authFiel);
  4. fileReporter.report("Checking: azureAuthenticated.subscriptions().list()...");
  5. azureAuthenticated.subscriptions().list();
  6. Azure azure = azureAuthenticated.withDefaultSubscription();
  7. fileReporter.report("Checking: resourceGroups().list()...");
  8. azure.resourceGroups().list();
  9. fileReporter.report("Done.");
  10. break;

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

  1. public static WithCreate defineWindowsApp(final String resourceGroup,
  2. final String appName,
  3. final Azure azureClient, final AppServicePlan plan) throws Exception {
  4. assureWindowsPlan(plan);
  5. final ExistingWindowsPlanWithGroup existingWindowsPlanWithGroup = azureClient.webApps()
  6. .define(appName).withExistingWindowsPlan(plan);
  7. return azureClient.resourceGroups().contain(resourceGroup) ?
  8. existingWindowsPlanWithGroup.withExistingResourceGroup(resourceGroup) :
  9. existingWindowsPlanWithGroup.withNewResourceGroup(resourceGroup);
  10. }

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

  1. public static Map<String, Pair<Vault, KeyVaultClient>> refreshDockerVaults(List<AzureDockerSubscription> azureDockerSubscriptions) {
  2. Map<String, Pair<Vault, KeyVaultClient>> vaults = new HashMap<>();
  3. if (DEBUG) System.out.format("\tGet AzureDockerHostsManage Docker key vault: %s\n", new Date().toString());
  4. try {
  5. for (AzureDockerSubscription dockerSubscription : azureDockerSubscriptions) {
  6. // TODO
  7. for (ResourceGroup group : dockerSubscription.azureClient.resourceGroups().list()) {
  8. for (Vault vault : dockerSubscription.azureClient.vaults().listByResourceGroup(group.name())) {
  9. if (DEBUG) System.out.format("\tGet AzureDockerHostsManage Docker vault: %s at %s\n", vault.name(), new Date().toString());
  10. if (vault.tags().get("dockerhost") != null) {
  11. if (DEBUG) System.out.format("\t\t...adding Docker vault: %s at %s\n", vault.name(), new Date().toString());
  12. vaults.put(vault.name(), new Pair<>(vault, dockerSubscription.keyVaultClient));
  13. }
  14. }
  15. }
  16. }
  17. } catch (Exception e) {
  18. e.printStackTrace();
  19. DefaultLoader.getUIHelper().showError(e.getMessage(), "Error loading key vaults");
  20. }
  21. return vaults;
  22. }

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

  1. public static List<AzureDockerStorageAccount> getStorageAccounts(Azure azureClient) {
  2. List<AzureDockerStorageAccount> result = new ArrayList<>();
  3. if (azureClient != null) {
  4. for (StorageAccount storageAccount : azureClient.storageAccounts().list()) {
  5. AzureDockerStorageAccount dockerStorageAccount = new AzureDockerStorageAccount();
  6. dockerStorageAccount.name = storageAccount.name();
  7. dockerStorageAccount.region = storageAccount.regionName();
  8. dockerStorageAccount.resourceGroup = storageAccount.resourceGroupName();
  9. dockerStorageAccount.sid = azureClient.subscriptionId();
  10. dockerStorageAccount.skuType = storageAccount.sku().name().name();
  11. result.add(dockerStorageAccount);
  12. }
  13. }
  14. return result;
  15. }

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

  1. public static void deleteDockerHostAll(Azure azureClient, String resourceGroup, String vmName) {
  2. if (azureClient == null || resourceGroup == null || vmName == null ) {
  3. throw new AzureDockerException("Unexpected param values; Azure instance, resource group and VM name cannot be null");
  4. }
  5. VirtualMachine vm = azureClient.virtualMachines().getByResourceGroup(resourceGroup, vmName);
  6. if (vm == null) {
  7. throw new AzureDockerException(String.format("Unexpected error retrieving VM %s from Azure", vmName));
  8. }
  9. try {
  10. PublicIPAddress publicIp = vm.getPrimaryPublicIPAddress();
  11. NicIPConfiguration nicIPConfiguration = publicIp.getAssignedNetworkInterfaceIPConfiguration();
  12. Network vnet = nicIPConfiguration.getNetwork();
  13. NetworkInterface nic = vm.getPrimaryNetworkInterface();
  14. azureClient.virtualMachines().deleteById(vm.id());
  15. azureClient.networkInterfaces().deleteById(nic.id());
  16. azureClient.publicIPAddresses().deleteById(publicIp.id());
  17. azureClient.networks().deleteById(vnet.id());
  18. } catch (Exception e) {
  19. throw new AzureDockerException(String.format("Unexpected error while deleting VM %s and its associated resources", vmName));
  20. }
  21. }

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

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

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

  1. public Azure getAzureClient() throws AzureAuthFailureException {
  2. if (azure == null) {
  3. azure = azureAuthHelper.getAzureClient();
  4. if (azure == null) {
  5. getTelemetryProxy().trackEvent(INIT_FAILURE);
  6. throw new AzureAuthFailureException(AZURE_INIT_FAIL);
  7. } else {
  8. // Repopulate subscriptionId in case it is not configured.
  9. getTelemetryProxy().addDefaultProperty(SUBSCRIPTION_ID_KEY, azure.subscriptionId());
  10. }
  11. }
  12. return azure;
  13. }

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

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

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

  1. protected Azure.Configurable azureConfigure() {
  2. final String httpProxyHost = config.getHttpProxyHost();
  3. final int httpProxyPort = config.getHttpProxyPort();
  4. final Azure.Configurable configurable = Azure.configure()
  5. .withLogLevel(getLogLevel())
  6. .withUserAgent(config.getUserAgent());
  7. return StringUtils.isNotEmpty(httpProxyHost) ?
  8. configurable.withProxy(new Proxy(Proxy.Type.HTTP, new InetSocketAddress(httpProxyHost, httpProxyPort))) :
  9. configurable;
  10. }

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

  1. deployment = azureClient.deployments().
  2. getByResourceGroup(info.getResourceGroupName(), info.getDeploymentName());
  3. } catch (NullPointerException e) {
  4. failTimeoutInMinutes);
  5. azureClient.deployments()
  6. .deleteByResourceGroup(info.getResourceGroupName(), info.getDeploymentName());
  7. if (StringUtils.isNotBlank(info.scriptUri)) {
  8. successTimeoutInMinutes);
  9. azureClient.deployments()
  10. .deleteByResourceGroup(info.getResourceGroupName(), info.getDeploymentName());
  11. if (StringUtils.isNotBlank(info.scriptUri)) {

相关文章