Share via

Adding Azure Cname using Bicep code: Getting error of "ParentResourceNotFound",

kade 11 Reputation points
2022-01-18T17:55:54.92+00:00

// Reside in different RS
resource dnsZone 'Microsoft.Network/dnsZones@2018-05-01' existing = {
name: 'example.com'
}

// creating web resources into different one.
resource sites_TestSpa_name 'Microsoft.Web/sites@2020-12-01' = {
name: sites_TestSpa_name_var
location: resourceGroup().location
kind: 'app'
properties: {
serverFarmId: serverFarmID
siteConfig: {
http20Enabled: true
nodeVersion: '~14'
requestTracingEnabled: true
requestTracingExpirationTime: '12/31/9999 11:59:00 PM'
httpLoggingEnabled: true
detailedErrorLoggingEnabled: true
publishingUsername: '$TestSpa-${environment}'
appSettings: [
{
name: 'WEBSITE_HTTPLOGGING_RETENTION_DAYS'
value: '3'

    }
    {
      name: 'WEBSITE_NODE_DEFAULT_VERSION'
      value: '~14'

    }
    {
      name: 'WEBSITE_RUN_FROM_PACKAGE'
      value: '1'

    }
  ]
  scmType: 'VSTSRM'
  alwaysOn: false
  virtualApplications: [
    {
      virtualPath: '/'
      physicalPath: 'site\\wwwroot'
      preloadEnabled: false
    }
  ]
  cors: {
    allowedOrigins: [

    ]
    supportCredentials: true
  }
}
httpsOnly: true

}
}

resource sites_TestSpa_name_sites_TestSpa_name_azurewebsites_net 'Microsoft.Web/sites/hostNameBindings@2020-12-01' = {
parent: sites_TestSpa_name
name: '${toLower('${sites_TestSpa_name_var}.azurewebsites.net')}'
properties: {
siteName: sites_TestSpa_name_var
hostNameType: 'Verified'
}
}

resource sites_TestSpa_name_environment_testspa_biberk_com 'Microsoft.Web/sites/hostNameBindings@2020-12-01' = {
parent: sites_TestSpa_name
name: '${toLower('${environment}-testspa.example.com')}'
properties: {
siteName: sites_TestSpa_name_var
hostNameType: 'Verified'
sslState: 'SniEnabled'
thumbprint: certificateName_resource.properties.thumbprint
}
dependsOn: [
sites_TestSpa_name_sites_TestSpa_name_azurewebsites_net
]
}

// adding cname
resource dnsRecord 'Microsoft.Network/dnsZones/CNAME@2018-05-01' = {
parent: dnsZone
name: 'dev-testspa'
properties: {
TTL: 300
CNAMERecord: {
cname: 'TestSpa-dev.azurewebsites.net'
}
}
}

deployment error:

"status": "Failed",
"error": {
"code": "ParentResourceNotFound",
"message": "Can not perform requested operation on nested resource. Parent resource 'example.com' not found."
}

Azure DNS
Azure DNS

An Azure service that enables hosting Domain Name System (DNS) domains in Azure.

0 comments No comments

1 answer

Sort by: Most helpful
  1. suvasara-MSFT 10,166 Reputation points Moderator
    2022-02-01T10:56:13.6+00:00

    @kade , I would like to help you here with truly little expertise on Bicep framework. While delving into Bicep concepts I came across this sample Bicep module that aims towards creating a CNAME in DNS Zone. Please go through this module if you haven't visited yet and do let us know if you are still unable to fix it.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.