REST API request returns "BadRequest" for VMSS

Jaewoo Kim 20 Reputation points
2023-11-06T18:11:05.64+00:00

Working on REST API to retrieve instances from VMSS.

https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-orchestration-modes#list-scale-sets-vm-api-changes

found that based on orchestration mode:

'flexible' : use standard VM API

'uniform' : use VMSS API

So, 'flexible' VMSS seems fine. But, still got error from a VMSS resource with 'Uniform'

Microsoft.Compute/virtualMachineScaleSets/{UniformVMSS}/virtualMachines?api-version=2019-12-01&$expand=instanceView

{

    "error": {

        "code": "BadRequest",

        "message": "Operation 'VirtualMachineScaleSets.virtualMachines.GET' is not allowed on Virtual Machine Scale Set {UniformVMSS}."

    }

}

Is there any case that we cannnot retireve VMs from VMSS('uniform') using the REST call above?

How can I determine which API to use?

Azure Virtual Machines
Azure Virtual Machines
An Azure service that is used to provision Windows and Linux virtual machines.
8,238 questions
Azure Virtual Machine Scale Sets
Azure Virtual Machine Scale Sets
Azure compute resources that are used to create and manage groups of heterogeneous load-balanced virtual machines.
424 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. shiva patpi 13,256 Reputation points Microsoft Employee
    2023-11-07T06:54:25.9566667+00:00

    @Jaewoo Kim

    As per the document: https://learn.microsoft.com/en-us/azure/virtual-machine-scale-sets/virtual-machine-scale-sets-orchestration-modes?WT.mc_id=modinfra-31635-pierrer#what-has-changed-with-flexible-orchestration-mode

    User's image

    For uniform, it works with the normal VMSS REST APIs:

    User's image

    If you try to use the same VMSS REST APIs for Flexible , it won't work:

    User's image

    {
      "error": {
        "code": "BadRequest",
        "message": "Operation 'VirtualMachineScaleSets.virtualMachines.GET' is not allowed on Virtual Machine Scale Set 'testvmssflixible'."
      }
    }
    

    So while querying Flexible VMSS we can use the normal VM REST API to query individual VMs

    User's image

    Kindly let us know if you have additional questions !

    Regards,

    Shiva.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.