Azure Front Door supports rules engines however because the rules engine must reference an existing Front Door instance and the rules engine can only be connected to frontend endpoints on Azure Front Door, if the rules engine already exists, thus a circular reference appears.

A workaround is to deploy the Front Door instance twice, when deploying the first time. With ARM templates and Azure Pipelines, the following can be used:


- task: AzureCLI@2
  displayName: Azure CLI
  inputs:
    azureSubscription: <Name of the Azure Resource Manager service connection>
    scriptType: pscore
    scriptLocation: inlineScript
    inlineScript: |
      Set-StrictMode -Version Latest

      $ErrorActionPreference = "Stop"

      $RulesEngines = az network front-door rules-engine list --resource-group $(RESOURCE_GROUP_NAME) --front-door-name $(FRONTDOOR_NAME) | ConvertFrom-Json
      if ($RulesEngines) {
          Write-Host "##vso[task.setvariable variable=FRONTDOOR_RULES_ENGINE_EXISTS;]true"
      }
      else {
          Write-Host "##vso[task.setvariable variable=FRONTDOOR_RULES_ENGINE_EXISTS;]false"
      }

- task: AzureResourceGroupDeployment@2
  displayName: Deploy Azure Front Door
  inputs:
    azureSubscription: 
    action: 'Create Or Update Resource Group'
    resourceGroupName: $(RESOURCE_GROUP_NAME)
    location: $(RESOURCE_GROUP_LOCATION)
    #templateLocation: 'Linked artifact' # Options: linked Artifact, uRL Of The File
    #csmFileLink: # Required when templateLocation == URL Of The File
    #csmParametersFileLink: # Optional
    #csmFile: # Required when  TemplateLocation == Linked Artifact
    #csmParametersFile: # Optional
    #overrideParameters: # Optional
    deploymentMode: 'Incremental'

- task: AzureResourceGroupDeployment@2
  displayName: Link Front Door endpoints to rules engine
  # succeeded() must be a part of the condition, otherwise Azure Pipelines will run this task even if a previous task failed, if FRONTDOOR_RULES_ENGINE_EXISTS is set to true
  condition: and( succeeded(), eq( variables.FRONTDOOR_RULES_ENGINE_EXISTS, 'false' ) )
  inputs:
    azureSubscription: 
    action: 'Create Or Update Resource Group'
    resourceGroupName: $(RESOURCE_GROUP_NAME)
    location: $(RESOURCE_GROUP_LOCATION)
    #templateLocation: 'Linked artifact' # Options: linked Artifact, uRL Of The File
    #csmFileLink: # Required when templateLocation == URL Of The File
    #csmParametersFileLink: # Optional
    #csmFile: # Required when  TemplateLocation == Linked Artifact
    #csmParametersFile: # Optional
    #overrideParameters: # Optional
    deploymentMode: 'Incremental'

Categories:

Tags:

No responses yet

Skriv et svar

Din e-mailadresse vil ikke blive publiceret. Krævede felter er markeret med *