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

标签 c# azure .net-core azure-keyvault

我需要提取 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/

相关文章:

c# - 附加类型的实体失败,因为相同类型的另一个实体已经具有相同的主键值。

powershell - Azure PowerShell Connect-AzureAD 和登录-AzureRmAccount

authentication - .NET Core 2 Api 与 Azure AD 和 Windows 身份验证

azure - Azure Web App 的替代 Azure 资源来运行后台服务

c# - 创建针对 .Net Framework 4.5 和 .Net Standard 的库

c# - Azure devops - 在 netcore/模板项目之外找不到 NUnit 测试

c# - 直接检查是否有任何服务已停止的任何替代方法?

c# - 使用 Google Calendar API 创建全天事件

c# - FabricConnectionDeniedException - 在哪里设置 Azure Service Fabric 连接?

azure - ARM 模板 API 管理部署策略内容