你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
Azure作员服务管理器(AOSM)允许将网络函数定义版本 (NFDV) 和 Azure 资源管理器 (ARM) 模板合并到网络服务设计版本 (NSDV) 中。 NSDV 成为包含网络函数和运行所需的 Azure 基础结构的网络服务的单个模板。 然后,作员可以在一个作中部署网络函数(NF)及其基础结构。
本作指南介绍如何使用 Azure CLI AOSM 扩展生成和发布包含容器化网络函数(CNF)Azure 资源管理器(ARM)资源的 NSDV。
载入是一个多步骤过程。 满足先决条件后,您将使用 Azure CLI 的 AOSM 扩展来执行以下操作:
- 修改先前加入的 CNF 的现有 NSDV 输入文件。
- 将生成 AOSM 资源定义所需的信息填写到输入文件中。
- 根据输入文件和 ARM 模板生成定义网络服务设计组和版本(NSDV)的 Bicep 文件。
- 发布 NSDV 并将 ARM 模板上传到制品存储库(由 AOSM 管理的 Azure 容器注册表(ACR))。
本作指南使用 Azure Key Vault(AKV)作为 Azure 资源的示例,但是,可以按照相同的步骤载入任何 Azure 资源。 本文使用 CNF 作为示例 NF;除了 NSDV 输入文件中的细微差异外,虚拟化网络函数(VNF)的过程是相同的。
先决条件
- 已在 Azure 订阅上启用了 AOSM。
- 如果计划在 Azure Operator Nexus 上运行 CNF,那么您可以访问 Azure Operator Nexus 实例,并已完成 工作负载部署的先决条件。
- 已加入 CNF,并在执行 CLI 的机器本地存储中提供了与
az aosm nsd generate-config
文件一起生成的输入文件。
配置权限
- 需要在订阅中使用参与者角色才能创建资源组,或创建具有参与者角色的现有资源组。
- 对于包含 AOSM 管理的项目存储的订阅,需获配
Contributor
和AcrPush
角色。- 公司策略可能会阻止你拥有订阅范围的权限。
--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 环境。 有关详细信息,请参阅启动 Cloud Shell 以在 Azure Cloud Shell 中使用 Bash 环境。
安装 AOSM CLI 扩展
Az CLI AOSM 扩展需要 Azure CLI 2.54.0 或更高版本。
- 运行
az version
以查看安装的版本和依赖库。 - 运行
az upgrade
以升级到 Azure CLI 的当前版本。
使用以下命令安装 AOSM CLI 扩展:
az extension add --name aosm
生成网络服务设计组和版本
打开载入 CNF 时生成的 NSDV 输入文件。
注释
如果没有 CNF 载入中的 NSDV 输入文件,则可以使用
az aosm nsd generate-config --output-file <nsd-output-filename.jsonc>
此命令生成新的输入文件。使用输入文件中的内联注释输入所需的值。 此示例演示虚构 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" } } ] }
注释
资源元素模板部分用于定义哪些 NFD 被包含在 NSD 中。 属性必须与传递给
az aosm nfd build
命令的输入文件中所使用的属性匹配。 这是因为 Azure CLI AOSM 扩展在生成 NSD 时会验证 NFD 是否已正确集成。执行以下命令以生成网络服务设计组和版本 Bicep 文件。
az aosm nsd build --config-file <nsd-output-filename.jsonc>
可以查看文件夹和文件结构,并在必要时进行修改。
发布网络服务设计组和版本
此步骤创建定义网络服务设计组和版本的 AOSM 资源。 它还会将 NSDV 所需的项目上传到项目存储(NF ARM 模板和 AKV ARM 模板)。
- 执行以下命令以发布网络服务设计组和版本。 如果您没有订阅范围
Contributor
和AcrPush
角色,请在命令中包含--no-subscription-permissions
。
az aosm nsd publish --build-output-folder nsd-cli-output
现在,你已拥有一套完整的 AOSM 发布者资源,并已准备好执行操作流程。