0

I'm interested in querying service health (as opposed to resource health). As described here;

"Service Health provides a personalized view of the status of your Azure services and regions, as well as information about current incidents, planned maintenance, and health advisories."

https://azure.microsoft.com/en-us/get-started/azure-portal/service-health/#overview

Is there a way to achieve this using the Azure SDK for python?

I notice there is a Microsoft Azure Resource Health Management Client Library https://azuresdkdocs.blob.core.windows.net/$web/python/azure-mgmt-resourcehealth/1.0.0b3/index.html

But not sure this is the correct client or indeed how to get started with it.

Any guidance would be much appreciated

krafty1010
  • 19
  • 3

1 Answers1

1

I tried in my environment and got below results:

You can use this document for the azure service health library using python.

To start with the Azure Management Health Client Library, you need to install package:

pip install azure-mgmt-resourcehealth

I used the sample code to get the availability status of the azure-resource eg-(virtual-machine).

Code:

from azure.mgmt.resourcehealth import MicrosoftResourceHealth
from azure.identity import DefaultAzureCredential

credential = DefaultAzureCredential()
subscription_id = "b83c1ed3-c5b6-44fb-b5ba-2b83a074c23f"
health_client = MicrosoftResourceHealth(credential, subscription_id)
query= health_client.availability_statuses.get_by_resource(resource_uri="/subscriptions/<subscriptionID>/resourceGroups/<your-resource-grp>/providers/Microsoft.Compute/virtualMachines/vm1326")
print(query.properties)

Output:

enter image description here

{'additional_properties': {'title': 'Available', 'occuredTime': '2023-02-21T12:04:17Z', 'context': 'Not Applicable', 'category': 'Not Applicable'}, 'availability_state': 'Available', 'summary': "There aren't any known Azure platform problems affecting this virtual machine.", 'detailed_status': None, 'reason_type': '', 'root_cause_attribution_time': None, 'health_event_type': None, 'health_event_cause': None, 'health_event_category': None, 'health_event_id': None, 'resolution_eta': None, 'occurred_time': None, 'reason_chronicity': 'Persistent', 'reported_time': datetime.datetime(2023, 2, 21, 13, 4, 46, 863775, tzinfo=<isodate.tzinfo.Utc object at 0x000001B773A58F70>), 'recently_resolved': None, 'recommended_actions': None, 'service_impacting_events': None}
Venkatesan
  • 3,748
  • 1
  • 3
  • 15