你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

将 Azure 资源管理器 (ARM) 资源添加到 Azure 运营商服务管理器 (AOSM) 网络服务设计版本 (NSDV)

Azure 运营商服务管理器 (AOSM) 允许将网络功能定义版本 (NFDV) 和 Azure 资源管理器 (ARM) 模板组合到网络服务设计版本 (NSDV) 中。 NSDV 成为网络服务的单一模板,该网络服务包含运行所需的网络功能和 Azure 基础结构。 然后,运营商可以在一次操作中部署网络功能 (NF) 及其基础结构。

本操作指南将介绍如何使用 Azure CLI AOSM 扩展来构建和发布包含容器化网络功能 (CNF) 和 Azure 资源管理器 (ARM) 资源的 NSDV。

加入是多步骤的进程。 满足先决条件后,将使用 Azure CLI AOSM 扩展来:

  1. 修改先前加入的 CNF 的现有 NSDV 输入文件。
  2. 使用构建 AOSM 资源定义所需的信息填充输入文件。
  3. 根据输入文件和 ARM 模板生成定义网络服务设计组和版本 (NSDV) 的 BICEP 文件。
  4. 发布 NSDV 并将 ARM 模板上载到项目存储(AOSM 管理的 Azure 容器注册表 (ACR))。

本操作指南使用 Azure Key Vault (AKV) 作为 Azure 资源的示例,但是,可以按照相同的步骤加入任何 Azure 资源。 本文使用 CNF 作为示例 NF;除了 NSDV 输入文件中的微小差异之外,进程对于虚拟化网络功能 (VNF) 是相同的。

先决条件

  • 已在 Azure 订阅上启用了 AOSM
  • 如果 CNF 计划在 Azure 运营商关系上运行,则可以访问 Azure 运营商关系实例,并已完成工作负载部署的先决条件
  • 已加入 CNF,并在执行 CLI 的机器本地存储中提供了与 az aosm nsd generate-config 文件一起生成的输入文件。

配置权限

  • 需要在订阅中使用参与者角色才能创建资源组,或创建具有参与者角色的现有资源组。
  • 需要在将包含 AOSM 管理的项目存储的订阅上分配 ContributorAcrPush 角色。
    • 贵公司策略可能会阻止拥有订阅范围的权限。 az aosm nsd publish 命令中提供的 --no-subscription-permissions 参数使用从 AOSM 服务派生的严格范围权限来协调往返于本地计算机的两步复制。 此两步复制速度较慢,但不需要订阅范围的权限。

ARM 模板

  • 必须在执行 CLI 的计算机本地存储上具有定义要部署的 Azure 资源的 ARM 模板。
  • 要向将部署 NSDV 的运营商公开的任何参数都必须定义为 ARM 模板中的参数。

注意

Az CLI AOSM 扩展不支持 BICEP 模板中定义的 Azure 资源登录。 但是,可以使用 bicep build 命令将 BICEP 文件转换为 ARM 模板。 有关详细信息和说明,请参阅 bicep CLI 文档

Helm 和 Docker 引擎

  • 在主机上安装 Helm CLI。 必须使用 Helm v3.8.0 或更高版本。
  • 在主机上安装 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 环境。 有关详细信息,请参阅启动 Cloud Shell 以在 Azure Cloud Shell 中使用 Bash 环境。

安装 AOSM CLI 扩展

Az CLI AOSM 扩展需要 2.54.0 或更高版本的 Azure CLI。

  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. 执行以下命令以发布网络服务设计组和版本。 如果没有订阅范围 Contributor 和角色 AcrPush,请在命令中包含 --no-subscription-permissions
az aosm nsd publish --build-output-folder nsd-cli-output

现已拥有一整套 AOSM 发布者资源,可以执行运营商流了。

后续步骤