I am using bicep to configure the site and DNS. Currently, I can configure it when using the subdomain (e.g www.foilen-lab.me) by using a CNANE, but for the main (e.g foilen-lab.me), I cannot use a CNAME and must use the IP. How can I get the IP?
Currently for the "www":
resource siteWww 'Microsoft.Web/sites@2021-03-01' = {
name: 'www-foilen-lab-me'
location: location
kind: 'app,linux,container'
properties: {
serverFarmId: serverFarmsId
reserved: true
httpsOnly: true
siteConfig: {
alwaysOn: true
numberOfWorkers: 1
linuxFxVersion: 'DOCKER|foilen/az-docker-apache_php:7.4.9-3'
}
}
}
resource dnsWww 'Microsoft.Network/dnsZones/CNAME@2018-05-01' = {
parent: dnsZone
name: 'www'
properties: {
TTL: 3600
CNAMERecord: {
cname: '${siteWww.name}.azurewebsites.net'
}
}
}
And I would like to create something like:
resource dns 'Microsoft.Network/dnsZones/A@2018-05-01' = {
parent: dnsZone
name: '@'
properties: {
TTL: 3600
ARecords: [
{
ipv4Address: '${siteWww.xxxxxxxx}'
}
]
}
}
thanks
You should be able to use siteWww.properties.inboundIpAddress
to get the current ipAddress.
As a general rule of thumb you can retrieve any property on a resource in bicep by using it's symbolic name and the JSON path of the GET from the REST api.
So for example, if you go to the portal for any resource and select the JSON View from the overview page... you can see what's possible to return via that syntax. e.g. siteWww.properties.customDomainVerificationId
is also handy.