Modifier

Partager via


New-AzPrivateDnsRecordSet

Creates a record set in a Private DNS zone.

Syntax

New-AzPrivateDnsRecordSet
   -ResourceGroupName <String>
   -ZoneName <String>
   -Name <String>
   -RecordType <RecordType>
   -Ttl <UInt32>
   [-Metadata <Hashtable>]
   [-PrivateDnsRecord <PSPrivateDnsRecordBase[]>]
   [-Overwrite]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzPrivateDnsRecordSet
   -Zone <PSPrivateDnsZone>
   -Name <String>
   -RecordType <RecordType>
   -Ttl <UInt32>
   [-Metadata <Hashtable>]
   [-PrivateDnsRecord <PSPrivateDnsRecordBase[]>]
   [-Overwrite]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]
New-AzPrivateDnsRecordSet
   -ParentResourceId <String>
   -Name <String>
   -RecordType <RecordType>
   -Ttl <UInt32>
   [-Metadata <Hashtable>]
   [-PrivateDnsRecord <PSPrivateDnsRecordBase[]>]
   [-Overwrite]
   [-DefaultProfile <IAzureContextContainer>]
   [-WhatIf]
   [-Confirm]
   [<CommonParameters>]

Description

The New-AzPrivateDnsRecordSet cmdlet creates a new Private Domain Name System (DNS) record set with the specified name and type in the specified private zone. A RecordSet object is a set of Private DNS records with the same name and type. Note that the name is relative to the private zone and not the fully qualified name. The PrivateDnsRecord parameter specifies the records in the record set. This parameter takes an array of Private DNS records, constructed using New-AzPrivateDnsRecordConfig. You can use the pipeline operator to pass a PSPrivateDnsZone object to this cmdlet, or you can pass a PSPrivateDnsZone object as the Zone parameter, or you can specify the zone by its ResourceId, or alternatively you can specify the zone by name. You can use the Confirm parameter and $ConfirmPreference Windows PowerShell variable to control whether the cmdlet prompts you for confirmation. If a matching RecordSet already exists (same name and record type), you must specify the Overwrite parameter, otherwise the cmdlet will not create a new RecordSet .

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.

Example 2: Create a RecordSet of type AAAA

$Records = @()
$Records += New-AzPrivateDnsRecordConfig -Ipv6Address 2001:db8::1
$RecordSet = New-AzPrivateDnsRecordSet -Name "www" -RecordType AAAA -ResourceGroupName "MyResourceGroup" -TTL 3600 -ZoneName "myzone.com" -PrivateDnsRecords $Records

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.

Example 3: Create a RecordSet of type CNAME

$Records = @()
$Records += New-AzPrivateDnsRecordConfig -Cname www.contoso.com
$RecordSet = New-AzPrivateDnsRecordSet -Name "www" -RecordType CNAME -ResourceGroupName "MyResourceGroup" -TTL 3600 -ZoneName "myzone.com" -PrivateDnsRecords $Records

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.

Example 4: Create a RecordSet of type MX

$Records = @()
$Records += New-AzPrivateDnsRecordConfig -Exchange "mail.microsoft.com" -Preference 5
$RecordSet = New-AzPrivateDnsRecordSet -Name "www" -RecordType MX -ResourceGroupName "MyResourceGroup" -TTL 3600 -ZoneName "myzone.com" -PrivateDnsRecords $Records

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.

Example 5: Create a RecordSet of type PTR

$Records = @()
$Records += New-AzPrivateDnsRecordConfig -Ptrdname www.contoso.com
$RecordSet = New-AzPrivateDnsRecordSet -Name "4" -RecordType PTR -ResourceGroupName "MyResourceGroup" -TTL 3600 -ZoneName "3.2.1.in-addr.arpa" -PrivateDnsRecords $Records

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.

Example 6: Create a RecordSet of type SRV

$Records = @()
$Records += New-AzPrivateDnsRecordConfig -Priority 0 -Weight 5 -Port 8080 -Target sipservice.contoso.com
$RecordSet = New-AzPrivateDnsRecordSet -Name "_sip._tcp" -RecordType SRV -ResourceGroupName "MyResourceGroup" -TTL 3600 -ZoneName "myzone.com" -PrivateDnsRecords $Records

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.

Example 7: Create a RecordSet of type TXT

$Records = @()
$Records += New-AzPrivateDnsRecordConfig -Value "This is a TXT Record"
$RecordSet = New-AzPrivateDnsRecordSet -Name "text" -RecordType TXT -ResourceGroupName "MyResourceGroup" -TTL 3600 -ZoneName "myzone.com" -PrivateDnsRecords $Records

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.

Example 8: Create a RecordSet at the zone apex

$Records = @()
$Records += New-AzPrivateDnsRecordConfig -Ipv4Address 1.2.3.4
$RecordSet = New-AzPrivateDnsRecordSet -Name "@" -RecordType A -ResourceGroupName "MyResourceGroup" -TTL 3600 -ZoneName "myzone.com" -PrivateDnsRecords $Records

Id                : /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Micros
                    oft.Network/privateDnsZones/myzone.com/A/@
Name              : @
ZoneName          : myzone.com
ResourceGroupName : MyResourceGroup
Ttl               : 3600
Etag              : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
RecordType        : A
Records           : {1.2.3.4}
Metadata          :
IsAutoRegistered  :

This command creates a RecordSet at the apex (or root) of the private zone myzone.com. To do this, the record set name is specified as "@" (including the double-quotes). You cannot create CNAME records at the apex of a zone. This is a constraint of the DNS standards; it is not a limitation of Azure Private DNS. To create a RecordSet using only one line of pn_PowerShell_short, or to create a record set with multiple records, see Example 1.

Example 9: Create a wildcard Record Set

$Records = @()
$Records += New-AzPrivateDnsRecordConfig -Ipv4Address 1.2.3.4
$RecordSet = New-AzPrivateDnsRecordSet -Name "*" -RecordType A -ResourceGroupName "MyResourceGroup" -TTL 3600 -ZoneName "myzone.com" -PrivateDnsRecords $Records

Id                : /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Micros
                    oft.Network/privateDnsZones/myzone.com/A/@
Name              : *
ZoneName          : myzone.com
ResourceGroupName : MyResourceGroup
Ttl               : 3600
Etag              : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
RecordType        : A
Records           : {1.2.3.4}
Metadata          :
IsAutoRegistered  :

This command creates a RecordSet named * in the private zone myzone.com. This is a wildcard record set. To create a RecordSet using only one line of pn_PowerShell_short, or to create a record set with multiple records, see Example 1.

Example 10: Create an empty Record Set

$RecordSet = New-AzPrivateDnsRecordSet -Name "www" -RecordType A -ResourceGroupName "MyResourceGroup" -TTL 3600 -ZoneName "myzone.com" -PrivateDnsRecords @()

Id                : /subscriptions/xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx/resourceGroups/myresourcegroup/providers/Micros
                    oft.Network/privateDnsZones/myzone.com/A/@
Name              : *
ZoneName          : myzone.com
ResourceGroupName : MyResourceGroup
Ttl               : 3600
Etag              : xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
RecordType        : A
Records           : {}
Metadata          :
IsAutoRegistered  :

This command creates a RecordSet named * in the private zone myzone.com. The record set is of type A and has a TTL of 1 hour (3600 seconds). This is an empty record set, which acts as a placeholder to which you can later add records.

Example 11: Create a record set and suppress all confirmation

$RecordSet = New-AzPrivateDnsRecordSet -Name "www" -RecordType A -ResourceGroupName "MyResourceGroup" -TTL 3600 -ZoneName "myzone.com" -PrivateDnsRecords (New-AzDnsRecordConfig -Ipv4Address 1.2.3.4) -Confirm:$False -Overwrite

This command creates a RecordSet. The Overwrite parameter ensures that this record set overwrites any pre-existing record set with the same name and type (existing records in that record set are lost). The Confirm parameter with a value of $False suppresses the confirmation prompt.

Parameters

-Confirm

Prompts you for confirmation before running the cmdlet.

Type:SwitchParameter
Aliases:cf
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-DefaultProfile

The credentials, account, tenant, and subscription used for communication with Azure.

Type:IAzureContextContainer
Aliases:AzContext, AzureRmContext, AzureCredential
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Metadata

A hash table which represents resource tags.

Type:Hashtable
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Name

The name of the records in this record set (relative to the name of the zone and without a terminating dot).

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Overwrite

Do not fail if the record set already exists.

Type:SwitchParameter
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-ParentResourceId

Private DNS Zone ResourceID.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-PrivateDnsRecord

The private dns records that are part of this record set.

Type:PSPrivateDnsRecordBase[]
Aliases:PrivateDnsRecords
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-RecordType

The type of Private DNS records in this record set.

Type:RecordType
Accepted values:A, AAAA, CNAME, MX, PTR, SOA, SRV, TXT
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-ResourceGroupName

The resource group to which the zone belongs.

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-Ttl

The TTL value of all the records in this record set.

Type:UInt32
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Type:SwitchParameter
Aliases:wi
Position:Named
Default value:None
Required:False
Accept pipeline input:False
Accept wildcard characters:False

-Zone

The PrivateDnsZone object representing the zone in which to create the record set.

Type:PSPrivateDnsZone
Position:Named
Default value:None
Required:True
Accept pipeline input:True
Accept wildcard characters:False

-ZoneName

The zone in which to create the record set (without a terminating dot).

Type:String
Position:Named
Default value:None
Required:True
Accept pipeline input:False
Accept wildcard characters:False

Inputs

PSPrivateDnsZone

String

Outputs

PSPrivateDnsRecordSet