I need to restrict access to the Key Vault at the time it is created. I am creating through the Fluent sdk, where I can create the KeyVault and define Tags and Resource Group.
Note: with powershell I can perform the operation using the command: Add-AzKeyVaultNetworkRule but using Fluent I cannot
here how i create the 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();
This is a known issue that has been reported to the SDK team, you can see the issue here. though it is not so elegant, you can call this REST API to set
networkAcls
after the key vault is created.Or just create a key vault by key vault ARM template by fluent SDK.
Let me know if you have any more questions.