I'd like to get/check azure resource by ID
from azure.mgmt.resource import ResourceManagementClient
resource_client = ResourceManagementClient(credentials, subscription_id)
resource_client.resources.check_existence_by_id(
'/subscriptions/<any_subscr>/resourceGroups/random_group'
'/providers/Microsoft.Compute/virtualMachines/test_vm',
api_version='2017-12-01')
fails with:
ClientRequestError: Error occurred in request., RetryError: HTTPSConnectionPool(host='management.azure.com', port=443): Max retries exceeded with url: /subscriptions/<any_subscr>/resourceGroups/random_group/providers/Microsoft.Compute/virtualMachines/test_vm?api-version=2017-12-01 (Caused by ResponseError('too many 503 error responses',))
api_version
was taken from another error. If I try to run same command with api_version=resource_client.api_version
and get:
CloudError: Azure Error: NoRegisteredProviderFound
Message: No registered resource provider found for location 'eastus2' and API version '2017-05-10' for type 'virtualMachines'. 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'. The supported locations are 'eastus, eastus2, westus, centralus, northcentralus, southcentralus, northeurope, westeurope, eastasia, southeastasia, japaneast, japanwest, australiaeast, australiasoutheast, brazilsouth, southindia, centralindia, westindia, canadacentral, canadaeast, westus2, westcentralus, uksouth, ukwest, koreacentral, koreasouth'.
but .get_by_id()
with same api_version
works fine.
Is there something wrong with check_existence_by_id
?
az resource show --id '/subscriptions/<any_subscr>/resourceGroups/random_group/providers/Microsoft.Compute/virtualMachines/test-vm'
also works as expected. without anyapi_version
specification – Leonkin