Problem is that sample code raises exception.
import json
from azure.identity import AzureCliCredential,DefaultAzureCredential
from azure.mgmt.resourcehealth import MicrosoftResourceHealth
#https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/resourcehealth/azure-mgmt-resourcehealth
def main():
resourcehealth_client = MicrosoftResourceHealth(
credential=AzureCliCredential(),
subscription_id = 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'
)
emerging_events_list = list(resourcehealth_client.emerging_issues.list())
print(f"There are {len(emerging_events_list)} emerging issues items")
if __name__ == "__main__":
main()
Exception;
azure.core.exceptions.DeserializationError: (', ValueError: Invalid datetime string: 2023-02-23 11:23:39Z', 'Cannot deserialize datetime object.', ValueError('Invalid datetime string: 2023-02-23 11:23:39Z'))
Whereas other operations are successful, e.g.
availability_statuses_list = list(resourcehealth_client.availability_statuses.list_by_subscription_id())
How is it possible to return data from emerging issues?
Thanks
I tried in my environment and got below results: Initially, I got an same error in my environment.
azure.core.exceptions.DeserializationError: (', DeserializationError: (", DeserializationError: (', ValueError: Invalid datetime string:2023-02-25 06:15:04Z', 'Cannot deserialize datetime object.', ValueError('Invalid datetime string: 2023-02-25 06:15:04Z'))",'Unable to deserialize response data. Data: 2023-02-25 06:15:04Z, iso-8601'
The above error indicates that the Azure SDK for Python is unable to deserialize a response from the Microsoft Resource-health API due to an invalid datetime string.
The datetime string '2023-02-25 06:45:45Z
' in the response appears to be in an invalid format, which is causing the deserialization error. Actually python format should be 2023-02-25 06:45:45
AFAIK, this is due to Azure python SDK issue.
As a workaround, you can use this Ms-Docs to list the emergency issues with REST API using graph explorer:
Command:
GET https://management.azure.com/providers/Microsoft.ResourceHealth/emergingIssues?api-version=2018-07-01
Response:
{
"value": [
{
"id": "/providers/Microsoft.ResourceHealth/emergingissues/default",
"type": "/providers/Microsoft.ResourceHealth/emergingissues",
"name": "default",
"properties": {
"refreshTimestamp": "2023-02-25 07:14:19Z",
"statusBanners": [],
"statusActiveEvents": []
}
}
]
}
Postman: