By default any Azure regions does not contain Health in its name as, Region names are the name of the Countries where Azure data centres exists. And MonitorManagementClient does not include any parameter with list_locations or locations. Refer these documents:-
azure.mgmt.monitor.MonitorManagementClient class | Microsoft Learn
azure-docs/cloud-services-python-how-to-use-service-management.md at main · MicrosoftDocs/azure-docs · GitHub
I tried using MonitorManagementClient to get list of Azure regions with Health in their name and received an error below:-
regions = client.locations.list()
AttributeError: 'MonitorManagementClient' object has no attribute 'locations'
I used the code below to get all the Azure regions with Health in its name and got no results:-
from azure.mgmt.resource import ResourceManagementClient
from azure.identity import DefaultAzureCredential
# Define Azure subscription ID
subscription_id = '<sub-id>'
# Create ResourceManagementClient object
credential = DefaultAzureCredential()
resource_client = ResourceManagementClient(credential, subscription_id)
# Retrieve the Azure regions that contain the term 'health'
regions = []
for location in resource_client.providers.get('Microsoft.Compute').resource_types[0].locations:
if 'health' in location.lower():
regions.append(location)
# Print the list of regions that contain the term 'health'
print(regions)
Output:-

In order to get the list of all regions, You can make use of the code below:-
Code 1:-
from azure.mgmt.resource import ResourceManagementClient
from azure.identity import DefaultAzureCredential
subscription_id = '<sub-id>'
credential = DefaultAzureCredential()
resource_client = ResourceManagementClient(credential, subscription_id)
regions = []
for provider in resource_client.providers.list():
for resource_type in provider.resource_types:
for location in resource_type.locations:
regions.append(location)
for region in regions:
print(region)
Output:-

If you want to check the resource health of your resources, You can make use of the code below to get the availability status of the resources by their regions or at subscription level:-
Code 1:-
Availability status by Subscription:
import requests
import json
from azure.identity import DefaultAzureCredential
credential = DefaultAzureCredential()
url = f"https://management.azure.com/subscriptions/<sub-id>/providers/Microsoft.ResourceHealth/availabilityStatuses?api-version=2022-05-01"
headers = {"Authorization": f"Bearer {credential.get_token('https://management.azure.com/.default').token}"}
response = requests.get(url, headers=headers)
print(response)
if response.status_code == 200:
health_status = json.loads(response.content.decode('utf-8'))
print(health_status)
Output:-

Resource Type by regions:-
Code2 :-
import requests
import json
from azure.identity import DefaultAzureCredential
credential = DefaultAzureCredential()
subscription_id = "<sub-id>"
resource_type = "Microsoft.Compute"
resource_name = "<vm>"
region = "UK South"
#url = f"https://management.azure.com/subscriptions/{subscription_id}/providers/Microsoft.ResourceHealth/availabilityStatuses/{resource_type}/{resource_name}/providers/Microsoft.Compute/locations/{region}?api-version=2018-07-01-preview"
url = f"https://management.azure.com/subscriptions/{subscription_id}/providers/Microsoft.ResourceHealth/availabilityStatuses/{resource_type}/{resource_name}/providers/Microsoft.Compute/locations/{region}?api-version=2018-07-01-preview"
headers = {"Authorization": f"Bearer {credential.get_token('https://management.azure.com/.default').token}"}
response = requests.get(url, headers=headers)
print(response)
if response.status_code == 200:
health_status = json.loads(response.content.decode('utf-8'))
print(health_status)
print(f"The health status of {resource_name} in {region} is {health_status['properties']['availabilityState']}")
else:
print(f"Failed to get the health status of {resource_name} in {region}. Error message: {response.content}")
As, We do not have any health issues in our VM in UK south region, It returned the response below:-
Output:-

locationto exist as an attribute? Did you see an example that used it?