如何使用 Azure Java SDK 获取资源可用性状态
How to get Resource Availability Statuses with Azure Java SDK
我想了解 Azure 中资源的可用性状态。
REST API 可用于 Resource Health。
如何使用 Azure Java SDK 调用此端点?
我找到了使用 com.azure.resourcemanager:azure-resourcemanager:2.2.0
的解决方案。
以下代码加载 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();
我想了解 Azure 中资源的可用性状态。 REST API 可用于 Resource Health。
如何使用 Azure Java SDK 调用此端点?
我找到了使用 com.azure.resourcemanager:azure-resourcemanager:2.2.0
的解决方案。
以下代码加载 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();