Pergunta

I found a very strange problem here: In Azure powershell, we can use Start-AzureVM -ServiceName "mypc" -Name "mypc" for both VM state= stop or stop(Deallocated). But for Azure Mangement API We can use start role only for VM state= stop

VM state=stop(deallocated) can't use that API.. How can I use REST API to start VM with State=Stop(deallocated)? Thanks.

Foi útil?

Solução

The Windows Azure PowerShell cmdlets use the Service Management REST API - but it uses an undocumented 2013-06-01 version. It is possible that this operation is available only in the undocumented version of the Service Management REST API.

You can see what the cmdlets actually do by using Fiddler to proxy the request - this gives you access to the operation invoked (URL) as well as the payload sent and received. Alternatively, you can look at the PowerShell cmdlets source which is available on GitHub.

Outras dicas

POST https://management.core.windows.net/<subscription-id>/services/hostedservices/<service-name>/deployments/<deployment-name>/roleinstances/<role-name>/Operations

**x-ms-version: 2013-06-01**

<StartRoleOperation xmlns="http://schemas.microsoft.com/windowsazure" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"><OperationType>StartRoleOperation</OperationType></StartRoleOperation>
public Task<ComputeLongRunningOperationResponse> StartVirtualMachineAsync(string subscriptionId, string name, string resource_group)
{
    TokenCloudCredentials tokenCloudCredential = new TokenCloudCredentials(subscriptionId, token);

    ComputeManagementClient computeManagementClient = new ComputeManagementClient(tokenCloudCredential);

    return computeManagementClient.VirtualMachines.StartAsync(resource_group, name);
}
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top