在本作指南中,網路函式發行者和服務設計師會瞭解如何使用 Azure CLI AOSM 擴充功能將虛擬化網路函式部署至 AOSM。 此 VNF 後續可以在 Azure Operator Nexus 上部署。 入職是個多步驟的過程。 一旦符合必要條件,您將使用 Azure CLI AOSM 擴充功能來:
- 產生 Bicep 檔案,以定義網路函式定義群組和版本 (NFD)。
- 發佈 NFD 並將 VNF 映像檔上傳到成品存放區(由 AOSM 管理的 Azure Container Registry (ACR))。
- 將已發佈的 NFD 新增至 Bicep 檔案,以定義網路服務設計群組和版本 (NSD)。
- 發佈 NSD。
先決條件
- 您已存取 Azure 操作員 Nexus 實例,並已完成 工作負載部署的必要條件。
- 您已在您的 Azure 訂用帳戶上啟用 AOSM。
備註
強烈建議您在將 VNF 上線至 AOSM 之前,先確認 VM 部署在 Azure Operator Nexus 實例上已成功。
Azure Operator Nexus 虛擬機(VM)映像和 Azure Resource Manager(ARM)範本
您已 建立 Azure 作員 Nexus 虛擬機的映像。 此映像必須可在 ACR 中使用。
VM ARM 範本(適用於 AzureCore 和 Operator Nexus)只能從下列資源提供者部署 ARM 資源
- Microsoft.Compute
- Microsoft.Network
- Microsoft.NetworkCloud
- Microsoft 儲存服務
- Microsoft.NetworkFabric
- Microsoft.Authorization
- Microsoft.ManagedIdentity
VNF ARM 範本應該部署一個 VM。 您可以藉由在 NSDV 中包含多個 NFDV 實例來部署多個 VM。
設定許可權
- 您需要在您的訂用帳戶中擁有參與者角色,才能建立新的資源群組;或者,您需要在現有資源群組中擁有參與者角色。
- 您需要來源
Reader/AcrPullACR 上包含映像的角色指派。 - 您需要在包含 AOSM 受控成品存放區的訂閱上具有
Contributor和AcrPush角色指派。 這些許可權可讓 Azure CLI AOSM 擴充功能執行直接 ACR 對 ACR 複製。 直接複製是將影像從一個 ACR 傳輸到另一個 ACR 的最快速方法。- 您的公司政策可能會限制您擁有訂用帳戶範圍的權限。
--no-subscription-permissions參數可用於az aosm nfd publish和az aosm nsd publish命令,使用衍生自 AOSM 服務的嚴格範圍許可權,協調從本機計算機的雙向複製的兩步驟過程。 此雙步驟複製速度較慢,但不需要訂用帳戶範圍許可權。
- 您的公司政策可能會限制您擁有訂用帳戶範圍的權限。
下載並安裝 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 環境。
Helm 和 Docker 引擎
安裝 AOSM CLI 擴充功能
Az CLI AOSM 擴充功能需要 Azure CLI 2.54.0 版或更新版本。
- 執行
az version以查看所安裝的版本和相依程式庫。 - 執行
az upgrade以升級至 Azure CLI 的目前版本。
使用此指令安裝 AOSM CLI 擴充功能:
az extension add --name aosm
建置網路函式定義群組和版本
本節會在工作目錄中建立一個名為 vnf-cli-output 的資料夾,該資料夾包含用來定義您的網路功能定義群組和版本的 AOSM 資源 Bicep 檔案,以及 Artifact Store。 這些資源最終會包含在您的網路服務設計中
產生 VNF 的 Azure CLI AOSM 擴充功能輸入檔。
az aosm nfd generate-config --definition-type vnf-nexus --output-file <filename.jsonc>開啟您在上一個步驟中產生的輸入檔,並使用內嵌批注來輸入必要的值。 此範例示範用於虛構的 Contoso VNF 的 Az CLI AOSM 擴充套件輸入檔,該 VNF 在 Azure 營運商 Nexus 上執行。
備註
根據預設,Azure CLI AOSM 擴充功能只會公開輸入 ARM 範本中沒有預設值的必要參數。 您可以設定
expose_all_parameters為true,以公開網路函式定義版本 (NFDV) 和組態群組架構 (CGS) 中的所有 ARM 樣本參數。 如需更詳細的資訊,請參閱使用 AOSM CLI 擴充功能公開參數。{ // 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-vnf", // Name of the ACR Artifact Store resource. // Will be created if it does not exist. "acr_artifact_store_name": "contoso-vnf-artifact-store", // Name of the network function. "nf_name": "contoso-vnf", // Version of the network function definition in 1.1.1 format (three integers separated by dots). "version": "1.0.0", // If set to true, all NFD configuration parameters are made available to the designer, including optional parameters and those with defaults. // If not set or set to false, only required parameters without defaults will be exposed. "expose_all_parameters": false, // ARM template configuration. The ARM templates given here would deploy a VM if run. They will be used to generate the VNF. "arm_templates": [ { // Name of the artifact. Used as internal reference only. "artifact_name": "contoso-vnf", // 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": "/home/contoso-vnf/contoso-vnf-arm-template.json" } ], // List of images to be pulled from the acr registry. // You must provide the source acr registry, the image name and the version. // For example: 'sourceacr.azurecr.io/imagename:imageversion'. "images": ["contoso-vnf.azurecr.io/contosovnf:1.0.0"] }```執行下列命令來建置網路函式定義群組和版本。
az aosm nfd build --definition-type vnf-nexus --config-file <filename.jsonc>
發佈網路函式定義群組和版本
此步驟會建立 AOSM 資源,以定義網路函式定義,以及將用來儲存網路函式 VM 映射的成品存放區。 它還會將映像上傳到 Artifact 存儲庫,可以直接從來源 ACR 複製,或者在您沒有訂閱範圍 Contributor 和 AcrPush 角色的情況下,本地重新標記 Docker 映像並使用 AOSM 服務產生的範圍嚴格的憑證上傳至 Artifact 存儲庫。
- 執行下列命令以發佈網路函式定義群組和版本。 如果您沒有訂用帳戶範圍
Contributor和AcrPush角色,請在命令中包含--no-subscription-permissions。
az aosm nfd publish --build-output-folder vnf-cli-output --definition-type vnf
您可以檢視資料夾和檔案結構,並視需要進行修改。
建置網路服務設計群組和版本
本節會在名為 nsd-cli-output的工作目錄中建立資料夾。 此資料夾包含定義網路服務設計群組和版本之 AOSM 資源的 Bicep 檔案。 此網路服務設計是網站網路服務資源中使用的範本,會部署您在上一節中上線的網路功能。
產生 Azure CLI AOSM 擴充功能 NSD 輸入檔。
az aosm nsd generate-config --output-file <nsd-output-filename.jsonc>開啟您在上一個步驟中產生的輸入檔,並使用內嵌批注來輸入必要的值。 產生的輸入檔包含另外一個
resource_element_type類型為ArmTemplate。 在部署 VNF 時,這是沒有必要的;您可以將其刪除。 此範例示範虛構 Contoso NSD 的 Az CLI AOSM 擴充功能輸入檔案,可用來將虛構的 Contoso VNF 部署到 Azure Operator Nexus 實例。{ // 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-vnf", // Name of the ACR Artifact Store resource. // Will be created if it does not exist. "acr_artifact_store_name": "contoso-vnf-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-vnf-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-vnf NFD", // 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-vnf", // 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-vnf", // 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": "vnf" } } ] }備註
資源元素範本區段會定義NSD中包含哪些NFD。 屬性必須符合傳遞至
az aosm nfd build命令之輸入檔中使用的屬性。 這是因為 Azure CLI AOSM 擴充功能會驗證建置 NSD 時,NFD 是否已正確上線。執行下列命令來建置網路服務設計群組和版本 Bicep 檔案。
az aosm nsd build --config-file <nsd-output-filename.jsonc>
您可以檢視資料夾和檔案結構,並視需要進行修改。
發佈網路服務設計 (NSD)
此步驟會建立 AOSM 資源,以定義網路服務設計群組和版本。 它也會將 NSD 所需的工件上傳至工件存放區(網路功能 ARM 模板)。
- 執行下列命令以發佈網路服務設計群組和版本。 如果您沒有訂用帳戶範圍
Contributor和AcrPush角色,請在命令中包含--no-subscription-permissions。
az aosm nsd publish --build-output-folder nsd-cli-output
您已具備一組完整的 AOSM 發行者資源,並準備好執行操作流程。