使用 Fluent 限制对 Azure KeyVault 的访问

Restrict access to Azure KeyVault using Fluent

我需要在创建 Key Vault 时限制对它的访问。我正在通过 Fluent sdk 创建,我可以在其中创建 KeyVault 并定义标签和资源组。

注意:使用 powershell 我可以使用以下命令执行操作:Add-AzKeyVaultNetworkRule 但使用 Fluent 我不能

这是我创建 KeyVault 的方式:

        var azureClient = await GetAzureClientWithSubscription();

        var rVault = await azureClient.Vaults
            .Define(kvName)
            .WithRegion(Region.BrazilSouth)
            .WithExistingResourceGroup(kvRG)
            .DefineAccessPolicy()
            .ForObjectId(_settings.ObjectId)
            .AllowSecretPermissions(SecretPermissions.Get)
            .AllowSecretPermissions(SecretPermissions.List)
            .AllowSecretPermissions(SecretPermissions.Set)
            .Attach()
            .WithTags(tags)
            .CreateAsync();

这是一个已知问题,已报告给 SDK 团队,您可以在创建密钥保管库后查看the issue here. though it is not so elegant, you can call this REST API设置networkAcls

或者通过 key vault ARM template by fluent SDK 创建密钥保管库。

如果您还有其他问题,请告诉我。