Skip to content

Commit 2e859b4

Browse files
committed
Adding private link CLI script
1 parent 4dfbcd5 commit 2e859b4

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

articles/cosmos-db/how-to-configure-private-endpoints.md

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,57 @@ foreach ($IPConfiguration in $networkInterface.IpConfigurations)
181181
}
182182
```
183183

184+
### Create a private endpoint by using Azure CLI
185+
186+
Run the following Azure CLI script to create a private endpoint named "myPrivateEndpoint" for an existing Azure Cosmos account. Replace the variable values with the details for your environment.
187+
188+
```azurecli-interactive
189+
190+
# Resource group where the Azure Cosmos account and virtual network resources are located
191+
ResourceGroupName="myResourceGroup"
192+
193+
# Subscription ID where the Azure Cosmos account and virtual network resources are located
194+
SubscriptionId="<your Azure subscription ID>"
195+
196+
# Name of the existing Azure Cosmos account
197+
CosmosDbAccountName="mycosmosaccount"
198+
199+
# API type of your Azure Cosmos account: Sql, MongoDB, Cassandra, Gremlin, or Table
200+
CosmosDbApiType="Sql"
201+
202+
# Name of the virtual network to create
203+
VNetName="myVnet"
204+
205+
# Name of the subnet to create
206+
SubnetName="mySubnet"
207+
208+
# Name of the private endpoint to create
209+
PrivateEndpointName="myPrivateEndpoint"
210+
211+
# Name of the private endpoint connection to create
212+
PrivateConnectionName="myConnection"
213+
214+
az network vnet create \
215+
--name $VNetName \
216+
--resource-group $ResourceGroupName \
217+
--subnet-name $SubnetName
218+
219+
az network vnet subnet update \
220+
--name $SubnetName \
221+
--resource-group $ResourceGroupName \
222+
--vnet-name $VNetName \
223+
--disable-private-endpoint-network-policies true
224+
225+
az network private-endpoint create \
226+
--name $PrivateEndpointName \
227+
--resource-group $ResourceGroupName \
228+
--vnet-name $VNetName \
229+
--subnet $SubnetName \
230+
--private-connection-resource-id "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/$CosmosDbAccountName" \
231+
--group-ids $CosmosDbApiType \
232+
--connection-name $PrivateConnectionName
233+
```
234+
184235
## Create a private endpoint by using a Resource Manager template
185236

186237
You can set up Private Link by creating a private endpoint in a virtual network subnet. You achieve this by using an Azure Resource Manager template.

0 commit comments

Comments
 (0)