簡體   English   中英

如何將 Azure Front Door 與 Azure 容器應用程序一起使用?

[英]How to use Azure Front Door with Azure Container Apps?

我計划在我的容器應用程序前面使用 Azure Front Door,並且只允許通過 Front Door 進行訪問。 我已經部署了一個帶有自定義 virtual.network 的內部容器應用程序環境。 我已經使用允許 Azure FrontDoor.Backend 的入站規則向 infra-su.net 添加了一個 NSG。 但這似乎不起作用。

關於如何將 Azure Front Door 與 Azure 容器應用程序一起使用的任何建議?

Azure Front Door 是一種 CDN 服務,可提供高性能、可擴展的應用程序。 它具有用於高級路由功能的可自定義規則引擎,我們可以添加 Azure 容器應用程序 URL / 負載均衡器 IP [[如果它與 NSG 集成允許入站中的相應端口]。 下面的示例示例有助於將容器應用程序部署到 Front Door 中。

  1. 創建和瀏覽容器應用程序 URL,無論它是否在沒有前門的情況下啟動並運行,或者通過容器應用程序 URL / Load Balancer 的方式。在此處輸入圖像描述

  2. 在容器應用程序上配置前門在此處輸入圖像描述注意:如果我們使用 Container App URL,Origin 類型將是自定義的。

  3. 單擊 Origin 組,然后驗證它是否指向正確的 Endpoint? 在此處輸入圖像描述在此處輸入圖像描述

  4. 從 Front Door Service 復制 Front Door URL在此處輸入圖像描述

Output在此處輸入圖像描述

要使用私有 ACA(Azure 容器應用程序)環境部署 AFD(Azure Front Door),您需要在 Front Door 和 ACA 創建的內部 Azure 負載均衡器之間創建私有鏈接連接。

因此,您必須為負載均衡器創建專用鏈接服務。 現在的挑戰是“找到”應為其創建專用鏈接服務的負載均衡器,並將負載均衡器的 ID 添加到專用鏈接服務資源(如果以編程方式完成)。

在我的示例中,我使用了環境的默認域來創建“自動生成”資源組的名稱,因為您需要提供負載均衡器的名稱和資源組才能獲得所需的 ID。

二頭肌示例代碼:

// Create Container Apps Environment
resource environment 'Microsoft.App/managedEnvironments@2022-03-01' = {
  name: environmentName
  location: location
  
  ...
  
}

// Get the Default Domain of the ACA environment
var containerAppsEnvironmentDefaultDomain string = environment.properties.defaultDomain

// Split the domain to get the identifier of the ACA environment (the element before the location)
var containerAppsNameIdentifier = split(containerAppsDefaultDomainName, '.')[lastIndexOf(containerAppsDefaultDomainArray, location)-1]

// Use the identifier to 'generate' the resource group name
var containerAppsManagedResourceGroup = 'MC_${containerAppsNameIdentifier}-rg_${containerAppsNameIdentifier}_${location}'

// Get the ID of the Load Balancer
resource loadBalancer 'Microsoft.Network/loadBalancers@2021-05-01' existing = {
  name: 'kubernetes-internal'
  scope: resourceGroup(containerAppsManagedResourceGroup)
}

包括所有 Bicep 代碼的完整示例可以在 Github 找到: https://github.com/sebafo/frontdoor-container-apps

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM