0

I'm using arm templates for deployments (preferable bicep). Is there a simple way to add my public ip resource to preexisting DNS zone? Public IP has property named dnsSettings, but it seems that it only can set DNS pointing to azure default domain publicipname.eastus.cloudapp.azure.com, instead of publicipname.customdomain.com.

resource publicIp 'Microsoft.Network/publicIPAddresses@2020-11-01' = {
  location: rg_location
  name: 'pip-example'
  tags: tags_list
  sku: {
    name: 'Standard'
    tier: 'Regional'
  }
  properties:{
    dnsSettings:{
      domainNameLabel: 'publicipname'
      fqdn: 'publicipname.customdomain.com'
    }
    publicIPAllocationMethod: 'Static'
  }
}
kirsie
  • 11
  • 4

1 Answers1

0

You could register the PublicIP resource directly in DNS like:

...
resource dns 'Microsoft.Network/dnsZones@2018-05-01' = {
  name: 'customdomain.com'
  location: 'global'
  properties: {
    zoneType: 'Public'
  }
}

resource dnsEntry 'Microsoft.Network/dnsZones/A@2018-05-01' = {
  name: 'publicipname'
  parent: dns
  properties: {
    TTL: 3600
    targetResource: {
      id: publicIp.id
    }
  }
}

or with the IP address

resource dns 'Microsoft.Network/dnsZones@2018-05-01' = {
  name: 'customdomain.com'
  location: 'global'
  properties: {
    zoneType: 'Public'
  }
}

resource dnsEntry 'Microsoft.Network/dnsZones/A@2018-05-01' = {
  name: 'publicipname'
  parent: dns
  properties: {
    TTL: 3600
    ARecords: [
      {
        ipv4Address: publicIp.properties.ipAddress
      }
    ]
  }
}
Kai Walter
  • 3,485
  • 2
  • 32
  • 62