简体   繁体   English

如何从Azure ARM Java SDk获得启动和停止VM的响应?

[英]How can I get response for start and stop VM from Azure ARM java SDk?

I am using Azure ARM java SDK and I perform operation start and stop VM. 我正在使用Azure ARM Java SDK,并执行启动和停止VM的操作。 I am not able to get the response. 我无法得到答复。

     try{
           VirtualMachine vm=azure.virtualMachines().getByGroup("resourceGroup", "vmNAme");
            vm.start();
    }catch(CloudException| IllegalArgumentException| IOException|InterruptedException e){

            System.out.println(e.getMessage());
    }

vm.start(); vm.start(); is a sysnc call. 是sysnc调用。 In Azure ASM able to get by getVirtualMachinesOperations() method. 在Azure ASM中,可以通过getVirtualMachinesOperations()方法获取。

Is there any way to get the response ?. 有没有办法得到回应?

As you can see from documentation Start/Restart/Stop calls return only status code : https://msdn.microsoft.com/en-us/library/azure/mt163628.aspx 从文档的Start / Restart / Stop调用中可以看到,仅返回状态代码: https : //msdn.microsoft.com/zh-cn/library/azure/mt163628.aspx

So, start/stop/restart function are void in Java SDK. 因此,启动/停止/重新启动功能在Java SDK中无效。

You will find information about Virtual Machine status in the VirtualMachineInstanceView : VirtualMachineInstanceView vmInstanceView = vm.refreshInstanceView(); 您可以在VirtualMachineInstanceView中找到有关虚拟机状态的信息: VirtualMachineInstanceView vmInstanceView = vm.refreshInstanceView(); or VirtualMachineInstanceView vmInstanceView = vm.instanceView(); VirtualMachineInstanceView vmInstanceView = vm.instanceView(); to optimize some calls. 优化一些通话。

@PawanSharma, According to your code, I know you are using the version 1.0.0-beta of Azure SDK for Java. @PawanSharma,根据您的代码,我知道您正在使用Azure SDK for Java的1.0.0-beta版本。 If you want to get status on the start/stop call as you wish, I think the way is that directly use REST APIs with HTTP Client or return the SDK version 0.9 to get the ComputeLongRunningOperationResponse from the function VirtualMachineOperations.start/startAsync . 如果你想获得对状态的开始/停止打电话,你想,我的思考方式是直接使用REST API的使用HTTP客户端或返回SDK版本0.9 ,以获得ComputeLongRunningOperationResponse从功能VirtualMachineOperations.start/startAsync

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM