gpt4 book ai didi

c# - 如何从 Azure Key Vault 获取 VaultProperties.NetworkAcls 属性

转载 作者:行者123 更新时间:2023-12-02 23:44:26 26 4
gpt4 key购买 nike

我需要提取 azure key Vault 的防火墙和虚拟网络属性,看起来我想要的属性是 VaultProperties.NetworkAcls

这记录在 https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.management.keyvault.models.vaultproperties.networkacls?view=azure-dotnet#Microsoft_Azure_Management_KeyVault_Models_VaultProperties_NetworkAcls

但是我不明白如何提取这个属性。

我正在使用 VS 2017 c# .net core 2.1

我已经安装了 Azure SKR 并且安装了 Microsoft.Azure.Management.Fluent 1.19.0

我找不到 Microsoft.Azure.Management.KeyVault.Models.VaultProperties然而我能找到的是这个

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/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com