The New-AzPrivateDnsRecordConfig cmdlet creates a local PSPrivateDnsRecord object. An array of these objects is passed to the New-AzPrivateDnsRecordSet cmdlet using the PrivateDnsRecord parameter to specify the records to create in the record set.
Examples
Example 1: Create a RecordSet of type A
$Records = @()
$Records += New-AzPrivateDnsRecordConfig -IPv4Address 1.2.3.4
$RecordSet = New-AzPrivateDnsRecordSet -Name "www" -RecordType A -ResourceGroupName "MyResourceGroup" -TTL 3600 -ZoneName "myzone.com" -PrivateDnsRecords $Records
# When creating a RecordSet containing a single record, the above sequence can also be condensed into a single line:
$RecordSet = New-AzPrivateDnsRecordSet -Name "www" -RecordType A -ResourceGroupName "MyResourceGroup" -TTL 3600 -ZoneName "myzone.com" -PrivateDnsRecords (New-AzPrivateDnsRecordConfig -IPv4Address 1.2.3.4)
Id : /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.Netwo
rk/privateDnsZones/myzone.com/A/www
Name : www
ZoneName : myzone.com
ResourceGroupName : MyResourceGroup
Ttl : 3600
Etag : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
RecordType : A
Records : {1.2.3.4}
Metadata :
IsAutoRegistered :
# To create a record set containing multiple records, use New-AzPrivateDnsRecordConfig to add each record to the $Records array,
# then call New-AzPrivateDnsRecordSet, as follows:
$Records = @()
$Records += New-AzPrivateDnsRecordConfig -IPv4Address 1.2.3.4
$Records += New-AzPrivateDnsRecordConfig -IPv4Address 5.6.7.8
$RecordSet = New-AzPrivateDnsRecordSet -Name "www" -RecordType A -ResourceGroupName "MyResourceGroup" -TTL 3600 -ZoneName "myzone.com" -PrivateDnsRecords $Records
Id : /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/MyResourceGroup/providers/Microsoft.Netwo
rk/privateDnsZones/myzone.com/A/www
Name : www
ZoneName : myzone.com
ResourceGroupName : MyResourceGroup
Ttl : 3600
Etag : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
RecordType : A
Records : {1.2.3.4, 5.6.7.8}
Metadata :
IsAutoRegistered :
This example creates a RecordSet named www in the private zone myzone.com. The record set is of type A and has a TTL of 1 hour (3600 seconds). It contains a single Private DNS record.
Id : /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Micros
oft.Network/privateDnsZones/myzone.com/AAAA/www
Name : www
ZoneName : myzone.com
ResourceGroupName : MyResourceGroup
Ttl : 3600
Etag : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
RecordType : AAAA
Records : {2001:db8::1}
Metadata :
IsAutoRegistered :
This example creates a RecordSet named www in the private zone myzone.com. The record set is of type AAAA and has a TTL of 1 hour (3600 seconds). It contains a single Private DNS record. To create a RecordSet using only one line of pn_PowerShell_short, or to create a record set with multiple records, see Example 1.
Id : /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Micros
oft.Network/privateDnsZones/myzone.com/CNAME/www
Name : www
ZoneName : myzone.com
ResourceGroupName : MyResourceGroup
Ttl : 3600
Etag : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
RecordType : CNAME
Records : {www.contoso.com}
Metadata :
IsAutoRegistered :
This example creates a RecordSet named www in the private zone myzone.com. The record set is of type CNAME and has a TTL of 1 hour (3600 seconds). It contains a single Private DNS record. To create a RecordSet using only one line of pn_PowerShell_short, or to create a record set with multiple records, see Example 1.
Id : /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Micros
oft.Network/privateDnsZones/myzone.com/MX/www
Name : www
ZoneName : myzone.com
ResourceGroupName : MyResourceGroup
Ttl : 3600
Etag : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
RecordType : MX
Records : {[5,mail.microsoft.com]}
Metadata :
IsAutoRegistered :
This command creates a RecordSet named www in the private zone myzone.com. The record set is of type MX and has a TTL of 1 hour (3600 seconds). It contains a single Private DNS record. To create a RecordSet using only one line of pn_PowerShell_short, or to create a record set with multiple records, see Example 1.
Id : /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Micros
oft.Network/privateDnsZones/3.2.1.in-addr.arpa/PTR/4
Name : 4
ZoneName : 3.2.1.in-addr.arpa
ResourceGroupName : MyResourceGroup
Ttl : 3600
Etag : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
RecordType : PTR
Records : {www.contoso.com}
Metadata :
IsAutoRegistered :
This command creates a RecordSet named 4 in the private zone 3.2.1.in-addr.arpa. The record set is of type PTR and has a TTL of 1 hour (3600 seconds). It contains a single Private DNS record. To create a RecordSet using only one line of pn_PowerShell_short, or to create a record set with multiple records, see Example 1.
Id : /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Micros
oft.Network/privateDnsZones/myzone.com/SRV/_sip._tcp
Name : _sip._tcp
ZoneName : myzone.com
ResourceGroupName : MyResourceGroup
Ttl : 3600
Etag : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
RecordType : SRV
Records : {[0,5,8080,sipservice.contoso.com]}
Metadata :
IsAutoRegistered :
This command creates a RecordSet named _sip._tcp in the private zone myzone.com. The record set is of type SRV and has a TTL of 1 hour (3600 seconds). It contains a single Private DNS record, pointing to the IP address 2001.2.3.4. The service (sip) and the protocol (tcp) are specified as part of the record set name, not as part of the record data. To create a RecordSet using only one line of pn_PowerShell_short, or to create a record set with multiple records, see Example 1.
Id : /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Micros
oft.Network/privateDnsZones/myzone.com/TXT/text
Name : text
ZoneName : myzone.com
ResourceGroupName : MyResourceGroup
Ttl : 3600
Etag : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
RecordType : TXT
Records : {This is a TXT Record}
Metadata :
IsAutoRegistered :
This command creates a RecordSet named text in the private zone myzone.com. The record set is of type TXT and has a TTL of 1 hour (3600 seconds). It contains a single Private DNS record. To create a RecordSet using only one line of pn_PowerShell_short, or to create a record set with multiple records, see Example 1.
Parameters
-Cname
The canonical name for the CNAME record to add.
Must not be relative to the name of the zone.
Must not have a terminating dot
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable,
-InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable,
-ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see
about_CommonParameters.
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.