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

快速入门:使用 Nginx 设计容器化网络函数 (CNF) 网络服务设计

本快速入门介绍如何使用 az aosm Azure CLI 扩展创建和发布基本网络服务设计。

先决条件

创建输入文件

创建用于发布网络服务设计版本和关联资源的输入文件。 执行以下命令,以生成网络服务设计版本 (NSDV) 的输入配置文件。

az aosm nsd generate-config

执行上述命令会生成 nsd-input.jsonc 文件。

注意

编辑 input.json 文件。 将其替换为以下示例中所示的值。 将文件另存为input-cnf-nsd.jsonc

如果在发布 NFDV 时更改了发布者的名称,请将发布者名称用于 publisher_namepublisher 字段(后者位于 resource_element_templates 数组中)。

如果使用了不同的资源组名称,请更新 publisher_resource_group_namepublisher_resource_group 字段(后者位于 resource_element_templates 数组中)。

下面是一个示例input-cnf-nsd.jsonc

{
  // Azure location to use when creating resources e.g uksouth
  "location": "uksouth",
  // Name of the Publisher resource you want your definition published to.
  // Will be created if it does not exist.
  "publisher_name": "nginx-publisher",
  // Resource group for the Publisher resource.
  // Will be created if it does not exist.
  "publisher_resource_group_name": "nginx-publisher-rg",
  // Name of the ACR Artifact Store resource.
  // Will be created if it does not exist.
  "acr_artifact_store_name": "nginx-nsd-acr",
  // Network Service Design (NSD) name. This is the collection of Network Service Design Versions. Will be created if it does not exist.
  "nsd_name": "nginx-nsdg",
  // 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": "Deploys a basic NGINX CNF",
  // 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": "nginx-publisher",
        // The resource group that the publisher is hosted in.
        "publisher_resource_group": "nginx-publisher-rg",
        // 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": "nginx",
        // 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": "uksouth",
        // Type of Network Function. Valid values are 'cnf' or 'vnf'.
        "type": "cnf"
      }
    }
  ]
}
  • publisher_name - 要将定义发布到的发布服务器资源的名称。 如果它尚不存在,则已创建。
  • publisher_resource_group_name - 发布服务器资源的资源组。 如果它尚不存在,则已创建。 对于本快速入门,建议使用发布网络函数定义时使用的同一资源组。
  • acr_artifact_store_name - ACR 项目存储资源的名称。 如果它尚不存在,则已创建。
  • location - 创建资源时要使用的 Azure 位置。
  • nsd_name - 网络服务设计组名称。 网络服务设计版本的集合。 如果它尚不存在,则已创建。
  • nsd_version - 要创建的 NSD 版本。 采用 A.B.C. 格式。
  • nsdv_description - NSDV 的说明。
  • resource_element_templates
    • publisher - 以其名义发布此 NFDV 的发布者的名称。
    • publisher_resource_group - 托管发布者的资源组。
    • name - 要使用此 NSD 进行部署的现有网络函数定义组的名称。 如果使用 CLI 发布了 NFDV,则这将与 NF 名称相同。
    • version - 要基于此 NSD 的现有网络函数定义的版本。 此 NSD 能够部署带有与此版本兼容的部署参数的任何 NFDV。
    • publisher_offering_location - NFDV 发布到的区域。
    • type - 网络函数的类型。 有效值为 cnf 或 vnf。

生成网络服务设计版本 (NSDV)

使用以下命令启动 NSDV 的生成过程:

az aosm nsd build -f input-cnf-nsd.jsonc

生成过程生成名为nsd-cli-output的文件夹。 生成过程完成后,请查看生成的文件,以深入了解 NSDV 体系结构和结构以及关联的资源。

将会创建以下文件:

目录/文件 说明
nsdDefinition/config-group-schema.json 定义从此 NSDV 创建站点网络服务 (SNS) 所需的部署参数的架构。
nsdDefinition/nginx-nsd-mappings.json 将 NSDV 的参数映射到 NF ARM 模板所需的值。
nsdDefinition/deploy.bicep 用于创建 NSDV 本身的 bicep 模板。
项目 包含 NF ARM 模板的 bicep 模板,以及项目清单中要包含的项目列表。
artifactManifest/deploy.bicep 用于创建项目清单的 bicep 模板。
base/deploy.bicep 用于创建发布者、网络服务设计组和项目存储资源的 bicep 模板

发布网络服务设计版本 (NSDV)

要发布 NSDV 及其关联的项目,请发出以下命令:

az aosm nsd publish --build-output-folder nsd-cli-output

发布过程完成后,导航到发布服务器资源组,以观察并查看生成的资源和项目。

后续步骤