Cannot start Windows Azure VM programmatically

2019-05-04 21:52发布

问题:

I'm performing REST API operation Start Role (http://msdn.microsoft.com/en-us/library/jj157189.aspx)

In the link https://management.core.windows.net/{subscription-id}/services/hostedservices/{service-name}/deployments/{deployment-name}/roles/{role-name}/Operations we have replaced {service-name}, {deployment-name} and {role-name} with name of VM.

In result we have next message: "ResourceNotFoundThe resource service name hostedservices is not supported."

List Hosted Services operation (http://msdn.microsoft.com/en-us/library/windowsazure/ee460781.aspx) shows us that we have 2 WMs as hosted services.

Get Role operaion (http://msdn.microsoft.com/en-us/library/jj157193.aspx) also gives info about each of VMs.

Thanks in advance.

回答1:

You are using:

{subscription-id}/services/hostedservices/{service-name}/deployments/{deployment-name}/roles/{role-name}/Operations

But the correct Uri is:

{subscriptionID}/services/hostedservices/{serviceName}/deployments/{deploymentName}/roleInstances/{roleInstanceName}/Operations

See the difference?



回答2:

I haven't worked with this particular operation, however a few things:

service-name: It should be the name of the hosted service (the one with .cloudapp.net) and what you see when you list your hosted service.

deployment-name: Generally speaking it's a GUID returned by Get Deployment operation (http://msdn.microsoft.com/en-us/library/windowsazure/ee460804.aspx).

role-name: Role name is also returned when you do a Get Deployment operation. You should use that. I'm not sure if it is same as the name of your VM.

Can you retry your operation after changing these values?



回答3:

In my case, deployment name is the name of the first VM I created in this cloud service. So, if I added 3 machines to the same cloud service, all of them have the same deployment name - the name of the first machine.



标签: rest azure