diff --git a/docs/examples/101/private-dns-zone/main.bicep b/docs/examples/101/private-dns-zone/main.bicep new file mode 100644 index 00000000000..8c1a2f1af96 --- /dev/null +++ b/docs/examples/101/private-dns-zone/main.bicep @@ -0,0 +1,42 @@ +param privateDnsZoneName string = 'contoso.com' +param autoVmRegistration bool = true +param vnetName string = 'Vnet1' +param vnetAddressPrefix string = '10.0.0.0/16' +param subnetName string = 'Subnet1' +param subnetAddressPrefix string = '10.0.1.0/24' +param location string = resourceGroup().location + +resource virtualNetwork 'Microsoft.Network/virtualNetworks@2020-06-01' = { + name: vnetName + location: location + properties: { + addressSpace: { + addressPrefixes: [ + vnetAddressPrefix + ] + } + } +} + +resource subnet 'Microsoft.Network/virtualNetworks/subnets@2020-06-01' = { + name: '${virtualNetwork.name}/${subnetName}' + properties: { + addressPrefix: subnetAddressPrefix + } +} + +resource privateDnsZone 'Microsoft.Network/privateDnsZones@2018-09-01' = { + name: privateDnsZoneName + location: 'global' +} + +resource virtualNetworkLink 'Microsoft.Network/privateDnsZones/virtualNetworkLinks@2018-09-01' = { + name: '${privateDnsZone.name}/${privateDnsZone.name}-link' + location: 'global' + properties: { + registrationEnabled: autoVmRegistration + virtualNetwork: { + id: virtualNetwork.id + } + } +} diff --git a/docs/examples/101/private-dns-zone/main.json b/docs/examples/101/private-dns-zone/main.json new file mode 100644 index 00000000000..d25538dd6a8 --- /dev/null +++ b/docs/examples/101/private-dns-zone/main.json @@ -0,0 +1,83 @@ +{ + "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", + "contentVersion": "1.0.0.0", + "parameters": { + "privateDnsZoneName": { + "type": "string", + "defaultValue": "contoso.com" + }, + "autoVmRegistration": { + "type": "bool", + "defaultValue": true + }, + "vnetName": { + "type": "string", + "defaultValue": "Vnet1" + }, + "vnetAddressPrefix": { + "type": "string", + "defaultValue": "10.0.0.0/16" + }, + "subnetName": { + "type": "string", + "defaultValue": "Subnet1" + }, + "subnetAddressPrefix": { + "type": "string", + "defaultValue": "10.0.1.0/24" + }, + "location": { + "type": "string", + "defaultValue": "[resourceGroup().location]" + } + }, + "functions": [], + "resources": [ + { + "type": "Microsoft.Network/virtualNetworks", + "apiVersion": "2020-06-01", + "name": "[parameters('vnetName')]", + "location": "[parameters('location')]", + "properties": { + "addressSpace": { + "addressPrefixes": [ + "[parameters('vnetAddressPrefix')]" + ] + } + } + }, + { + "type": "Microsoft.Network/virtualNetworks/subnets", + "apiVersion": "2020-06-01", + "name": "[format('{0}/{1}', parameters('vnetName'), parameters('subnetName'))]", + "properties": { + "addressPrefix": "[parameters('subnetAddressPrefix')]" + }, + "dependsOn": [ + "[resourceId('Microsoft.Network/virtualNetworks', parameters('vnetName'))]" + ] + }, + { + "type": "Microsoft.Network/privateDnsZones", + "apiVersion": "2018-09-01", + "name": "[parameters('privateDnsZoneName')]", + "location": "global" + }, + { + "type": "Microsoft.Network/privateDnsZones/virtualNetworkLinks", + "apiVersion": "2018-09-01", + "name": "[format('{0}/{1}-link', parameters('privateDnsZoneName'), parameters('privateDnsZoneName'))]", + "location": "global", + "properties": { + "registrationEnabled": "[parameters('autoVmRegistration')]", + "virtualNetwork": { + "id": "[resourceId('Microsoft.Network/virtualNetworks', parameters('vnetName'))]" + } + }, + "dependsOn": [ + "[resourceId('Microsoft.Network/privateDnsZones', parameters('privateDnsZoneName'))]", + "[resourceId('Microsoft.Network/virtualNetworks', parameters('vnetName'))]" + ] + } + ] +} \ No newline at end of file diff --git a/docs/examples/index.json b/docs/examples/index.json index 98091bd852c..bff11186a19 100644 --- a/docs/examples/index.json +++ b/docs/examples/index.json @@ -151,6 +151,10 @@ "filePath": "101/nat-gateway-vnet/main.bicep", "description": "101/nat-gateway-vnet" }, + { + "filePath": "101/private-dns-zone/main.bicep", + "description": "101/private-dns-zone" + }, { "filePath": "101/redis-cache/main.bicep", "description": "101/redis-cache"