azure-sdk-for-python
azure-sdk-for-python copied to clipboard
az vm list error by ComputeManagementclient used the package to 28.0.0
Describe the bug Operations in the ComputeManagementclient that require pagination are failing after used the package to 28.0.0 and 29.0.0 There are 76 VMS in total. After 61 VMS are obtained, an exception occurs. Like the following error.
Exception or Stack Trace Traceback (most recent call last): File "C:\Users\xxx\PycharmProjects\dragonfly\flask\tests\integration\syncer\test_azure_syncer.py", line 21, in test_sync_vm syncer.sync_vm() File "C:\Users\xxx\PycharmProjects\dragonfly\flask\jobs\syncer\azure_syncer.py", line 57, in sync_vm for v in vm_list: File "C:\Program Files\Python310\lib\site-packages\azure\core\paging.py", line 128, in next return next(self._page_iterator) File "C:\Program Files\Python310\lib\site-packages\azure\core\paging.py", line 76, in next self._response = self._get_next(self.continuation_token) File "C:\Users\xxx\AppData\Roaming\Python\Python310\site-packages\azure\mgmt\compute\v2022_08_01\operations_virtual_machines_operations.py", line 2191, in get_next map_error(status_code=response.status_code, response=response, error_map=error_map) File "C:\Program Files\Python310\lib\site-packages\azure\core\exceptions.py", line 107, in map_error raise error azure.core.exceptions.ResourceNotFoundError: (InvalidResourceType) The resource type 'virtualMachines' could not be found in the namespace 'Microsoft.Compute' for api version '2022-07-02'. The supported api-versions are '2015-05-01-preview,2015-06-15,2016-03-30,2016-04-30-preview,2016-08-30,2017-03-30,2017-12-01,2018-04-01,2018-06-01,2018-10-01,2019-03-01,2019-07-01,2019-12-01,2020-06-01,2020-12-01,2021-03-01,2021-04-01,2021-07-01,2021-11-01,2022-03-01,2022-08-01,2022-11-01'. Code: InvalidResourceType Message: The resource type 'virtualMachines' could not be found in the namespace 'Microsoft.Compute' for api version '2022-07-02'. The supported api-versions are '2015-05-01-preview,2015-06-15,2016-03-30,2016-04-30-preview,2016-08-30,2017-03-30,2017-12-01,2018-04-01,2018-06-01,2018-10-01,2019-03-01,2019-07-01,2019-12-01,2020-06-01,2020-12-01,2021-03-01,2021-04-01,2021-07-01,2021-11-01,2022-03-01,2022-08-01,2022-11-01'.
To Reproduce Steps to reproduce the behavior:
- In my case, have a subscription with multiple pages of resources(76 VMs)
- get all vm info(disk,network,etc) from multiple resource group
Code Snippet
subscription_id = subscription.subscription_id
compute_client = ComputeManagementClient(
credential,
subscription_id=subscription_id
)
vm_list = compute_client.virtual_machines.list(resource_group.name)
for v in vm_list:
vm_id = v.vm_id
....
Expected behavior ComputeManagementClient.virtual_machines.list_all() should paginate successfully and return all resources.
Environment Package Name: azure-mgmt-compute Package Version: 28.0.0,29.0.0 Operating System: Window11 Python Version: 3.10
Thanks for the feedback, we’ll investigate asap.
Hi @den-arm, according to the log, the 2022-07-02 is not supported by service. But for azure-mgmt-compute==29.0.0, default api-version is 2022-08-01 and there is no support for 2022-07-02 about virtual_machines:
So I am wondering why you will use api-version 2021-07-02 in code. Could you check whether 29.0.0 is installed?
@msyyc Thanks for the feedback.
My development environment list the version information as following:

The api version is not set in my sourcecode. In addition, what is the version number of 'azure-mgmt-compute' corresponding to api version '2022-07-02'? I searched 'microsoft.compute' for api version '2022-07-02' by google, and only the disk resource type was released at this time. https://learn.microsoft.com/ja-jp/azure/templates/microsoft.compute/allversions
If i want to upgrade the version, do I just install the azure-mgmt-compute package to 29.0.0?
@den-arm
(1) Please run az -v to show your cli version. (I advise to use latest azure-cli)
(2) Please add --debug when you run cmd like: az vm list ... --debug. With that, detailed log will be shown and please pay attention to "api-version" and "package version":

If needed, you can share the log after conceal the sensitive info
Hi, we're sending this friendly reminder because we haven't heard back from you in a while. We need more information about this issue to help address it. Please be sure to give us your input within the next 7 days. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!