我需要提取 azure key Vault 的防火墙和虚拟网络属性,看起来我想要的属性是 VaultProperties.NetworkAcls
但是我不明白如何提取这个属性。
我正在使用 VS 2017 c# .net core 2.1
我已经安装了 Azure SKR 并且安装了 Microsoft.Azure.Management.Fluent 1.19.0
我找不到 Microsoft.Azure.Management.KeyVault.Models.VaultProperties 然而我能找到的是这个
谢谢 埃兰加
最佳答案
我设法使用以下方法获取给定订阅的保管库信息。您还需要以下 nuget。 Microsoft.Azure.Management.KeyVault
private async Task<string> GetAccessTokenAsync(string authority, string resource)
{
var adCredential = new ClientCredential(ClientId,
ClientSecret);
var authenticationContext = new AuthenticationContext(authority);
return (await authenticationContext.AcquireTokenAsync(resource, adCredential)).AccessToken;
}
var token = await GetAccessTokenAsync(
"https://login.microsoftonline.com/<TenantId>",
"https://management.azure.com/")
var tokenCredentials = new TokenCredentials(token);
var keyVaultManagementClient =
new KeyVaultManagementClient(tokenCredentials)
{
SubscriptionId = subscriptionId
}
return keyVaultManagementClient.Vaults.Get(resourceGroupName, vaultName)
关于c# - 如何从 Azure Key Vault 获取 VaultProperties.NetworkAcls 属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54546845/