I want to find out the availability status of a resource in Azure. There is a REST API available for Resource Health.
How is it possible to call this endpoint with the Azure Java SDK?
I want to find out the availability status of a resource in Azure. There is a REST API available for Resource Health.
How is it possible to call this endpoint with the Azure Java SDK?
I found a solution using com.azure.resourcemanager:azure-resourcemanager:2.2.0
.
Following code loads the availability status of an Azure Key Vault.
TokenCredential credentials = InteractiveBrowserCredentialBuilder().build();
AzureResourceManager resourceManager = AzureResourceManager
.configure()
.authenticate(credentials, AzureProfile(AzureEnvironment.AZURE))
.withDefaultSubscription();
String resourceGroup = "resource-group-name";
String keyVaultName = "key-vault-name";
GenericResource resource = resourceManager.genericResources().get(
resourceGroup,
"Microsoft.KeyVault",
"vaults/" + keyVaultName + "/providers/Microsoft.ResourceHealth",
"availabilityStatuses",
"/current",
"2020-05-01"
);
// Map containing the availabilityState
resource.properties();