Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Return Virtual Machine Instance View from list() or list_all() methods #573

Closed
chouseknecht opened this issue Apr 13, 2016 · 34 comments
Closed
Labels
Compute - VM customer-reported Issues that are reported by GitHub users external to the Azure organization. feature-request This issue requires a new behavior in the product in order be resolved. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. Mgmt This issue is related to a management-plane library. RestAPI Service Attention Workflow: This issue is responsible by Azure service team.
Milestone

Comments

@chouseknecht
Copy link

Is there a way to get an instance view returned from the list() or list_all() methods of the VirtualMachineOperations class?

Building the Azure inventory script for Ansible. Fetching the list of machines for a subscription of for a specific resource group returns data within 3 or 4 seconds. However, the machine objects do not include the instance view and thus no power state information. To get that information I'm calling the get() method for each machine and providing an expand parameter value of 'instanceView', which makes the overall process very slow.

Is there a more efficient way to do this?

@lmazuel
Copy link
Member

lmazuel commented Apr 13, 2016

It seems that the REST API itself does not provide this feature:
https://msdn.microsoft.com/en-us/library/azure/mt163572.aspx

@devigned do you have someone in the Compute team which can help us here? The SDK 2.0.0rc2 is using the 2016-03-30 Swagger file.

@chouseknecht
Copy link
Author

Any insights on this one?

@roadbikemike
Copy link

I agree completely on this! Having to call VirtualMachines.Get on every machine in a LIst() is terribly inefficient and very slow. Been over a year and no progress :-(

@devigned
Copy link
Member

@squillace what do you think about making this happen?

@pparamalingam
Copy link

Is this feature still being considered to be added to the REST API?

@jogipraveen
Copy link

I'm trying to fetch the VM instances with the status. It would be great if we get the all VM details (VM size, memory, IP, status, etc..) in one place.

@devigned
Copy link
Member

@squillace or @singhkays any feedback on this issue?

@singhkays
Copy link

@nibhat should be able to answer decisively once he's back from leave but I haven't heard anything about this being considered as an add to the REST API over the many other priorities for the Compute team.

@devigned
Copy link
Member

Thank you, @singhkays!

@davidbairdala
Copy link

davidbairdala commented Feb 7, 2018

Has there been any progress on this issue, or is anyone from Microsoft able to comment on this? I see that the REST documentation for List All virtual machines now includes in results 'properties.instanceView', but when I call this api directly the instance view is not returned.

@squillace
Copy link

apologies, @davidbairdala I'll ping the appropriate people. I'm not the one to handle it.

@davidbairdala
Copy link

davidbairdala commented Feb 7, 2018

Thanks @squillace

@squillace
Copy link

@lmazuel can you have a look? Thanks so much.

@lmazuel
Copy link
Member

lmazuel commented Feb 7, 2018

As far as I know, this is still not supported. We are investigating alternative ways, but nothing solid enough to be documented and suggested yet.

@ioannisas
Copy link

This would be a really nice enhancement to have. It's impossible, as far as processing time is concerned, to have the power state along with other VM info. Any update on this?

@jpdiazsidaras
Copy link

Hey Team! I'm doing some report right now, using PowerBI and the Azure API's, It will be great, if the status of the machine cannot be added to the standard ListAll VMs call, at least have a ListAll for the instaceView, so you can call all the instanceView at once and after that cross the information. Thanks!

@ricardobranco777
Copy link

Adding this would benefit the cli as well.

@woosley
Copy link

woosley commented Jun 17, 2019

I want this too, because i have to create new http for every VM to get the instanceView, which makes the program very slow.

@mjconnection mjconnection self-assigned this Jun 17, 2019
@mjconnection mjconnection added feature-request This issue requires a new behavior in the product in order be resolved. and removed Compute labels Jun 17, 2019
@shandilvarun
Copy link

shandilvarun commented Jul 9, 2019

To get the power state for the instances in bulk you can use following CLI option.

az vmss list-instances --expand instanceView --select instanceView --resource-group "resourceGroupName" --subscription "subID" --name "vmssName"

@lmazuel
Copy link
Member

lmazuel commented Jul 9, 2019

Hi @shandilvarun
Thank you for your answer, but first this is the SDK repo, so the CLI command doesn't answer the question, and second this is VMSS specific: In case of VMSS, you can indeed get all instanceView using this method.

compute_client.virtual_machine_scale_set_vms.list(expand="instanceView")

@mobilemeneer
Copy link

mobilemeneer commented Aug 26, 2019

Good request. Having to query all vm's and then the instanceviews per vm to get the powerstate takes too long. Please add the instanceview to the list or listall. That will make things easier and much faster.

Update: I found the following page https://docs.microsoft.com/en-us/rest/api/dtl/virtualmachines/list#computevminstanceviewstatus

which is able to add an $expand: https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DevTestLab/labs/{labName}/virtualmachines?$expand={$expand}&$filter={$filter}&$top={$top}&$orderby={$orderby}&api-version=2018-09-15

Please note that this is DevTestLab of Microsoft, i hope this feature will come to https://management.azure.com/subscriptions/{subscriptionId}/providers/Microsoft.Compute/virtualMachines?api-version=2018-06-01

@welabbar1
Copy link

I am bumping this as well. Please consider this!

@jjohndrow
Copy link

I think this feature needed and I have for a long time. Right now if you need to do this through the API you have to make n+1 API requests where n is the number of VM's. This means if you have 500 VM's, 501 API calls are made to list and get each machine instead of a big paginated list. Is there somewhere else this issue lives as well? This is an deeper issue than just python SDK. We use the rest service exclusively these days and would love to see this resolved.

@welabbar1
Copy link

welabbar1 commented Jan 23, 2020

I wonder now... Is this why the power state of the VMs is always slow and lagging behind when you get the full list of VMs on the AzureStack portal??? 😬😬😬

Update: It actually seems so! The Ibiza portal uses Knockout JS to get its data from the API and immediately present it to the view, and whilst you get an almost immediate response when it comes to the List of VMs, It seems that there is a request being sent for every single VM, and on the Integrated AzureStack that i manage(one of many), it takes a very long time to get the status of all of the VMs.

Similar behavior on the Azure Off-Prem Portal. It is how the API is designed...

@welabbar1
Copy link

welabbar1 commented Feb 11, 2020

I have managed to workaround (on the GUI) this using:

  1. Flask-SocketIO to emit a dictionary of VM information ( list_all().next().as_dict() ) to the frontend's knockout JS observables (name, rg, type, size, subid, status showing loading gif, and extensions showing loading gif)

2.For every VM that gets processed, it would immediately write a row in the paginated jQuery Datatable to display to the user immediately and make an asynchronous AJAX call with the parameters of vmname, vmrg, region, and subid to the "vmstatus" api that i have waiting in Flask.

  1. When the AJAX response is received, the results are imposed on the respective knockout observable for the VM and the DataTable rows are invalidated in order to replace the loading gif with the required information (datatable.rows().invalidate())

The experience is exactly like the one using the Ibiza portal. The user gets, what appears to be, an immediate response but of course it will not work with Ansible :( sorry.

@lmazuel lmazuel added this to the Backlog milestone May 4, 2020
@prajaktasd
Copy link

Is this resolved yet or one still needs to perform get call by lopping over the list of vms to get the status.

@jongio jongio added the Mgmt This issue is related to a management-plane library. label Sep 8, 2020
@azure-sdk azure-sdk added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Sep 24, 2020
@RAY-316 RAY-316 added the issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. label Dec 15, 2021
@ghost
Copy link

ghost commented Dec 15, 2021

Hi @chouseknecht. Thank you for opening this issue and giving us the opportunity to assist. We believe that this has been addressed. If you feel that further discussion is needed, please add a comment with the text “/unresolve” to remove the “issue-addressed” label and continue the conversation.

@ghost
Copy link

ghost commented Dec 22, 2021

Hi @chouseknecht, since you haven’t asked that we “/unresolve” the issue, we’ll close this out. If you believe further discussion is needed, please add a comment “/unresolve” to reopen the issue.

@ghost ghost closed this as completed Dec 22, 2021
@ghost
Copy link

ghost commented May 26, 2022

Hi zsandrus, only the original author of the issue can ask that it be unresolved. Please open a new issue with your scenario and details if you would like to discuss this topic with the team.

1 similar comment
@ghost
Copy link

ghost commented May 26, 2022

Hi zsandrus, only the original author of the issue can ask that it be unresolved. Please open a new issue with your scenario and details if you would like to discuss this topic with the team.

@edrogers
Copy link

For those looking to get the instance status for all VMs without having to make API calls for each VM one-by-one, I had success using the ComputeManagementClient.virtual_machines.list_all(status_only=True) method. (Surprising to see this issue was closed without mentioning it.)

Hope that helps!

@ricardobranco777
Copy link

For those looking to get the instance status for all VMs without having to make API calls for each VM one-by-one, I had success using the ComputeManagementClient.virtual_machines.list_all(status_only=True) method. (Surprising to see this issue was closed without mentioning it.)

Hope that helps!

This only returns the statuses but not the instance views.

@davidbairdala
Copy link

If you are wanting to get instance view properties for a list of VMs in an efficient manner you might consider just using the Graph API instead (see https://learn.microsoft.com/en-us/graph/use-the-api)

@zsandrus
Copy link

For those looking to get the instance status for all VMs without having to make API calls for each VM one-by-one, I had success using the ComputeManagementClient.virtual_machines.list_all(status_only=True) method. (Surprising to see this issue was closed without mentioning it.)

Hope that helps!

Thanks, this works for my use case. It's still one additional call, but that's better than one call per VM.

@github-actions github-actions bot locked and limited conversation to collaborators Apr 13, 2023
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Compute - VM customer-reported Issues that are reported by GitHub users external to the Azure organization. feature-request This issue requires a new behavior in the product in order be resolved. issue-addressed Workflow: The Azure SDK team believes it to be addressed and ready to close. Mgmt This issue is related to a management-plane library. RestAPI Service Attention Workflow: This issue is responsible by Azure service team.
Projects
None yet
Development

No branches or pull requests