首页 > 解决方案 > Is there a powershell command to add ipRules to CosmosDB in azure?

问题描述

I'm trying to add an ip to the network rules of CosmosDb (firewall) in azure, using powershell.

A lot of other resources seem to have a command available to do this (eg. keyvault Add-AzKeyVaultNetworkRule -VaultName myvault -IpAddressRange "10.0.1.0/24"), but I can't find any for CosmosDb. Does anyone know if it actually exist? Thanks!

标签: azurepowershellazure-cosmosdbfirewall

解决方案


是,更新-AzCosmosDBAccount

$resourceGroupName = "myResourceGroup"
$accountName = "my-cosmos-account"
$ipFilter = @("10.0.0.0/8", "11.0.1.0/24")
$allowAzureAccess = $true

if ($true -eq $allowAzureAccess) {
    $ipFilter += "0.0.0.0"
}

Update-AzCosmosDBAccount -ResourceGroupName $resourceGroupName `
-Name $accountName -IpRangeFilter $ipFilter

推荐阅读