Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This quickstart describes how to use an Azure Resource Manager template (ARM Template) to create a DNS zone with an A
record in it.
An Azure Resource Manager template is a JavaScript Object Notation (JSON) file that defines the infrastructure and configuration for your project. The template uses declarative syntax. You describe your intended deployment without writing the sequence of programming commands to create the deployment.
If your environment meets the prerequisites and you're familiar with using ARM templates, select the Deploy to Azure button. The template will open in the Azure portal.
If you don't have an Azure subscription, create a trial account before you begin.
The template used in this quickstart is from Azure Quickstart Templates.
In this quickstart, you'll create a unique DNS zone with a suffix of azurequickstart.org
. An A
record pointing to two IP addresses will also be placed in the zone.
{
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
"contentVersion": "1.0.0.0",
"metadata": {
"_generator": {
"name": "bicep",
"version": "0.8.9.13224",
"templateHash": "3207741835848035910"
}
},
"parameters": {
"zoneName": {
"type": "string",
"defaultValue": "[format('{0}.azurequickstart.org', uniqueString(resourceGroup().id))]",
"metadata": {
"description": "The name of the DNS zone to be created. Must have at least 2 segments, e.g. hostname.org"
}
},
"recordName": {
"type": "string",
"defaultValue": "www",
"metadata": {
"description": "The name of the DNS record to be created. The name is relative to the zone, not the FQDN."
}
}
},
"resources": [
{
"type": "Microsoft.Network/dnsZones",
"apiVersion": "2018-05-01",
"name": "[parameters('zoneName')]",
"location": "global"
},
{
"type": "Microsoft.Network/dnsZones/A",
"apiVersion": "2018-05-01",
"name": "[format('{0}/{1}', parameters('zoneName'), parameters('recordName'))]",
"properties": {
"TTL": 3600,
"ARecords": [
{
"ipv4Address": "1.2.3.4"
},
{
"ipv4Address": "1.2.3.5"
}
]
},
"dependsOn": [
"[resourceId('Microsoft.Network/dnsZones', parameters('zoneName'))]"
]
}
],
"outputs": {
"nameServers": {
"type": "array",
"value": "[reference(resourceId('Microsoft.Network/dnsZones', parameters('zoneName'))).nameServers]"
}
}
}
Two Azure resources have been defined in the template:
- Microsoft.Network/dnsZones
- Microsoft.Network/dnsZones/A: Used to create an
A
record in the zone.
follow the instructions to sign in to Azure.
$projectName = Read-Host -Prompt "Enter a project name that is used for generating resource names" $location = Read-Host -Prompt "Enter the location (i.e. chinaeast2)" $templateUri = "https://raw.githubusercontent.com/Azure/azure-quickstart-templates/master/quickstarts/microsoft.network/azure-dns-new-zone/azuredeploy.json" $resourceGroupName = "${projectName}rg" New-AzResourceGroup -Name $resourceGroupName -Location "$location" New-AzResourceGroupDeployment -ResourceGroupName $resourceGroupName -TemplateUri $templateUri Read-Host -Prompt "Press [ENTER] to continue ..."
Wait until you see the prompt from the console.
Select Copy from the previous code block to copy the PowerShell script.
Right-click the shell console pane and then select Paste.
Enter the values.
The template deployment creates a zone with one
A
record pointing to two IP addresses. The resource group name is the project name withrg
appended.It takes a couple seconds to deploy the template. When completed, the output is similar to:
Azure PowerShell is used to deploy the template. In addition to Azure PowerShell, you can also use the Azure portal, Azure CLI, and REST API. To learn other deployment methods, see Deploy templates.
Sign in to the Azure portal.
Select Resource groups from the left pane.
Select the resource group that you created in the previous section. The default resource group name is the project name with
rg
appended.The resource group should contain the following resources seen here:
Select the DNS zone with the suffix of
azurequickstart.org
to verify that the zone is created properly with anA
record referencing the value of203.0.113.1
and203.0.113.2
.Copy one of the name server names from the previous step.
Open a command prompt, and run the following command:
nslookup www.<dns zone name> <name server name>
For example:
nslookup www.2lwynbseszpam.azurequickstart.org ns1-01.azure-dns.cn.
You should see something like the following screenshot:
The host name www.2lwynbseszpam.azurequickstart.org
resolves to 203.0.113.1
and 203.0.113.2
, just as you configured it. This result verifies that name resolution is working correctly.
When you no longer need the resources that you created with the DNS zone, delete the resource group. This action removes the DNS zone and all the related resources.
To delete the resource group, call the Remove-AzResourceGroup
cmdlet:
Remove-AzResourceGroup -Name <your resource group name>
In this quickstart, you created a:
- DNS zone
A
record
Now that you've created your first DNS zone and record using an ARM template, you can create records for a web app in a custom domain.