Search code examples
azureazure-bicepazure-front-door

Bicep - Adding to Existing Azure Front Door


I have a Bicep script deployed via Azure pipelines which creates an assortment of resources from scratch. Everything works, but I'm struggling with the frontdoor section. The Bicep script will be deployed to create various different environments (dev/test/preprod), but I'd like to use an existing frontdoor for all of these environments. Is there a way to add FEEs, BEPs and RRs to an existing FD? The documentation I've seen only sems to cover creating a new FD from scratch.

The code I'm using is:

resource frontDoor 'Microsoft.Network/frontDoors@2020-05-01'  = {
  name: frontdoorName
  location: 'global'
  properties:{
    enabledState: 'Enabled'
    frontendEndpoints: appFEs
    loadBalancingSettings: [
      ...
    ]

    healthProbeSettings: [
      ...
    ]

    backendPools: [
      {
        name: 'app-bep'
        ...
      }
    ]
    
    routingRules: [
      {
        name: 'app-rr'
        ...
      }
      {
        name: 'http-redirect-rr'
        ...
      }
    ]
  }
}

If I change the first line to use existing, the only thing I can specify is the name. Ideally I'd like to do a create if not exists for these setting on my pre-existing FD. If the ARM template is deployed again, I'd like to just ignore the FEEs, BEPs and RRs.


Solution

  • The "classic" Front Door is defined as one big resource. The only way to manage that via an ARM/Bicep template is to write the template to match exactly your existing resource. Then you can modify, for instance, the routing rules. But you cannot add some things while not specifying the entire resource.

    You should consider migrating to the Front Door Standard/Premium SKU, which has a totally new ARM definition which is more granular with child resources etc, which makes it easier to manage through ARM templates.