我正在使用 Java sdk 尝试自动化一些天蓝色的任务,例如启动服务器和关闭服务器。我正在使用来自 maven 的 0.9.0 版本的 java sdk
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-svc-mgmt</artifactId>
<version>0.9.0</version>
</dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-svc-mgmt-compute</artifactId>
<version>0.9.0</version>
</dependency>
这段代码在eclipse中编译运行成功
package com.services.servers.operations.azure;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import com.microsoft.windowsazure.Configuration;
import com.microsoft.windowsazure.core.utils.KeyStoreType;
import com.microsoft.windowsazure.exception.ServiceException;
import com.microsoft.windowsazure.management.compute.ComputeManagementClient;
import com.microsoft.windowsazure.management.compute.ComputeManagementService;
import com.microsoft.windowsazure.management.compute.VirtualMachineOperations;
import com.microsoft.windowsazure.management.configuration.ManagementConfiguration;
public class AzureTest {
String uri = "https://management.core.windows.net/";
String subscriptionId = "dasdas9-86da-4343-a1f4-24c20864e166";
String keyStoreLocation = "C:\\Users\\test\\Desktop\\azure\\testKeystore.jks";
String keyStorePassword = "password";
public boolean startVirtualMachine(String serviceName, String deploymentName, String virtualMachineName){
boolean isSuccess = true;
try {
VirtualMachineOperations virtualMachineOperations = null;
Configuration config = ManagementConfiguration.configure(
new URI(uri),
subscriptionId,
keyStoreLocation,
keyStorePassword,
KeyStoreType.jks
);
ComputeManagementClient computeManagementClient = ComputeManagementService.create(config);
virtualMachineOperations = computeManagementClient.getVirtualMachinesOperations();
virtualMachineOperations.beginStarting(serviceName, deploymentName, virtualMachineName);
} catch (IOException e) {
System.out.println("An IOException has occured. Exception: " +e);
isSuccess = false;
} catch (ServiceException e) {
System.out.println("A ServiceException has occured. Exception: " + e);
isSuccess = false;
} catch (URISyntaxException e) {
System.out.println("A URISyntaxException has occured. Exception: " + e);
isSuccess = false;
}
return isSuccess;
}
}
当我升级到最新版本的 sdk - 0.9.1 - 以下类不再存在
import com.microsoft.windowsazure.Configuration;
import com.microsoft.windowsazure.core.utils.KeyStoreType;
import com.microsoft.windowsazure.exception.ServiceException;
import com.microsoft.windowsazure.management.configuration.ManagementConfiguration;
我在网上找不到任何东西来说明这些课程的去向——它们是否已被弃用或更多到另一个库
如果有人知道我应该改用什么类或者他们可能已经移到了哪些库 - 那会很棒或者如果有人可以建议对上述代码进行任何改进以启动服务器,那将不胜感激
谢谢达米安