{"id":8869,"library":"azure-mgmt-resourcehealth","title":"Azure Resource Health Management Client Library for Python","description":"The Azure Resource Health Management Client Library for Python enables developers to programmatically interact with Azure Resource Health, a service that provides information about the current and past health of Azure resources. It helps diagnose and get support for issues impacting resources, whether caused by Azure platform events or user actions. The current version is 1.0.0b6 and it's part of the broader Azure SDK for Python, which sees frequent updates across its various sub-packages.","status":"active","version":"1.0.0b6","language":"en","source_language":"en","source_url":"https://github.com/Azure/azure-sdk-for-python","tags":["azure","cloud","management","resource health","sdk","beta"],"install":[{"cmd":"pip install azure-mgmt-resourcehealth==1.0.0b6 azure-identity","lang":"bash","label":"Install with pip"}],"dependencies":[{"reason":"Required for authentication using DefaultAzureCredential, which is the recommended approach for Azure SDKs.","package":"azure-identity","optional":false},{"reason":"Requires Python version 3.8 or higher.","package":"Python","optional":false}],"imports":[{"symbol":"ResourceHealthMgmtClient","correct":"from azure.mgmt.resourcehealth import ResourceHealthMgmtClient"},{"note":"Required for authenticating with Azure services.","symbol":"DefaultAzureCredential","correct":"from azure.identity import DefaultAzureCredential"}],"quickstart":{"code":"import os\nfrom azure.identity import DefaultAzureCredential\nfrom azure.mgmt.resourcehealth import ResourceHealthMgmtClient\n\n# Set your Azure Subscription ID as an environment variable, e.g., AZURE_SUBSCRIPTION_ID\n# For local development, ensure you are logged in via Azure CLI (`az login`)\n# or configure environment variables for service principal authentication.\nsubscription_id = os.environ.get(\"AZURE_SUBSCRIPTION_ID\", \"YOUR_SUBSCRIPTION_ID\")\n\nif subscription_id == \"YOUR_SUBSCRIPTION_ID\":\n    raise ValueError(\"Please set the AZURE_SUBSCRIPTION_ID environment variable or replace the placeholder.\")\n\n# Authenticate using DefaultAzureCredential\n# This credential provider chain will attempt various authentication methods.\ncredential = DefaultAzureCredential()\n\n# Create the Resource Health Management Client\nresource_health_client = ResourceHealthMgmtClient(\n    credential=credential,\n    subscription_id=subscription_id\n)\n\n# Example: List service health events in the subscription\nprint(f\"Listing service health events for subscription ID: {subscription_id}\")\nfor event in resource_health_client.events.list_by_subscription_id():\n    print(f\"  Event ID: {event.event_id}, Status: {event.impacted_resource_type}, Severity: {event.severity}, Status: {event.status}\")\n\n# Example: Get availability status for a specific resource (replace with your resource URI)\n# resource_uri = \"/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/{resource_provider}/{resource_type}/{resource_name}\"\n# print(f\"\\nGetting availability status for resource: {resource_uri}\")\n# try:\n#     availability_status = resource_health_client.availability_statuses.get_by_resource(resource_uri=resource_uri)\n#     print(f\"  Availability State: {availability_status.availability_state}\")\n#     print(f\"  Summary: {availability_status.summary}\")\n# except Exception as e:\n#     print(f\"  Could not retrieve availability status: {e}\")","lang":"python","description":"This quickstart demonstrates how to authenticate with Azure using `DefaultAzureCredential` and then initialize `ResourceHealthMgmtClient` to list service health events across your subscription. Replace placeholder values like `YOUR_SUBSCRIPTION_ID` and potentially `resource_uri` with your actual Azure resource details. Ensure `AZURE_SUBSCRIPTION_ID` is set as an environment variable or passed explicitly."},"warnings":[{"fix":"Review the API-Version documentation for the specific Resource Health operations you use. If needed, pin your package version to an earlier release (e.g., `azure-mgmt-resourcehealth==1.0.0b5`) or update your code to use the latest API surface.","message":"Starting with version 1.0.0b6, this package targets only the latest API-Version available on Azure and removes APIs for other API-Versions. If your application relies on a specific, non-latest API-Version, you may need to pin to an older package version.","severity":"breaking","affected_versions":">=1.0.0b6"},{"fix":"For local development, run `az login` in your terminal. For service principals, ensure `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, and `AZURE_CLIENT_SECRET` environment variables are correctly configured. Always set `AZURE_SUBSCRIPTION_ID`.","message":"Authentication with Azure SDKs often relies on `DefaultAzureCredential`, which attempts multiple authentication methods. Common issues arise if required environment variables (e.g., `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, `AZURE_CLIENT_SECRET`, `AZURE_SUBSCRIPTION_ID`) are not set, or if `az login` (for Azure CLI) is not performed for local development.","severity":"gotcha","affected_versions":"All"},{"fix":"Always pin to a specific beta version (`==1.0.0b6`) rather than relying on `~=` or `latest` during development to avoid unexpected breakages. Refer to release notes for any new beta versions before upgrading.","message":"As a beta package, the API surface (`ResourceHealthMgmtClient` methods, parameter names, model structures) is subject to change without strict backward compatibility between minor beta versions. This is common in `b` releases within the Azure SDK.","severity":"gotcha","affected_versions":"All beta versions"},{"fix":"Consult the Azure SDK for Python documentation for the specific service you are interacting with to ensure you are using the recommended and latest client library.","message":"While `azure-mgmt-resourcehealth` is actively maintained, some older `azure-mgmt-*` client libraries have been refactored or deprecated in favor of newer `azure-resourcemanager-*` or specific `azure-mgmt-resource-*` packages. This can cause confusion if you're mixing new and old styles of Azure SDKs for other resource types.","severity":"deprecated","affected_versions":"All `azure-mgmt-*` libraries"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Ensure you are logged in via Azure CLI (`az login`), or that required environment variables like `AZURE_CLIENT_ID`, `AZURE_TENANT_ID`, and `AZURE_CLIENT_SECRET` are set for a service principal. Also, ensure `AZURE_SUBSCRIPTION_ID` is set.","cause":"The `DefaultAzureCredential` could not find valid credentials in the environment variables, Azure CLI, or other configured sources.","error":"azure.identity.CredentialUnavailableError: DefaultAzureCredential failed to retrieve a token from the following sources:..."},{"fix":"Double-check the resource URI for accuracy. Verify the `api-version` implicitly used by the client is supported for the operation. Ensure the authenticated identity has the necessary 'Reader' or 'Monitoring Reader' permissions for Azure Resource Health.","cause":"This generic error often indicates an issue with the request parameters, such as an incorrect or malformed resource URI, an unsupported API version for the requested operation, or insufficient permissions.","error":"HttpResponseError: Operation returned an invalid status 'Bad Request' (or 'NotFound')"},{"fix":"Consult the official `azure-mgmt-resourcehealth` documentation for the `1.0.0b6` version to identify the correct method/property names and usage. If necessary, pin to an older working version or adapt your code to the new API surface.","cause":"An API method or property name has changed or been removed between library versions, especially common in beta releases or due to the 'latest API version' breaking change.","error":"AttributeError: 'ResourceHealthMgmtClient' object has no attribute 'some_old_method'"}]}