After seeing how the portal batch-fetches VM instanceViews for PowerState so quickly via the /batch endpoint, I hacked together a batched version of instance_view() on ComputeManagementClient. I couldn't find any docs about the batch endpoint though (complicated by the prevalence of docs for the Batch service)..
Is /batch actually supported, and if so, any chance for "official" support for batched operations via msrestazure and/or the Python SDK? The bulk VM instanceView fetch is the only thing I can think of right now that I'd need it for, but there are probably plenty of other things out there too...
cc @lmazuel
That's super interesting, I didn't know about this one either.
@devigned @johanste ? thoughts?
(sniffed from the portal)
Request URL:https://management.azure.com/batch?api-version=2015-11-01
Request Method:POST
{
"requests": [{
"url": "https://management.azure.com/subscriptions/XXXXXXXX/resourceGroups/rgfluentchash-6828/providers/Microsoft.Compute/virtualMachines/chashvm?api-version=2017-03-30&$expand=instanceView",
"httpMethod": "GET"
}, {
"url": "https://management.azure.com/subscriptions/XXXXXXXX/resourceGroups/javacsmrg3492/providers/Microsoft.Compute/virtualMachines/extvm3158?api-version=2017-03-30&$expand=instanceView",
"httpMethod": "GET"
}, {
"url": "https://management.azure.com/subscriptions/XXXXXXXX/resourceGroups/vmbdtest2680/providers/Microsoft.Compute/virtualMachines/javavm?api-version=2017-03-30&$expand=instanceView",
"httpMethod": "GET"
}, {
"url": "https://management.azure.com/subscriptions/XXXXXXXX/resourceGroups/vmbdtest2819/providers/Microsoft.Compute/virtualMachines/javavm?api-version=2017-03-30&$expand=instanceView",
"httpMethod": "GET"
}, {
"url": "https://management.azure.com/subscriptions/XXXXXXXX/resourceGroups/vmbdtest3413/providers/Microsoft.Compute/virtualMachines/javavm?api-version=2017-03-30&$expand=instanceView",
"httpMethod": "GET"
}, {
"url": "https://management.azure.com/subscriptions/XXXXXXXX/resourceGroups/vmbdtest5047/providers/Microsoft.Compute/virtualMachines/javavm?api-version=2017-03-30&$expand=instanceView",
"httpMethod": "GET"
}]
}
response
{
"responses": [{
"httpStatusCode": 200,
"headers": {
"Pragma": "no-cache",
"x-ms-ratelimit-remaining-resource": "Microsoft.Compute/LowCostGet3Min;4799,Microsoft.Compute/LowCostGet30Min;38399",
"Strict-Transport-Security": "max-age=31536000; includeSubDomains",
"x-ms-served-by": "XXXXXXXXXXXX",
"x-ms-request-id": "XXXXXXX",
"Cache-Control": "no-cache",
"Server": "Microsoft-HTTPAPI/2.0,Microsoft-HTTPAPI/2.0",
"x-ms-ratelimit-remaining-subscription-reads": "14989",
"x-ms-correlation-request-id": "XXXXXXXXXX",
"x-ms-routing-request-id": "WESTUS2:20180105T165654Z:cfe09e58-53d6-4079-b426-51ecb0ac88bd",
"Date": "Fri, 05 Jan 2018 16:56:53 GMT"
},
"content": {
"properties": {
"type": "Microsoft.Compute/virtualMachines",
"location": "southcentralus",
"tags": {},
"id": "/subscriptions/XXXXXXXX/resourceGroups/rgfluentchash-6828/providers/Microsoft.Compute/virtualMachines/chashvm",
"name": "chashvm"
},
"contentLength": 4058
}
}
I don't know why the API is not publicly documented (I have asked in the past but not gotten an authoritative answer). I may be that the endpoints don't have the SLAs needed for them to be supported for arbitrary usage. @ravbhatnagar, any insights?
:100: Uhm... That's something we should have documented.
Yeah, it's definitely handy... The ARM implementation switches from a single synchronous response to a standard polled long-running operation at 20+ items (which that C# client didn't seem to take into account at first glance), and maxes out at 500 embedded requests. I don't have enough VMs laying around in my test account to poke at the limits for the instanceView use case that I care most about, but in my crusty prototype, fetching instanceView for 10 VMs usually comes back in < 1s, which is a HUGE improvement over 10 additional round trips.
I'm sure there are a number of other things this could be useful for, but the fact that it remains undocumented on ARM is definitely of concern. I'm leaning toward using it anyway for our new inventory plugin; perhaps with a switch or auto-fallback to the standard method on any unexpected failures.
Any update on getting the /batch API documented? I'd like to understand it better, for example can it do more than just GET requests, how to I specify a request body, etc.
Is there any update here? I can't find any documentation for the /batch endpoint. It's also used by Azure Monitor to fetch data across multiple resources which would otherwise be many API calls.
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure
Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure
Most helpful comment
Any update on getting the /batch API documented? I'd like to understand it better, for example can it do more than just GET requests, how to I specify a request body, etc.