Add quickstart - Front Door Standard/Premium with Azure DNS and custom domain (#12240)
* Add sample
* Move to Microsoft.Cdn folder
* Updates
diff --git a/quickstarts/microsoft.cdn/front-door-standard-premium-custom-domain-azure-dns/README.md b/quickstarts/microsoft.cdn/front-door-standard-premium-custom-domain-azure-dns/README.md
new file mode 100644
index 0000000..f4c16a0
--- /dev/null
+++ b/quickstarts/microsoft.cdn/front-door-standard-premium-custom-domain-azure-dns/README.md
@@ -0,0 +1,43 @@
+# Front Door Standard/Premium with Azure DNS and custom domain
+
+
+
+
+
+
+
+
+
+
+
+
+[](https://portal.azure.com/#create/Microsoft.Template/uri/https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fquickstarts%2Fmicrosoft.cdn%2Ffront-door-standard-premium-custom-domain-azure-dns%2Fazuredeploy.json) [](http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fquickstarts%2Fmicrosoft.cdn%2Ffront-door-standard-premium-custom-domain-azure-dns%2Fazuredeploy.json)
+[](http://armviz.io/#/?load=https%3A%2F%2Fraw.githubusercontent.com%2FAzure%2Fazure-quickstart-templates%2Fmaster%2Fquickstarts%2Fmicrosoft.cdn%2Ffront-door-standard-premium-custom-domain-azure-dns%2Fazuredeploy.json)
+
+This template deploys a Front Door Standard/Premium with custom domain managed through an Azure DNS zone, and Microsoft-managed TLS certificate.
+
+## Sample overview and deployed resources
+
+This sample template creates a Front Door profile with a custom domain, managed through an Azure DNS zone, and a Microsoft-managed TLS certificate. To keep the sample simple, Front Door is configured to direct traffic to a static website configured as an origin, but this could be [any origin supported by Front Door](https://docs.microsoft.com/azure/frontdoor/standard-premium/concept-origin).
+
+The following resources are deployed as part of the solution:
+
+### Front Door Standard/Premium
+- Front Door profile, endpoint, origin group, origin, and route to direct traffic to the static website.
+ - Note that you can use either the standard or premium Front Door SKU for this sample. By default, the standard SKU is used.
+- Front Door custom domain.
+
+### Azure DNS
+- DNS zone for the custom domain.
+- TXT record for validating the custom domain ownership.
+- CNAME record to configure traffic to be sent to the Front Door endpoint.
+
+## Deployment steps
+
+You can click the "deploy to Azure" button at the beginning of this document or follow the instructions for command line deployment using the scripts in the root of this repo.
+
+## Usage
+
+### Connect
+
+After you deploy the Azure Resource Manager template, you can then access the Front Door endpoint by using your custom domain name. If you access the hostname you should see a page saying _Welcome_. If you see a different error page, wait a few minutes and try again.
diff --git a/quickstarts/microsoft.cdn/front-door-standard-premium-custom-domain-azure-dns/azuredeploy.json b/quickstarts/microsoft.cdn/front-door-standard-premium-custom-domain-azure-dns/azuredeploy.json
new file mode 100644
index 0000000..6f6e801
--- /dev/null
+++ b/quickstarts/microsoft.cdn/front-door-standard-premium-custom-domain-azure-dns/azuredeploy.json
@@ -0,0 +1,209 @@
+{
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
+ "contentVersion": "1.0.0.0",
+ "metadata": {
+ "_generator": {
+ "name": "bicep",
+ "version": "0.4.1301.36686",
+ "templateHash": "2753414083007225517"
+ }
+ },
+ "parameters": {
+ "endpointName": {
+ "type": "string",
+ "defaultValue": "[format('afd-{0}', uniqueString(resourceGroup().id))]",
+ "metadata": {
+ "description": "The name of the Front Door endpoint to create. This must be globally unique."
+ }
+ },
+ "skuName": {
+ "type": "string",
+ "defaultValue": "Standard_AzureFrontDoor",
+ "allowedValues": [
+ "Standard_AzureFrontDoor",
+ "Premium_AzureFrontDoor"
+ ],
+ "metadata": {
+ "description": "The name of the SKU to use when creating the Front Door profile."
+ }
+ },
+ "originHostName": {
+ "type": "string",
+ "metadata": {
+ "description": "The host name that should be used when connecting from Front Door to the origin."
+ }
+ },
+ "dnsZoneName": {
+ "type": "string",
+ "defaultValue": "[format('{0}.azurequickstart.org', uniqueString(resourceGroup().id))]",
+ "metadata": {
+ "description": "The name of the DNS zone to create."
+ }
+ },
+ "cnameRecordName": {
+ "type": "string",
+ "defaultValue": "www",
+ "metadata": {
+ "description": "The name of the CNAME record to create within the DNS zone. The record will be an alias to your Front Door endpoint."
+ }
+ }
+ },
+ "variables": {
+ "profileName": "MyFrontDoor",
+ "originGroupName": "MyOriginGroup",
+ "originName": "MyOrigin",
+ "routeName": "MyRoute",
+ "customDomainResourceName": "[replace(format('{0}.{1}', parameters('cnameRecordName'), parameters('dnsZoneName')), '.', '-')]",
+ "dnsRecordTimeToLive": 3600
+ },
+ "resources": [
+ {
+ "type": "Microsoft.Network/dnsZones",
+ "apiVersion": "2018-05-01",
+ "name": "[parameters('dnsZoneName')]",
+ "location": "global"
+ },
+ {
+ "type": "Microsoft.Network/dnsZones/CNAME",
+ "apiVersion": "2018-05-01",
+ "name": "[format('{0}/{1}', parameters('dnsZoneName'), parameters('cnameRecordName'))]",
+ "properties": {
+ "TTL": "[variables('dnsRecordTimeToLive')]",
+ "CNAMERecord": {
+ "cname": "[reference(resourceId('Microsoft.Cdn/profiles/afdEndpoints', variables('profileName'), parameters('endpointName'))).hostName]"
+ }
+ },
+ "dependsOn": [
+ "[resourceId('Microsoft.Network/dnsZones', parameters('dnsZoneName'))]",
+ "[resourceId('Microsoft.Cdn/profiles/afdEndpoints', variables('profileName'), parameters('endpointName'))]"
+ ]
+ },
+ {
+ "type": "Microsoft.Network/dnsZones/TXT",
+ "apiVersion": "2018-05-01",
+ "name": "[format('{0}/{1}', parameters('dnsZoneName'), format('_dnsauth.{0}', parameters('cnameRecordName')))]",
+ "properties": {
+ "TTL": "[variables('dnsRecordTimeToLive')]",
+ "TXTRecords": [
+ {
+ "value": [
+ "[reference(resourceId('Microsoft.Cdn/profiles/customDomains', variables('profileName'), variables('customDomainResourceName'))).validationProperties.validationToken]"
+ ]
+ }
+ ]
+ },
+ "dependsOn": [
+ "[resourceId('Microsoft.Cdn/profiles/customDomains', variables('profileName'), variables('customDomainResourceName'))]",
+ "[resourceId('Microsoft.Network/dnsZones', parameters('dnsZoneName'))]"
+ ]
+ },
+ {
+ "type": "Microsoft.Cdn/profiles",
+ "apiVersion": "2020-09-01",
+ "name": "[variables('profileName')]",
+ "location": "global",
+ "sku": {
+ "name": "[parameters('skuName')]"
+ }
+ },
+ {
+ "type": "Microsoft.Cdn/profiles/afdEndpoints",
+ "apiVersion": "2020-09-01",
+ "name": "[format('{0}/{1}', variables('profileName'), parameters('endpointName'))]",
+ "location": "global",
+ "properties": {
+ "originResponseTimeoutSeconds": 240,
+ "enabledState": "Enabled"
+ },
+ "dependsOn": [
+ "[resourceId('Microsoft.Cdn/profiles', variables('profileName'))]"
+ ]
+ },
+ {
+ "type": "Microsoft.Cdn/profiles/originGroups",
+ "apiVersion": "2020-09-01",
+ "name": "[format('{0}/{1}', variables('profileName'), variables('originGroupName'))]",
+ "properties": {
+ "loadBalancingSettings": {
+ "sampleSize": 4,
+ "successfulSamplesRequired": 3
+ },
+ "healthProbeSettings": {
+ "probePath": "/",
+ "probeRequestType": "HEAD",
+ "probeProtocol": "Http",
+ "probeIntervalInSeconds": 100
+ }
+ },
+ "dependsOn": [
+ "[resourceId('Microsoft.Cdn/profiles', variables('profileName'))]"
+ ]
+ },
+ {
+ "type": "Microsoft.Cdn/profiles/customDomains",
+ "apiVersion": "2020-09-01",
+ "name": "[format('{0}/{1}', variables('profileName'), variables('customDomainResourceName'))]",
+ "properties": {
+ "hostName": "[substring(reference(resourceId('Microsoft.Network/dnsZones/CNAME', parameters('dnsZoneName'), parameters('cnameRecordName'))).fqdn, 0, sub(length(reference(resourceId('Microsoft.Network/dnsZones/CNAME', parameters('dnsZoneName'), parameters('cnameRecordName'))).fqdn), 1))]",
+ "tlsSettings": {
+ "certificateType": "ManagedCertificate",
+ "minimumTlsVersion": "TLS12"
+ }
+ },
+ "dependsOn": [
+ "[resourceId('Microsoft.Network/dnsZones/CNAME', parameters('dnsZoneName'), parameters('cnameRecordName'))]",
+ "[resourceId('Microsoft.Cdn/profiles', variables('profileName'))]"
+ ]
+ },
+ {
+ "type": "Microsoft.Cdn/profiles/originGroups/origins",
+ "apiVersion": "2020-09-01",
+ "name": "[format('{0}/{1}/{2}', variables('profileName'), variables('originGroupName'), variables('originName'))]",
+ "properties": {
+ "hostName": "[parameters('originHostName')]",
+ "httpPort": 80,
+ "httpsPort": 443,
+ "originHostHeader": "[parameters('originHostName')]",
+ "priority": 1,
+ "weight": 1000
+ },
+ "dependsOn": [
+ "[resourceId('Microsoft.Cdn/profiles/originGroups', variables('profileName'), variables('originGroupName'))]",
+ "[resourceId('Microsoft.Cdn/profiles', variables('profileName'))]"
+ ]
+ },
+ {
+ "type": "Microsoft.Cdn/profiles/afdEndpoints/routes",
+ "apiVersion": "2020-09-01",
+ "name": "[format('{0}/{1}/{2}', variables('profileName'), parameters('endpointName'), variables('routeName'))]",
+ "properties": {
+ "customDomains": [
+ {
+ "id": "[resourceId('Microsoft.Cdn/profiles/customDomains', variables('profileName'), variables('customDomainResourceName'))]"
+ }
+ ],
+ "originGroup": {
+ "id": "[resourceId('Microsoft.Cdn/profiles/originGroups', variables('profileName'), variables('originGroupName'))]"
+ },
+ "supportedProtocols": [
+ "Http",
+ "Https"
+ ],
+ "patternsToMatch": [
+ "/*"
+ ],
+ "queryStringCachingBehavior": "IgnoreQueryString",
+ "forwardingProtocol": "HttpsOnly",
+ "linkToDefaultDomain": "Enabled",
+ "httpsRedirect": "Enabled"
+ },
+ "dependsOn": [
+ "[resourceId('Microsoft.Cdn/profiles/customDomains', variables('profileName'), variables('customDomainResourceName'))]",
+ "[resourceId('Microsoft.Cdn/profiles/afdEndpoints', variables('profileName'), parameters('endpointName'))]",
+ "[resourceId('Microsoft.Cdn/profiles/originGroups/origins', variables('profileName'), variables('originGroupName'), variables('originName'))]",
+ "[resourceId('Microsoft.Cdn/profiles/originGroups', variables('profileName'), variables('originGroupName'))]",
+ "[resourceId('Microsoft.Cdn/profiles', variables('profileName'))]"
+ ]
+ }
+ ]
+}
\ No newline at end of file
diff --git a/quickstarts/microsoft.cdn/front-door-standard-premium-custom-domain-azure-dns/azuredeploy.parameters.json b/quickstarts/microsoft.cdn/front-door-standard-premium-custom-domain-azure-dns/azuredeploy.parameters.json
new file mode 100644
index 0000000..9318867
--- /dev/null
+++ b/quickstarts/microsoft.cdn/front-door-standard-premium-custom-domain-azure-dns/azuredeploy.parameters.json
@@ -0,0 +1,9 @@
+{
+ "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
+ "contentVersion": "1.0.0.0",
+ "parameters": {
+ "originHostName": {
+ "value": "GEN-STATIC-WEBSITE-HOST-NAME"
+ }
+ }
+}
diff --git a/quickstarts/microsoft.cdn/front-door-standard-premium-custom-domain-azure-dns/main.bicep b/quickstarts/microsoft.cdn/front-door-standard-premium-custom-domain-azure-dns/main.bicep
new file mode 100644
index 0000000..047046f
--- /dev/null
+++ b/quickstarts/microsoft.cdn/front-door-standard-premium-custom-domain-azure-dns/main.bicep
@@ -0,0 +1,147 @@
+@description('The name of the Front Door endpoint to create. This must be globally unique.')
+param endpointName string = 'afd-${uniqueString(resourceGroup().id)}'
+
+@description('The name of the SKU to use when creating the Front Door profile.')
+@allowed([
+ 'Standard_AzureFrontDoor'
+ 'Premium_AzureFrontDoor'
+])
+param skuName string = 'Standard_AzureFrontDoor'
+
+@description('The host name that should be used when connecting from Front Door to the origin.')
+param originHostName string
+
+@description('The name of the DNS zone to create.')
+param dnsZoneName string = '${uniqueString(resourceGroup().id)}.azurequickstart.org'
+
+@description('The name of the CNAME record to create within the DNS zone. The record will be an alias to your Front Door endpoint.')
+param cnameRecordName string = 'www'
+
+var profileName = 'MyFrontDoor'
+var originGroupName = 'MyOriginGroup'
+var originName = 'MyOrigin'
+var routeName = 'MyRoute'
+
+// Create a valid resource name for the custom domain. Resource names don't include periods.
+var customDomainResourceName = replace('${cnameRecordName}.${dnsZoneName}', '.', '-')
+var dnsRecordTimeToLive = 3600
+
+resource dnsZone 'Microsoft.Network/dnsZones@2018-05-01' = {
+ name: dnsZoneName
+ location: 'global'
+}
+
+resource cnameRecord 'Microsoft.Network/dnsZones/CNAME@2018-05-01' = {
+ parent: dnsZone
+ name: cnameRecordName
+ properties: {
+ TTL: dnsRecordTimeToLive
+ CNAMERecord: {
+ cname: endpoint.properties.hostName
+ }
+ }
+}
+
+resource validationTxtRecord 'Microsoft.Network/dnsZones/TXT@2018-05-01' = {
+ parent: dnsZone
+ name: '_dnsauth.${cnameRecordName}'
+ properties: {
+ TTL: dnsRecordTimeToLive
+ TXTRecords: [
+ {
+ value: [
+ customDomain.properties.validationProperties.validationToken
+ ]
+ }
+ ]
+ }
+}
+
+resource profile 'Microsoft.Cdn/profiles@2020-09-01' = {
+ name: profileName
+ location: 'global'
+ sku: {
+ name: skuName
+ }
+}
+
+resource endpoint 'Microsoft.Cdn/profiles/afdEndpoints@2020-09-01' = {
+ name: endpointName
+ parent: profile
+ location: 'global'
+ properties: {
+ originResponseTimeoutSeconds: 240
+ enabledState: 'Enabled'
+ }
+}
+
+resource originGroup 'Microsoft.Cdn/profiles/originGroups@2020-09-01' = {
+ name: originGroupName
+ parent: profile
+ properties: {
+ loadBalancingSettings: {
+ sampleSize: 4
+ successfulSamplesRequired: 3
+ }
+ healthProbeSettings: {
+ probePath: '/'
+ probeRequestType: 'HEAD'
+ probeProtocol: 'Http'
+ probeIntervalInSeconds: 100
+ }
+ }
+}
+
+resource customDomain 'Microsoft.Cdn/profiles/customDomains@2020-09-01' = {
+ name: customDomainResourceName
+ parent: profile
+ properties: {
+ hostName: substring(cnameRecord.properties.fqdn, 0, length(cnameRecord.properties.fqdn) - 1)
+ tlsSettings: {
+ certificateType: 'ManagedCertificate'
+ minimumTlsVersion: 'TLS12'
+ }
+ }
+}
+
+resource origin 'Microsoft.Cdn/profiles/originGroups/origins@2020-09-01' = {
+ name: originName
+ parent: originGroup
+ properties: {
+ hostName: originHostName
+ httpPort: 80
+ httpsPort: 443
+ originHostHeader: originHostName
+ priority: 1
+ weight: 1000
+ }
+}
+
+resource route 'Microsoft.Cdn/profiles/afdEndpoints/routes@2020-09-01' = {
+ name: routeName
+ parent: endpoint
+ dependsOn:[
+ origin // This explicit dependency is required to ensure that the origin group is not empty when the route is created.
+ ]
+ properties: {
+ customDomains: [
+ {
+ id: customDomain.id
+ }
+ ]
+ originGroup: {
+ id: originGroup.id
+ }
+ supportedProtocols: [
+ 'Http'
+ 'Https'
+ ]
+ patternsToMatch: [
+ '/*'
+ ]
+ queryStringCachingBehavior: 'IgnoreQueryString'
+ forwardingProtocol: 'HttpsOnly'
+ linkToDefaultDomain: 'Enabled'
+ httpsRedirect: 'Enabled'
+ }
+}
diff --git a/quickstarts/microsoft.cdn/front-door-standard-premium-custom-domain-azure-dns/metadata.json b/quickstarts/microsoft.cdn/front-door-standard-premium-custom-domain-azure-dns/metadata.json
new file mode 100644
index 0000000..08feec8
--- /dev/null
+++ b/quickstarts/microsoft.cdn/front-door-standard-premium-custom-domain-azure-dns/metadata.json
@@ -0,0 +1,13 @@
+{
+ "$schema": "https://aka.ms/azure-quickstart-templates-metadata-schema#",
+ "type": "QuickStart",
+ "itemDisplayName": "Front Door Standard/Premium with Azure DNS and custom domain",
+ "description": "This template creates a Front Door Standard/Premium including a custom domain on Azure DNS and Microsoft-managed certificate.",
+ "summary": "This template creates a Front Door Standard/Premium including a custom domain on Azure DNS and Microsoft-managed certificate.",
+ "githubUsername": "johndowns",
+ "docOwner": "johndowns",
+ "dateUpdated": "2022-03-03",
+ "environments": [
+ "AzureCloud"
+ ]
+}
\ No newline at end of file