Cloud applications depend on several Azure services working together. A typical production application may use Azure Virtual Machines, App Service, Azure SQL Database, Storage Accounts, and networking resources. Even when application code is working correctly, an issue in the underlying Azure infrastructure can affect application availability.
For example, a virtual machine may become unavailable because of an unexpected host failure. A planned platform update may affect a resource, or a user-initiated operation may temporarily interrupt a service.
Application-level monitoring alone may not explain these situations. An API health check can tell you whether your application is responding, but it cannot always identify whether an Azure platform event is affecting the underlying resource.
Azure Resource Health helps developers understand these infrastructure-level problems. With the Azure Resource Manager Resource Health library for .NET, applications can retrieve resource availability information and use it in monitoring dashboards, operational tools, and diagnostic workflows.
In this article, we will understand Azure Resource Health, install the .NET SDK, authenticate with Azure, retrieve resource availability information, interpret health states, and build a practical monitoring example.
1. What Is Azure Resource Health?
Azure Resource Health is an Azure service that provides information about the current and historical health of individual Azure resources.
It helps determine whether a resource is affected by an Azure platform issue, a planned event, or an action initiated by a user.
For example, consider an application running on an Azure Virtual Machine.
Your application monitoring system may report that the application is unavailable. However, the actual cause could be:
- An unexpected host reboot.
- A planned platform maintenance event.
- A user-initiated restart.
- An infrastructure problem affecting the virtual machine.
- An unknown resource health condition.
Azure Resource Health provides additional information to help investigate these situations.
It can report availability information, event details, reasons for health changes, and recommended actions.
Resource Health vs. Application Health
These two monitoring approaches solve different problems.
| Monitoring approach | What it checks | Example |
|---|
| Application health | Application behavior | API endpoint returns HTTP 200 |
| Application Insights | Application performance and failures | High response time or exception rate |
| Azure Monitor | Metrics, logs, and alerts | CPU utilization reaches a threshold |
| Azure Resource Health | Azure resource availability | Virtual machine becomes unavailable |
| Azure Service Health | Broader Azure service issues | Regional service disruption |
A healthy application endpoint does not necessarily mean that every underlying Azure resource is healthy.
Similarly, a resource reported as Available does not guarantee that your application is functioning correctly.
For production monitoring, these signals should be considered together.
2. Understand Azure Resource Health States
Azure Resource Health provides availability information for supported resource types.
The health state is useful for identifying whether Azure knows about an issue affecting a particular resource.
Common availability states include:
Available
Available means Azure Resource Health has no known platform issue affecting the resource.
It does not guarantee that the application running on the resource is healthy.
For example, a virtual machine may be Available while its application process has stopped responding.
Unavailable
Unavailable means Resource Health has detected an issue affecting the resource.
The returned information may include the reason for the issue, its category, and recommended actions.
For example, a virtual machine may become unavailable because of an unexpected infrastructure event.
Unknown
Unknown means Azure cannot currently determine the resource's health.
This is not necessarily confirmation that the resource has failed.
It means the health information is unavailable or insufficient to determine its current condition.
Degraded
Some resource-specific health experiences and alert scenarios also expose Degraded as a health condition.
This indicates that a resource is experiencing a problem affecting its normal operation, even when it is not completely unavailable.
The exact states and health information depend on the resource type and the Resource Health operation being used.
3. Understand the Azure Resource Health .NET SDK
Microsoft provides a management library for accessing Azure Resource Health through .NET applications.
The NuGet package is:
Azure.ResourceManager.ResourceHealth
The package follows the Azure SDK design guidelines and integrates with Azure Identity for authentication.
It provides APIs for retrieving resource availability status, historical availability information, health events, and other Resource Health data.
The SDK also supports standard Azure SDK capabilities such as:
- Azure Identity authentication.
- Asynchronous operations.
- HTTP pipeline configuration.
- Error handling.
- Distributed tracing support through the Azure SDK infrastructure.
The package is available as a stable release. The version used in this article is 1.1.0.
Install the NuGet Package
Create a .NET console application:
dotnet new console -n AzureResourceHealthDemo
cd AzureResourceHealthDemo
Install the Resource Health package:
dotnet add package Azure.ResourceManager.ResourceHealth --version 1.1.0
Install Azure Identity for authentication:
dotnet add package Azure.Identity
The Resource Health management package also depends on the Azure Resource Manager library, which NuGet resolves automatically.
After installation, your application can use the Resource Health APIs.
4. Configure Azure Authentication
Before retrieving resource health information, your application must authenticate with Azure.
The recommended approach for many Azure SDK applications is DefaultAzureCredential.
DefaultAzureCredential is part of Azure Identity. It attempts supported authentication methods based on the execution environment.
For local development, it can use credentials from tools such as Azure CLI or Visual Studio.
In Azure-hosted environments, it can use an appropriately configured managed identity.
Sign In Through Azure CLI
For local development, install Azure CLI and sign in:
az login
Select the subscription you want to use:
az account set --subscription "YOUR-SUBSCRIPTION-ID"
Verify the selected subscription:
az account show
The Azure SDK can then use the available Azure CLI credentials through DefaultAzureCredential.
Configure the Required Permissions
Authentication and authorization are different.
Authentication establishes the identity of your application. Authorization determines what that identity is allowed to access.
The identity needs permission to read the relevant Resource Health information.
For example, an appropriately scoped Reader role may provide the required read access, depending on the API operation and resource scope.
For production applications, use the minimum permissions required by the monitoring workload.
Avoid assigning broad administrative permissions simply to retrieve health information.
5. Retrieve the Current Health of an Azure Resource
Now let's implement a practical example.
Assume that your application uses an Azure Virtual Machine and you want to retrieve its current health information.
Azure Resource Health provides the GetAvailabilityStatusAsync operation for retrieving the current availability status of a single resource.
The operation requires the Azure resource identifier.
An Azure resource identifier follows this structure:
/subscriptions/{subscriptionId}
/resourceGroups/{resourceGroupName}
/providers/{resourceProviderNamespace}
/{resourceType}/{resourceName}
For a virtual machine, it looks like this:
/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/production-rg/providers/Microsoft.Compute/virtualMachines/web-server-01
Replace the subscription ID, resource group, and virtual machine name with your actual Azure resource details.
Create the Monitoring Code
Open Program.cs and add the following implementation:
using Azure;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.ResourceHealth;
var resourceId = new ResourceIdentifier(
"/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/production-rg/providers/Microsoft.Compute/virtualMachines/web-server-01");
var credential = new DefaultAzureCredential();
var armClient = new ArmClient(credential);
try
{
var response = await armClient.GetAvailabilityStatusAsync(
resourceId,
expand: "recommendedactions");
var health = response.Value;
var properties = health.Properties;
Console.WriteLine($"Resource: {health.Name}");
Console.WriteLine($"Resource Type: {health.ResourceType}");
Console.WriteLine(
$"Availability: {properties?.AvailabilityState}");
Console.WriteLine(
$"Summary: {properties?.Summary}");
Console.WriteLine(
$"Context: {properties?.Context}");
Console.WriteLine(
$"Reason: {properties?.ReasonType}");
Console.WriteLine(
$"Last Reported: {properties?.ReportedOn}");
}
catch (RequestFailedException ex)
{
Console.WriteLine(
$"Azure request failed: {ex.Status} - {ex.Message}");
}
catch (AuthenticationFailedException ex)
{
Console.WriteLine(
$"Authentication failed: {ex.Message}");
}
Understand the Implementation
The first step creates a ResourceIdentifier.
It identifies the exact Azure resource whose health information you want to retrieve.
Next, DefaultAzureCredential establishes the authentication mechanism.
The ArmClient provides access to Azure Resource Manager operations. It acts as the primary client for interacting with Azure management APIs.
The following call performs the actual health query:
var response = await armClient.GetAvailabilityStatusAsync(
resourceId,
expand: "recommendedactions");
The GetAvailabilityStatusAsync extension method retrieves the current availability information for the specified resource.
The expand parameter requests additional recommended-action information when supported by the operation.
The response contains a ResourceHealthAvailabilityStatus object.
Its Properties object contains health information such as:
- AvailabilityState.
- Summary.
- Context.
- ReasonType.
- ReportedOn.
- DetailedStatus.
- RecommendedActions.
These fields help explain the condition of the resource.
The code also handles RequestFailedException and AuthenticationFailedException separately.
This is important because an Azure API failure and an authentication failure require different troubleshooting steps.
6. Interpret the Health Information
Retrieving the availability status is only the first step.
A monitoring application must interpret the returned information before deciding what to do.
For example, consider these illustrative results:
| Resource | Availability | Context | Reason |
|---|
| web-server-01 | Available | Platform | No known issue |
| web-server-02 | Unavailable | Platform Initiated | Unplanned |
| database-server | Available | Platform | No known issue |
| storage-account | Unknown | Not available | Not determined |
These values represent example scenarios, not live Azure resource information.
A simple application can classify the health state:
var availability = properties?.AvailabilityState?.ToString();
switch (availability)
{
case "Available":
Console.WriteLine("Resource is available.");
break;
case "Unavailable":
Console.WriteLine("Resource is unavailable.");
break;
case "Degraded":
Console.WriteLine("Resource health is degraded.");
break;
default:
Console.WriteLine(
$"Health state requires investigation: {availability ?? "Unknown"}");
break;
}
The application should not treat Unknown as equivalent to Unavailable.
Instead, it should record the state and investigate whether health information is temporarily unavailable.
Also remember that availability states and returned details depend on the resource type and API response.
7. Retrieve Health Information for Multiple Resources
A production application rarely depends on a single Azure resource.
For example, an enterprise application may use several virtual machines, databases, and storage accounts.
Checking each resource individually can become difficult to maintain.
The SDK also provides APIs for listing availability statuses across a subscription or resource group.
For example, the subscription-level API is available through Resource Health extension methods.
The following example retrieves availability information for resources in a subscription:
using Azure.Identity;
using Azure.ResourceManager;
using Azure.ResourceManager.ResourceHealth;
var credential = new DefaultAzureCredential();
var armClient = new ArmClient(credential);
var subscription = await armClient.GetDefaultSubscriptionAsync();
var resourceStatuses =
armClient.GetAvailabilityStatusesBySubscriptionAsync(
subscription.Id);
await foreach (var status in resourceStatuses)
{
var properties = status.Properties;
Console.WriteLine($"Resource: {status.Name}");
Console.WriteLine($"Type: {status.ResourceType}");
Console.WriteLine(
$"Availability: {properties?.AvailabilityState}");
Console.WriteLine(
$"Summary: {properties?.Summary}");
Console.WriteLine("--------------------------------");
}
This example uses the subscription associated with the default Azure credential context.
For applications that monitor a specific subscription, select that subscription explicitly rather than relying on the default subscription.
The GetAvailabilityStatusesBySubscriptionAsync method returns an asynchronous pageable collection.
This means the SDK can retrieve results across multiple pages as the application iterates through the collection.
You do not need to manually implement pagination for this SDK operation.
Monitor a Resource Group
If your application only needs to monitor resources inside one resource group, use the resource-group-level operation.
The SDK exposes GetAvailabilityStatusesByResourceGroupAsync through the Resource Health extensions.
The workflow is:
- Authenticate using DefaultAzureCredential.
- Create an ArmClient.
- Retrieve the subscription.
- Retrieve the required resource group.
- Call GetAvailabilityStatusesByResourceGroupAsync.
- Iterate through the returned availability information.
This approach is useful when an application has separate monitoring responsibilities for different environments or business services.
For example, development, staging, and production resource groups can be monitored independently.
8. Retrieve Historical Availability Information
Current health information tells you the condition of a resource now.
However, production troubleshooting often requires historical information.
For example, a developer may need to answer:
- When did the resource become unavailable?
- Was the issue planned or unplanned?
- Did the resource recover?
- Was the problem initiated by a user or the Azure platform?
- What information was reported during the health transition?
Azure Resource Health provides historical availability operations for supported resources.
The SDK includes GetAvailabilityStatusesAsync for retrieving availability transitions and impacting events associated with a resource.
Example:
var history = armClient.GetAvailabilityStatusesAsync(
resourceId);
await foreach (var item in history)
{
var properties = item.Properties;
Console.WriteLine(
$"Event: {item.Name}");
Console.WriteLine(
$"Availability: {properties?.AvailabilityState}");
Console.WriteLine(
$"Reason: {properties?.ReasonType}");
Console.WriteLine(
$"Occurred: {properties?.OccuredOn}");
Console.WriteLine(
$"Summary: {properties?.Summary}");
}
The returned collection can contain multiple records, so use asynchronous iteration.
Historical information is particularly useful when building incident reports or investigating repeated infrastructure interruptions.
Keep in mind that the amount of historical information available depends on the resource type and the Resource Health API.
9. Build a Simple Resource Health Monitoring Service
Instead of placing monitoring logic directly inside an API controller, it is better to separate the Azure integration from the application's business logic.
Consider an ASP.NET Core application that needs to monitor a production virtual machine.
A simple service can encapsulate the Resource Health query.
Create a Health Monitoring Service
using Azure.Core;
using Azure.ResourceManager;
using Azure.ResourceManager.ResourceHealth;
public class AzureResourceHealthService
{
private readonly ArmClient _armClient;
public AzureResourceHealthService(ArmClient armClient)
{
_armClient = armClient;
}
public async Task<string> GetAvailabilityAsync(
string resourceId,
CancellationToken cancellationToken = default)
{
var identifier = new ResourceIdentifier(resourceId);
var response =
await _armClient.GetAvailabilityStatusAsync(
identifier,
cancellationToken: cancellationToken);
return response.Value.Properties?
.AvailabilityState?
.ToString() ?? "Unknown";
}
}
The service receives an ArmClient through dependency injection.
It does not create a new authentication client for every request.
The method accepts a resource identifier and returns the current availability state.
Register the Azure Client
In Program.cs:
using Azure.Identity;
using Azure.ResourceManager;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSingleton<ArmClient>(_ =>
{
return new ArmClient(new DefaultAzureCredential());
});
builder.Services.AddScoped<AzureResourceHealthService>();
var app = builder.Build();
app.Run();
This configuration registers one ArmClient instance for the application lifetime.
The service can then be injected into controllers or other application components.
For production deployments, configure the credential and subscription settings according to the hosting environment.
Expose a Monitoring Endpoint
A controller can use the service to retrieve resource health information.
using Microsoft.AspNetCore.Mvc;
[ApiController]
[Route("api/resource-health")]
public class ResourceHealthController : ControllerBase
{
private readonly AzureResourceHealthService _healthService;
public ResourceHealthController(
AzureResourceHealthService healthService)
{
_healthService = healthService;
}
[HttpGet]
public async Task<IActionResult> Get(
[FromQuery] string resourceId,
CancellationToken cancellationToken)
{
if (string.IsNullOrWhiteSpace(resourceId))
{
return BadRequest("Resource ID is required.");
}
var availability =
await _healthService.GetAvailabilityAsync(
resourceId,
cancellationToken);
return Ok(new
{
ResourceId = resourceId,
Availability = availability
});
}
}
This is an illustrative integration pattern.
In a production system, do not accept arbitrary Azure resource IDs from untrusted callers. Validate resource identifiers against an approved inventory and enforce authorization before querying Azure.
You should also return structured health details and handle Azure API failures consistently rather than exposing raw exception messages to clients.
10. Use Event-Driven Monitoring Instead of Constant Polling
One important design decision is how frequently your application checks resource health.
A simple implementation might query Azure every minute.
However, repeatedly polling every resource can increase API traffic and create unnecessary monitoring overhead.
For systems that need proactive notifications, Azure provides Resource Health alerting and Azure Event Grid integration.
Resource Health Alerts
Resource Health alerts notify you when the health status of a specific Azure resource changes.
These alerts can be configured through Azure Service Health and connected to action groups.
Action groups support notification and integration channels such as:
- Email.
- SMS.
- Webhooks.
- IT service management integrations.
This is useful when an operations team needs to respond to infrastructure changes quickly.
Azure Event Grid
Azure Resource Notifications can publish resource health events through Event Grid.
Your application can subscribe to relevant events and process availability changes as they occur.
For example:
Azure Resource Health
|
v
Event Grid
|
v
Event Subscription
|
v
Webhook / Function
|
v
.NET Monitoring Service
|
v
Dashboard / Notification
This approach is useful for systems that need event-driven monitoring instead of continuously querying Azure.
A practical architecture can combine both approaches:
- Event Grid for receiving health-change notifications.
- Resource Health SDK for retrieving current status and additional details.
- Azure Monitor for application and infrastructure metrics.
- Application Insights for application-level diagnostics.
This gives developers a more complete view of production health.
11. Troubleshoot Common Resource Health Problems
Authentication Failed
If DefaultAzureCredential cannot authenticate, verify that you are signed in through Azure CLI or that the application's managed identity is configured correctly.
For local development:
az login
Check the selected subscription:
az account show
For Azure-hosted applications, verify the managed identity configuration and role assignments.
Authorization Failed
An authenticated identity may still lack permission to read Resource Health information.
Check the role assignments at the appropriate subscription or resource scope.
Use a least-privilege role that includes the required read operations.
Resource Health Information Is Missing
Not every Azure resource type has identical health checks or availability information.
Check whether the resource type is supported by Resource Health.
Also verify that the resource identifier points to the correct Azure resource.
Unknown Health State
Unknown does not necessarily mean that the resource is unavailable.
It means Azure cannot currently determine its health.
Check the reported timestamp, application metrics, resource logs, and other monitoring signals before declaring an outage.
Request Failed or Timed Out
Azure management requests can fail because of network problems, service throttling, temporary platform issues, or invalid request parameters.
Handle RequestFailedException and use the Azure SDK's built-in retry behavior appropriately.
For production monitoring, record the request status, resource identifier, and failure time without exposing sensitive information.
12. Best Practices for Production Monitoring
Use Managed Identity in Azure
When deploying the monitoring application to Azure, prefer managed identity over storing client secrets in configuration files.
This reduces credential-management overhead.
Reuse ArmClient
Create and reuse the ArmClient instead of constructing a new instance for every resource query.
This improves consistency and avoids unnecessary client initialization.
Monitor Only Required Resources
Do not query every resource in a subscription if your application only depends on a specific group of services.
Maintain an inventory of important resources and monitor them according to business requirements.
Combine Resource Health With Application Monitoring
Resource Health explains Azure resource conditions.
Application Insights and Azure Monitor provide other signals, such as request failures, exceptions, CPU usage, and response times.
Combining these signals makes troubleshooting more effective.
Avoid Excessive Polling
Use Event Grid or Resource Health alerts for proactive health-change notifications.
Use SDK queries when your application needs to retrieve current status, historical information, or additional event details.
Store Historical Monitoring Data
For operational reporting, consider storing important health transitions in a database or logging platform.
This makes it easier to analyze recurring problems and prepare incident reports.
Handle Unknown States Carefully
Do not automatically classify Unknown as a resource failure.
Treat it as an unresolved monitoring condition and investigate it using additional signals.
13. Advantages and Limitations
Advantages
- Infrastructure visibility: Developers can identify Azure resource health problems separately from application failures.
- Programmatic access: The .NET SDK allows applications to retrieve health information without manually using the Azure portal.
- Historical information: Availability transitions help investigate previous infrastructure incidents.
- Integration with .NET: The SDK works with Azure Identity and Azure Resource Manager clients.
- Operational automation: Health information can be integrated into dashboards, incident workflows, and internal monitoring tools.
- Event-driven integration: Resource Health alerts and Event Grid provide alternatives to constant polling.
Limitations
- Resource coverage: Health information and supported checks vary by Azure resource type.
- Not application monitoring: Resource Health does not replace application-level monitoring or endpoint health checks.
- Permissions required: The application identity must have appropriate access to the required resource information.
- Health reporting limitations: Unknown means Azure cannot determine the resource's condition, not necessarily that it has failed.
- Additional integration work: Developers still need to build dashboards, notifications, storage, and incident-management workflows around the returned information.
Conclusion
Azure Resource Health provides valuable information about the availability of individual Azure resources.
By using the Azure.ResourceManager.ResourceHealth library, .NET applications can retrieve current availability states, examine historical health transitions, and integrate infrastructure information into operational monitoring systems.
The Azure SDK makes this integration straightforward through ArmClient, Azure Identity, and asynchronous Resource Health operations.
For production applications, the best approach is to combine Resource Health with Azure Monitor, Application Insights, and event-driven notifications.
This helps development and operations teams understand whether an issue originates in application code, infrastructure, or the Azure platform, making troubleshooting more effective and improving overall service visibility.
Join the conversation! Your thoughts help the community grow.