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

快速入门:完成在 Azure 运营商服务管理器中部署虚拟化网络功能的先决条件

在开始使用 Azure 运营商服务管理器之前,请确保已注册所需的资源提供程序并已安装与服务交互所需的工具。

先决条件

请联系 Microsoft 帐户团队,注册 Azure 订阅以访问 Azure 运营商服务管理器 (AOSM),或者通过合作伙伴注册表单表达你的兴趣。

下载并安装 Azure CLI

可以在 Azure Cloud Shell 中使用 Bash 环境。 有关详细信息,请参阅 Azure Cloud Shell 中的 Bash 快速入门

如果要在本地运行 CLI 引用命令,请使用如何安装 Azure CLI安装 Azure CLI。

如果计算机在 Windows 或 macOS 上运行,请考虑在 Docker 容器中运行 Azure CLI。 有关详细信息,请参阅如何在 Docker 容器中运行 Azure CLI

对于本地安装,请使用az login命令登录到 Azure CLI。

若要完成身份验证过程,请遵循终端中显示的步骤。 有关其他登录选项,请参阅使用 Azure CLI 登录

使用 Azure CLI 登录

要使用 Azure CLI 登录,请发出以下命令。

az login

选择订阅

要使用订阅 ID 更改活动订阅,请发出以下命令。

az account set --subscription "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"

安装 Azure 运营商服务管理器 (AOSM) CLI 扩展

要安装 Azure 运营商服务管理器 CLI 扩展,请发出以下命令。

az extension add --name aosm

运行az version以确定已安装的版本和依赖库。 发出命令az upgrade以升级到最新版本。

注册所需的资源提供程序

在使用 Azure 运营商服务管理器之前,必须先执行这些命令以注册所需的资源提供程序。 注册过程最长可能需要 5 分钟。

# Register Resource Provider
az provider register --namespace Microsoft.HybridNetwork
az provider register --namespace Microsoft.ContainerRegistry
az provider register --namespace Microsoft.ContainerInstance

验证注册状态

要验证资源提供程序的注册状态,可以运行以下命令:

# Query the Resource Provider
az provider show -n Microsoft.HybridNetwork --query "{RegistrationState: registrationState, ProviderName: namespace}"
az provider show -n Microsoft.ContainerRegistry --query "{RegistrationState: registrationState, ProviderName: namespace}"
az provider show -n Microsoft.ContainerInstance --query "{RegistrationState: registrationState, ProviderName: namespace}"

成功后,会显示以下输出:

{
  "ProviderName": "Microsoft.HybridNetwork",
  "RegistrationState": "Registered"
}
{
  "ProviderName": "Microsoft.ContainerRegistry",
  "RegistrationState": "Registered"
}
{
  "ProviderName": "Microsoft.ContainerInstance",
  "RegistrationState": "Registered"
}

注意

资源提供程序注册可能需要几分钟才能完成。 注册成功后,可以开始使用网络功能管理器 (NFM) 或 Azure 运营商服务管理器。

虚拟化网络功能 (VNF) 要求

下载并提取 Ubuntu 映像

如果已拥有可通过 Azure Blob 存储中的 SAS URL 访问的 Ubuntu 映像,可以省略此步骤以节省时间。 请记住,Ubuntu 映像很大,约为 650 MB,因此传输过程可能需要一段时间。

# Download the Ubuntu image
wget https://cloud-images.ubuntu.com/jammy/current/jammy-server-cloudimg-amd64-azure.vhd.tar.gz

# Extract the downloaded image
tar -xzvf jammy-server-cloudimg-amd64-azure.vhd.tar.gz

虚拟机 (VM) ARM 模板

本快速入门使用适用于 Ubuntu 虚拟机 (VM) 的以下示例 ARM 模板。

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "metadata": {
    "_generator": {
      "name": "bicep",
      "version": "0.21.1.54444",
      "templateHash": "2626436546580286549"
    }
  },
  "parameters": {
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]"
    },
    "subnetName": {
      "type": "string"
    },
    "ubuntuVmName": {
      "type": "string",
      "defaultValue": "ubuntu-vm"
    },
    "virtualNetworkId": {
      "type": "string"
    },
    "sshPublicKeyAdmin": {
      "type": "string"
    },
    "imageName": {
      "type": "string"
    }
  },
  "variables": {
    "imageResourceGroup": "[resourceGroup().name]",
    "subscriptionId": "[subscription().subscriptionId]",
    "vmSizeSku": "Standard_D2s_v3"
  },
  "resources": [
    {
      "type": "Microsoft.Network/networkInterfaces",
      "apiVersion": "2021-05-01",
      "name": "[format('{0}_nic', parameters('ubuntuVmName'))]",
      "location": "[parameters('location')]",
      "properties": {
        "ipConfigurations": [
          {
            "name": "ipconfig1",
            "properties": {
              "subnet": {
                "id": "[format('{0}/subnets/{1}', parameters('virtualNetworkId'), parameters('subnetName'))]"
              },
              "primary": true,
              "privateIPAddressVersion": "IPv4"
            }
          }
        ]
      }
    },
    {
      "type": "Microsoft.Compute/virtualMachines",
      "apiVersion": "2021-07-01",
      "name": "[parameters('ubuntuVmName')]",
      "location": "[parameters('location')]",
      "properties": {
        "hardwareProfile": {
          "vmSize": "[variables('vmSizeSku')]"
        },
        "storageProfile": {
          "imageReference": {
            "id": "[extensionResourceId(format('/subscriptions/{0}/resourceGroups/{1}', variables('subscriptionId'), variables('imageResourceGroup')), 'Microsoft.Compute/images', parameters('imageName'))]"
          },
          "osDisk": {
            "osType": "Linux",
            "name": "[format('{0}_disk', parameters('ubuntuVmName'))]",
            "createOption": "FromImage",
            "caching": "ReadWrite",
            "writeAcceleratorEnabled": false,
            "managedDisk": "[json('{\"storageAccountType\": \"Premium_LRS\"}')]",
            "deleteOption": "Delete",
            "diskSizeGB": 30
          }
        },
        "osProfile": {
          "computerName": "[parameters('ubuntuVmName')]",
          "adminUsername": "azureuser",
          "linuxConfiguration": {
            "disablePasswordAuthentication": true,
            "ssh": {
              "publicKeys": [
                {
                  "path": "/home/azureuser/.ssh/authorized_keys",
                  "keyData": "[parameters('sshPublicKeyAdmin')]"
                }
              ]
            },
            "provisionVMAgent": true,
            "patchSettings": {
              "patchMode": "ImageDefault",
              "assessmentMode": "ImageDefault"
            }
          },
          "secrets": [],
          "allowExtensionOperations": true
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "[resourceId('Microsoft.Network/networkInterfaces', format('{0}_nic', parameters('ubuntuVmName')))]"
            }
          ]
        }
      },
      "dependsOn": [
        "[resourceId('Microsoft.Network/networkInterfaces', format('{0}_nic', parameters('ubuntuVmName')))]"
      ]
    }
  ]
}

将上述 json 文件另存为本地计算机上的ubuntu-template.json

后续步骤