Skip to content

Commit e1438cc

Browse files
authored
Merge pull request #108734 from SnehaGunda/breadcrumb
Adding private link CLI script
2 parents 52373b2 + d0fecb3 commit e1438cc

File tree

2 files changed

+78
-2
lines changed

2 files changed

+78
-2
lines changed

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

Lines changed: 77 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,6 @@ New-AzPrivateDnsRecordSet -Name $recordName `
172172
After the private endpoint is provisioned, you can query the IP addresses and the FQDN mapping by using the following PowerShell script:
173173

174174
```azurepowershell-interactive
175-
176175
$pe = Get-AzPrivateEndpoint -Name MyPrivateEndpoint -ResourceGroupName myResourceGroup
177176
$networkInterface = Get-AzNetworkInterface -ResourceId $pe.NetworkInterfaces[0].Id
178177
foreach ($IPConfiguration in $networkInterface.IpConfigurations)
@@ -181,6 +180,83 @@ foreach ($IPConfiguration in $networkInterface.IpConfigurations)
181180
}
182181
```
183182

183+
## Create a private endpoint by using Azure CLI
184+
185+
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.
186+
187+
```azurecli-interactive
188+
# Resource group where the Azure Cosmos account and virtual network resources are located
189+
ResourceGroupName="myResourceGroup"
190+
191+
# Subscription ID where the Azure Cosmos account and virtual network resources are located
192+
SubscriptionId="<your Azure subscription ID>"
193+
194+
# Name of the existing Azure Cosmos account
195+
CosmosDbAccountName="mycosmosaccount"
196+
197+
# API type of your Azure Cosmos account: Sql, MongoDB, Cassandra, Gremlin, or Table
198+
CosmosDbApiType="Sql"
199+
200+
# Name of the virtual network to create
201+
VNetName="myVnet"
202+
203+
# Name of the subnet to create
204+
SubnetName="mySubnet"
205+
206+
# Name of the private endpoint to create
207+
PrivateEndpointName="myPrivateEndpoint"
208+
209+
# Name of the private endpoint connection to create
210+
PrivateConnectionName="myConnection"
211+
212+
az network vnet create \
213+
--name $VNetName \
214+
--resource-group $ResourceGroupName \
215+
--subnet-name $SubnetName
216+
217+
az network vnet subnet update \
218+
--name $SubnetName \
219+
--resource-group $ResourceGroupName \
220+
--vnet-name $VNetName \
221+
--disable-private-endpoint-network-policies true
222+
223+
az network private-endpoint create \
224+
--name $PrivateEndpointName \
225+
--resource-group $ResourceGroupName \
226+
--vnet-name $VNetName \
227+
--subnet $SubnetName \
228+
--private-connection-resource-id "/subscriptions/$SubscriptionId/resourceGroups/$ResourceGroupName/providers/Microsoft.DocumentDB/databaseAccounts/$CosmosDbAccountName" \
229+
--group-ids $CosmosDbApiType \
230+
--connection-name $PrivateConnectionName
231+
```
232+
233+
### Integrate the private endpoint with a private DNS zone
234+
235+
After you create the private endpoint, you can integrate it with a private DNS zone by using the following Azure CLI script:
236+
237+
```azurecli-interactive
238+
zoneName="privatelink.documents.azure.com"
239+
240+
az network private-dns zone create --resource-group $ResourceGroupName \
241+
--name $zoneName
242+
243+
az network private-dns link vnet create --resource-group $ResourceGroupName \
244+
--zone-name $zoneName\
245+
--name myzonelink \
246+
--virtual-network $VNetName \
247+
--registration-enabled false
248+
249+
#Query for the network interface ID
250+
networkInterfaceId=$(az network private-endpoint show --name $PrivateEndpointName --resource-group $ResourceGroupName --query 'networkInterfaces[0].id' -o tsv)
251+
252+
# Copy the content for privateIPAddress and FQDN matching the Azure Cosmos account
253+
az resource show --ids $networkInterfaceId --api-version 2019-04-01 -o json
254+
255+
#Create DNS records
256+
az network private-dns record-set a create --name recordSet1 --zone-name privatelink.documents.azure.com --resource-group $ResourceGroupName
257+
az network private-dns record-set a add-record --record-set-name recordSet2 --zone-name privatelink.documents.azure.com --resource-group $ResourceGroupName -a <Private IP Address>
258+
```
259+
184260
## Create a private endpoint by using a Resource Manager template
185261

186262
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.

articles/cosmos-db/local-emulator-export-ssl-certificates.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Export the Azure Cosmos DB Emulator certificates
33
description: When developing in languages and runtimes that do not use the Windows Certificate Store you will need to export and manage the SSL certificates. This post gives step by step instructions.
44
ms.service: cosmos-db
5-
ms.topic: tutorial
5+
ms.topic: conceptual
66
ms.date: 05/23/2019
77
author: deborahc
88
ms.author: dech

0 commit comments

Comments
 (0)