compute_client = authenticate.client_management(subscription_id)
for resource_group in resources_groups.keys():
vm_list = compute_client.virtual_machines.list(resource_group)
for vm in vm_list:
array = vm.id.split("/")
locks_client = authenticate.locks_client(subscription_id)
result = locks_client.management_locks.list_at_resource_level(resource_group, "Microsoft.Compute",
"/subscriptions/XXXXXX/resourceGroups/YYYY",
"Microsoft.Compute/virtualMachines", array[-1])
Using the following class for locks ::
/usr/local/lib/python3.8/dist-packages/azure/mgmt/resource/locks/v2016_09_01/operations/_management_locks_operations.py
The result of the above program is ::
azure.core.exceptions.ResourceNotFoundError: (InvalidResourceType) The resource type could not be found in the namespace 'Microsoft.Compute' for api version '2016-09-01'.
Code: InvalidResourceType
Can someone please help me fix this.
Thanks.
azure.core.exceptions.ResourceNotFoundError:(InvalidResourceType) The resource type could not be found in the namespace 'Microsoft.Compute' for api version '2016-09-01'. Code: InvalidResourceType
The above error is usually occurs:
The above used Api version is not supported in resourcetypes kindly check the below image has been provided listed of api version in it.
Check and use the correct API Versions:
Locations:
Reference: View resource provider-MSFT Docs