I’d like to change a VMSS capacity through API. On the Azure webpage there is a "Try it" button for check a request:
https://learn.microsoft.com/en-us/rest/api/compute/virtual-machine-scale-sets/update?tabs=HTTP#code-try-0
and my JSON is working fine from that link. But with curl I’ve got an answer:
"code":"UnsupportedResourceOperation","message":"The resource type ‘virtualMachineScaleSets’ does not support this operation."
My request looks like this:
curl -s -X PATCH
-H "Authorization: Bearer ${TOKEN}"
-H "Content-type: application/json"
-d @body.json
https://management.azure.com/subscriptions/${SUBSCRIPTION}/resourceGroups/${RG}/providers/Microsoft.Compute/virtualMachineScaleSets/${SCALE_SET_NAME}?api-version=2022-11-01
and the content of a body.json file is:
{
"sku": {
"tier": "Standard",
"capacity": 1,
"name": "Standard_B2s"
}
}
The same json body is working fine on "Try it" so it may be something wrong with my curl request. I’m able to GET information using curl. Could you please show me where did I make a mistake?
2
Answers
My bad of course. The API version what I used in the example was 2022-11-01 instead of the latest 2023-03-01 and I used a SCALE_SET_NAME which was not defined on my host machine.
I created an Azure AD Application and added API permissions like below:
Now, I generated auth-code using below authorize endpoint:
Now, I generated access token by using below parameters:
By using the above token, I am able to update the VMSS successfully like below: