---
title: "Resource health through Azure Rest API"
description: "Use the Azure Rest API and PowerShell to retreive platform health state for your Azure resources."
date: 2017-09-18
updated: 2025-01-07
author: Martin Ehrnst
section: powershell
categories: [Azure, CSP Monitoring, Powershell]
tags: [api, Azure, monitoring, Powershell]
url: "https://adatum.no/powershell/resource-health-through-azure-rest-api/"
canonicalUrl: "https://adatum.no/powershell/resource-health-through-azure-rest-api"
---

As a part of a large monitoring project involving on prem, Azure and Office 365 I have started to explore the different methods on how to acquire all relevent data. Previously, I have written a post on how you authenticate against [Microsoft’s partner center API](https://adatum.no/powershell/using-powershell-against-micrsoft-partner-center-api) which is a part of the same feasibility project.
Later down the road i will try to write a larger blog series on how we can monitor Microsoft Cloud and on-Prem resources. Hopefully it will be joyful…
This blog post will describe how you can use Powershell to authenticate and get availability status from all resource groups and their resources. If you’re not that interested in monitoring data, use this post as a guide on how to get started with the API and the rest is [documented on the Azure API documentation pages.](https://docs.microsoft.com/en-us/rest/api/)
High level overview:

- Set up an Azure Active Directory Application to authenticate (not covered)
- Build an authentication header with a token from Azure AD
- Get all resource groups within a subscription
- Get the availability of all resources within a resource group

### Get Azure AD application token
After setting up/registering the application in Azure AD you will have to use the application ID and secret in order to generate an authentication token to use against Azure management Rest API’s.

### Get all resource groups and resources
The Resource Health API endpoint supports query by resource, resource group, and subscriptions. First, gather all resource groups, then iterate each group to collect resource IDs for health checks.

### Get the resource availability status
The output from this endpoint includes current status and previous events for each resource.

Other examples are to get [availability by Resource](https://docs.microsoft.com/en-us/rest/api/resourcehealth/availabilitystatuses/getbyresource) and the [entire subscription](https://docs.microsoft.com/en-us/rest/api/resourcehealth/availabilitystatuses/listbysubscriptionid).
