Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cosmosdb-private-endpoint example #1127

Merged
merged 1 commit into from
Dec 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 75 additions & 0 deletions docs/examples/101/cosmosdb-private-endpoint/main.bicep
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
param location string = resourceGroup().location
param virtualNetworkName string = 'Vnet'
param accountName string
param publicNetworkAccess string {
default: 'Enabled'
allowed: [
'Enabled'
'Disabled'
]
}
param privateEndpointName string

resource virtualNetwork 'Microsoft.Network/virtualNetworks@2020-06-01' = {
name: virtualNetworkName
location: location
properties: {
addressSpace: {
addressPrefixes: [
'172.20.0.0/16'
]
}
}
}

resource subNet 'Microsoft.Network/virtualNetworks/subnets@2020-06-01' = {
name: '${virtualNetwork.name}/default'
properties: {
addressPrefix: '172.20.0.0/24'
privateEndpointNetworkPolicies: 'Disabled'
}
}

resource databaseAccount 'Microsoft.DocumentDB/databaseAccounts@2020-06-01-preview' = {
name: accountName
location: location
kind: 'GlobalDocumentDB'
properties: {
createMode: 'Default'
consistencyPolicy: {
defaultConsistencyLevel: 'Session'
}
locations: [
{
locationName: location
failoverPriority: 0
isZoneRedundant: false
}
]
databaseAccountOfferType: 'Standard'
enableAutomaticFailover: false
enableMultipleWriteLocations: false
publicNetworkAccess: publicNetworkAccess
}
}

resource privateEndpoint 'Microsoft.Network/privateEndpoints@2020-06-01' = {
name: privateEndpointName
location: location
properties: {
subnet: {
id: subNet.id
}
privateLinkServiceConnections: [
{
name: 'MyConnection'
properties: {
privateLinkServiceId: databaseAccount.id
groupIds: [
'Sql'
]
}
}
]
}
}
106 changes: 106 additions & 0 deletions docs/examples/101/cosmosdb-private-endpoint/main.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"parameters": {
"location": {
"type": "string",
"defaultValue": "[resourceGroup().location]"
},
"virtualNetworkName": {
"type": "string",
"defaultValue": "Vnet"
},
"accountName": {
"type": "string"
},
"publicNetworkAccess": {
"type": "string",
"defaultValue": "Enabled",
"allowedValues": [
"Enabled",
"Disabled"
]
},
"privateEndpointName": {
"type": "string"
}
},
"functions": [],
"resources": [
{
"type": "Microsoft.Network/virtualNetworks",
"apiVersion": "2020-06-01",
"name": "[parameters('virtualNetworkName')]",
"location": "[parameters('location')]",
"properties": {
"addressSpace": {
"addressPrefixes": [
"172.20.0.0/16"
]
}
}
},
{
"type": "Microsoft.Network/virtualNetworks/subnets",
"apiVersion": "2020-06-01",
"name": "[format('{0}/default', parameters('virtualNetworkName'))]",
"properties": {
"addressPrefix": "172.20.0.0/24",
"privateEndpointNetworkPolicies": "Disabled"
},
"dependsOn": [
"[resourceId('Microsoft.Network/virtualNetworks', parameters('virtualNetworkName'))]"
]
},
{
"type": "Microsoft.DocumentDB/databaseAccounts",
"apiVersion": "2020-06-01-preview",
"name": "[parameters('accountName')]",
"location": "[parameters('location')]",
"kind": "GlobalDocumentDB",
"properties": {
"createMode": "Default",
"consistencyPolicy": {
"defaultConsistencyLevel": "Session"
},
"locations": [
{
"locationName": "[parameters('location')]",
"failoverPriority": 0,
"isZoneRedundant": false
}
],
"databaseAccountOfferType": "Standard",
"enableAutomaticFailover": false,
"enableMultipleWriteLocations": false,
"publicNetworkAccess": "[parameters('publicNetworkAccess')]"
}
},
{
"type": "Microsoft.Network/privateEndpoints",
"apiVersion": "2020-06-01",
"name": "[parameters('privateEndpointName')]",
"location": "[parameters('location')]",
"properties": {
"subnet": {
"id": "[resourceId('Microsoft.Network/virtualNetworks/subnets', split(format('{0}/default', parameters('virtualNetworkName')), '/')[0], split(format('{0}/default', parameters('virtualNetworkName')), '/')[1])]"
},
"privateLinkServiceConnections": [
{
"name": "MyConnection",
"properties": {
"privateLinkServiceId": "[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('accountName'))]",
"groupIds": [
"Sql"
]
}
}
]
},
"dependsOn": [
"[resourceId('Microsoft.DocumentDB/databaseAccounts', parameters('accountName'))]",
"[resourceId('Microsoft.Network/virtualNetworks/subnets', split(format('{0}/default', parameters('virtualNetworkName')), '/')[0], split(format('{0}/default', parameters('virtualNetworkName')), '/')[1])]"
]
}
]
}
4 changes: 4 additions & 0 deletions docs/examples/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@
"filePath": "101/cosmosdb-free/main.bicep",
"description": "101/cosmosdb-free"
},
{
"filePath": "101/cosmosdb-private-endpoint/main.bicep",
"description": "101/cosmosdb-private-endpoint"
},
{
"filePath": "101/cosmosdb-webapp/main.bicep",
"description": "101/cosmosdb-webapp"
Expand Down