Skip to content

Commit cfaeeea

Browse files
committed
Adding private DNS zone CLI script
1 parent 2e859b4 commit cfaeeea

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

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

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,34 @@ az network private-endpoint create \
232232
--connection-name $PrivateConnectionName
233233
```
234234

235+
### Integrate the private endpoint with a private DNS zone
236+
237+
After you create the private endpoint, you can integrate it with a private DNS zone by using the following Azure CLI script:
238+
239+
```azurecli-interactive
240+
241+
zoneName="privatelink.documents.azure.com"
242+
243+
az network private-dns zone create --resource-group $ResourceGroupName \
244+
--name $zoneName
245+
246+
az network private-dns link vnet create --resource-group $ResourceGroupName \
247+
--zone-name $zoneName\
248+
--name myzonelink \
249+
--virtual-network $VNetName \
250+
--registration-enabled false
251+
252+
#Query for the network interface ID
253+
networkInterfaceId=$(az network private-endpoint show --name $PrivateEndpointName --resource-group $ResourceGroupName --query 'networkInterfaces[0].id' -o tsv)
254+
255+
# Copy the content for privateIPAddress and FQDN matching the Azure Cosmos account
256+
az resource show --ids $networkInterfaceId --api-version 2019-04-01 -o json
257+
258+
#Create DNS records
259+
az network private-dns record-set a create --name recordSet1 --zone-name privatelink.documents.azure.com --resource-group $ResourceGroupName
260+
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>
261+
```
262+
235263
## Create a private endpoint by using a Resource Manager template
236264

237265
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)