How best to deal with 422 error from Azure Availability status API

Dave Lewis 25 Reputation points
2024-02-29T11:05:26.7433333+00:00

I'm using the Availability statuses API as found here: https://learn.microsoft.com/en-us/rest/api/resourcehealth/availability-statuses/get-by-resource?view=rest-resourcehealth-2022-10-01&tabs=HTTP
I can't tell ahead of time what resources are going to get given to me. However the resources given to me will have been pulled recently from the Resource Graph. Recently we noticed that trying to query the status of the master database of a SQL Server instance produces a 422 error with the code UnsupportedResourceName and the message Resource Name not supported in this resource type.
Pulling the availability of a 'user database' works fine.
The API documentation glosses over error messages, and doesn't really say much about what is or isn't supported (mostly limited to resource nesting, which doesn't seem applicable here). Searching for the error message elsewhere has not yielded anything of use.
The master database isn't really visible in the portal. I can get to it via its ID and via the 'Resource Explorer', but via the SQL server or the standard list of resources it may as well not exist (which makes sense, it's a more 'behind the scenes' sort of resource).
I'm currently running under the assumption that it can't/doesn't have an availability.
Whilst this scenario is rooted squarely in SQL, and I could simply ignore any master database that comes in, this does nothing to help other 'unknown' types that may not be compatible that we haven't found yet (or may not have been released yet!). Ideally, I don't want to make that API call if I know the resource won't work. Is there a way of getting a list of resources/types/kinds/etc. ahead of time? Is it a sensible approach to assume that anything that returns this 422 error can't/doesn't have a status? Is there a better approach/API that I may be missing (probably won't solve the problem immediately but could be a longer term solution}?

Azure Monitor
Azure Monitor
An Azure service that is used to collect, analyze, and act on telemetry data from Azure and on-premises environments.
3,662 questions
0 comments No comments
{count} votes

Accepted answer
  1. Stanislav Zhelyazkov 28,596 Reputation points MVP Volunteer Moderator
    2024-03-01T06:42:08.79+00:00

    Hi,

    What are you describing is not something most likely you will get information for. All resource types that support resource health are described here. In the specific case you are describing the master database is system resource that is intentionally hidden. If there is something wrong with the master database you for sure will get issues on your regular user databases so the health issue will appear on them. I am not aware if there are any kind of such resources as the master database on other types of supported resources but querying the resource health API does not seems so efficient way. Instead why do not use Resource Health alerts that way you will not have to query the API all the time, instead you will get the events when the status changes. Additionally the resource health data is in Resource Graph and the graph is way more efficient and easier to use than querying the API for each resource. So my suggestion would be to use one of those two methods where you will also not have the above mentioned issues.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.