共用方式為


將 Azure Resource Manager (ARM) 資源新增至 Azure 操作員服務管理員 (AOSM) 網路服務設計版本 (NSDV)

Azure 操作員服務管理員 (AOSM) 可讓您將網路函式定義版本 (NFDV) 和 Azure Resource Manager (ARM) 範本合併為網路服務設計版本 (NSDV)。 NSDV 會成為網路服務的單一範本,其中包含網路函式和它執行所需的 Azure 基礎結構。 操作員接著可以在一個作業中部署網路函式及其基礎結構。

在本操作指南中,您將瞭解如何使用 Azure CLI AOSM 擴充功能來建置和發佈 NSDV,其中包含 Azure Resource Manager (ARM) 資源的容器化網路函式 (CNF) 。

上線是一個多步驟的程式。 一旦符合必要條件,您將使用 Azure CLI AOSM 擴充功能來:

  1. 修改先前上線 CNF 的現有 NSDV 輸入檔。
  2. 將輸入檔填入建置 AOSM 資源定義所需的資訊。
  3. 根據輸入檔案和 ARM 範本,產生 BICEP 檔案,以定義網路服務設計群組和版本 (NSDV)。
  4. 發佈 NSDV 並將 ARM 範本上傳至成品存放區(AOSM 管理的 Azure Container Registry (ACR))。

本操作指南使用 Azure 金鑰保存庫 (AKV) 作為 Azure 資源的範例,不過,您可以遵循相同的步驟來上線任何 Azure 資源。 本文使用 CNF 作為範例 NF;除了 NSDV 輸入檔中的次要差異之外,虛擬化網路函式 (VNF) 的程式相同。

必要條件

  • 您已在 Azure 訂用帳戶上啟用 AOSM
  • 如果您的 CNF 是要在 Azure 操作員 Nexus 上執行,您可以存取 Azure 操作員 Nexus 實例,並已完成 工作負載部署的必要條件。
  • 您已將 CNF 上線,並具有您在執行 CLI 的電腦本機記憶體上可用的檔案所產生的 az aosm nsd generate-config 輸入檔案。

設定權限

  • 您需要訂用帳戶的參與者角色,才能建立資源群組,或具有參與者角色的現有資源群組。
  • 您需要訂 Contributor 用帳戶上的 和 AcrPush 角色指派,其中包含AOSM受控成品存放區。
    • 您的公司原則可能會防止您擁有訂用帳戶範圍的許可權。 在 --no-subscription-permissions 命令上 az aosm nsd publish 提供的 參數會使用衍生自 AOSM 服務的嚴格範圍許可權,來協調本機計算機的雙步驟複本。 此雙步驟複製速度較慢,但不需要訂用帳戶範圍許可權。

ARM 範本

  • 您必須有一個 ARM 範本,其定義您要部署的 Azure 資源,其位於您要執行 CLI 之電腦的本機記憶體上。
  • 您想要向將 NSDV 部署的操作員公開的任何參數,都必須定義為 ARM 範本中的參數。

注意

Az CLI AOSM 擴充功能不支援將 BICEP 範本中定義的 Azure 資源上線。 不過,您可以使用 bicep build 命令將 BICEP 檔案轉換成 ARM 範本。 如需詳細資訊和指示,請參閱 bicep CLI 檔

Helm 和 Docker 引擎

下載並安裝 Azure CLI

若要在本機安裝 Azure CLI,請參閱 如何安裝 Azure CLI

若要登入 Azure CLI,請使用 az login 命令並完成終端機中顯示的提示以完成驗證。 如需更多登入選項,請參閱 使用 Azure CLI 登入。

注意

若您在 Windows 或 macOS 上執行,請考慮在 Docker 容器中執行 Azure CLI。 如需詳細資訊,請參閱〈如何在 Docker 容器中執行 Azure CLI〉。 您也可以在 Azure Cloud Shell 中使用 Bash 環境。 如需詳細資訊,請參閱 在 Azure Cloud Shell 中啟動 Cloud Shell 以使用 Bash 環境。

安裝 AOSM CLI 擴充功能

Az CLI AOSM 擴充功能需要 Azure CLI 2.54.0 版或更新版本。

  1. 執行 az version 以查看已安裝的版本和相依連結庫。
  2. 執行 az upgrade 以升級至目前版本的 Azure CLI。

使用此指令安裝 AOSM CLI 擴充功能:

az extension add --name aosm

建置網路服務設計群組和版本

  1. 開啟您在上線 CNF 時所產生的 NSDV 輸入檔案。

    注意

    如果您沒有來自 CNF 上線的 NSDV 輸入檔 az aosm nsd generate-config --output-file <nsd-output-filename.jsonc> ,您可以使用 命令來產生新的輸入檔。

  2. 使用輸入檔中的內嵌批註輸入必要的值。 此範例顯示虛構 Contoso NSDV 的 Az CLI AOSM 延伸模組輸入檔,可用來將虛構的 Contoso CNF 部署到 Arc 連線的 Nexus Kubernetes 叢集和 Azure 位置中的 AKV 實例。

    {
        // Azure location to use when creating resources e.g uksouth
        "location": "eastus",
        // Name of the Publisher resource you want your definition published to.
        // Will be created if it does not exist.
        "publisher_name": "contoso",
        // Resource group for the Publisher resource.
        // Will be created if it does not exist.
        "publisher_resource_group_name": "contoso",
        // Name of the ACR Artifact Store resource.
        // Will be created if it does not exist.
        "acr_artifact_store_name": "contoso-artifact-store",
        // Network Service Design (NSD) name. This is the collection of Network Service Design Versions. Will be created if it does not exist.
        "nsd_name": "contoso-nsd",
        // Version of the NSD to be created. This should be in the format A.B.C
        "nsd_version": "1.0.0",
        // Optional. Description of the Network Service Design Version (NSDV).
        "nsdv_description": "An NSD that deploys the onboarded contoso-cnf NFD and an Azure Key Vault",
        // List of Resource Element Templates (RETs).
        // There must be at least one NF RET.
        // ArmTemplate RETs are optional. Delete if not required.
        "resource_element_templates": [
            {
                // Type of Resource Element. Either NF or ArmTemplate
                "resource_element_type": "NF",
                "properties": {
                    // The name of the existing publisher for the NSD.
                    "publisher": "contoso",
                    // The resource group that the publisher is hosted in.
                    "publisher_resource_group": "contoso",
                    // The name of the existing Network Function Definition Group to deploy using this NSD.
                    // This will be the same as the NF name if you published your NFDV using the CLI.
                    "name": "contoso-cnf-nfd",
                    // The version of the existing Network Function Definition to base this NSD on.
                    // This NSD will be able to deploy any NFDV with deployment parameters compatible with this version.
                    "version": "1.0.0",
                    // The region that the NFDV is published to.
                    "publisher_offering_location": "eastus",
                    // Type of Network Function. Valid values are 'cnf' or 'vnf'.
                    "type": "cnf"
                }
            },
            {
                // Type of Resource Element. Either NF or ArmTemplate
                "resource_element_type": "ArmTemplate",
                // Properties of the Resource Element.
                "properties": {
                    // Name of the artifact. Used as internal reference only.
                    "artifact_name": "contoso-keyvault",
                    // Version of the artifact in 1.1.1 format (three integers separated by dots).
                    "version": "1.0.0",
                    // File path (absolute or relative to this configuration file) of the artifact you wish to upload from your local disk.
                    // Use Linux slash (/) file separator even if running on Windows.
                    "file_path": "./contoso-keyvault.json"
                }
            }
        ]
    }
    

    注意

    資源元素範本區段會定義NSD中包含哪些NFD。 屬性必須符合傳遞至 az aosm nfd build 命令之輸入檔中使用的屬性。 這是因為 Azure CLI AOSM 擴充功能會驗證建置 NSD 時,NFD 是否已正確上線。

  3. 執行下列命令來建置網路服務設計群組和版本 BICEP 範本。

az aosm nsd build --config-file <nsd-output-filename.jsonc>

您可以檢視資料夾和檔案結構,並視需要進行修改。

發佈網路服務設計群組和版本

此步驟會建立 AOSM 資源,以定義網路服務設計群組和版本。 它也會將 NSDV 所需的成品上傳至成品存放區(NF ARM 範本和 AKV ARM 範本)。

  1. 執行下列命令以發佈網路服務設計群組和版本。 如果您沒有訂用帳戶範圍 ContributorAcrPush 角色, --no-subscription-permissions 請在 命令中包含 。
az aosm nsd publish --build-output-folder nsd-cli-output

您現在有一組完整的 AOSM 發行者資源,並準備好執行操作員流程。

下一步