Επεξεργασία

Κοινή χρήση μέσω


Quickstart: Create an Azure Operator Nexus virtual machine by using Azure CLI

  • Deploy an Azure Nexus virtual machine using Azure CLI

This quick-start guide is designed to help you get started with using Nexus virtual machines to host virtual network functions (VNFs). By following the steps outlined in this guide, you're able to quickly and easily create a customized Nexus virtual machine that meets your specific needs and requirements. Whether you're a beginner or an expert in Nexus networking, this guide is here to help. You learn everything you need to know to create and customize Nexus virtual machines for hosting virtual network functions.

Before you begin

If you don't have an Azure subscription, create an Azure free account before you begin.

  • Install the latest version of the necessary Azure CLI extensions.

  • This article requires version 2.49.0 or later of the Azure CLI. If using Azure Cloud Shell, the latest version is already installed.

  • If you have multiple Azure subscriptions, select the appropriate subscription ID in which the resources should be billed using the az account command.

  • Before proceeding with virtual machine creation, ensure that the container image to be used is created according to the instructions.

  • Create a resource group using the az group create command. An Azure resource group is a logical group in which Azure resources are deployed and managed. When you create a resource group, you're prompted to specify a location. This location is the storage location of your resource group metadata and where your resources run in Azure if you don't specify another region during resource creation. The following example creates a resource group named myResourceGroup in the eastus location.

    az group create --name myResourceGroup --location eastus
    

    The following output example resembles successful creation of the resource group:

    {
      "id": "/subscriptions/<guid>/resourceGroups/myResourceGroup",
      "location": "eastus",
      "managedBy": null,
      "name": "myResourceGroup",
      "properties": {
        "provisioningState": "Succeeded"
      },
      "tags": null
    }
    
  • To deploy a Bicep file or ARM template, you need write access on the resources you're deploying and access to all operations on the Microsoft.Resources/deployments resource type. For example, to deploy a cluster, you need Microsoft.NetworkCloud/virtualMachines/write and Microsoft.Resources/deployments/* permissions. For a list of roles and permissions, see Azure built-in roles.

  • You need the custom location resource ID of your Azure Operator Nexus cluster.

  • You need to create various networks according to your specific workload requirements, and it's essential to have the appropriate IP addresses available for your workloads. To ensure a smooth implementation, it's advisable to consult the relevant support teams for assistance.

  • Complete the prerequisites for deploying a Nexus virtual machine.

Create a Nexus virtual machine

The following example creates a virtual machine named myNexusVirtualMachine in resource group myResourceGroup in the eastus location.

Before you run the commands, you need to set several variables to define the configuration for your virtual machine. Here are the variables you need to set, along with some default values you can use for certain variables:

Variable Description
LOCATION The Azure region where you want to create your virtual machine.
RESOURCE_GROUP The name of the Azure resource group where you want to create the virtual machine.
SUBSCRIPTION The ID of your Azure subscription.
CUSTOM_LOCATION This argument specifies a custom location of the Nexus instance.
CSN_ARM_ID The ARM ID of the cloud services network that the virtual machine will be connected to.
L3_NETWORK_ID The ARM ID of the L3 network that the virtual machine will be connected to.
NETWORK_INTERFACE_NAME The name of the L3 network interface to be assigned.
ADMIN_USERNAME The username for the virtual machine administrator.
SSH_PUBLIC_KEY The SSH public key that is used for secure communication with the virtual machine.
CPU_CORES The number of CPU cores for the virtual machine (even number, max 46 vCPUs)
MEMORY_SIZE The amount of memory (in GiB, max 224 GiB) for the virtual machine.
VM_DISK_SIZE The size (in GiB) of the virtual machine disk.
VM_IMAGE The URL of the virtual machine image.
ACR_URL The URL of the Azure Container Registry.
ACR_USERNAME The username for the Azure Container Registry.
ACR_PASSWORD The password for the Azure Container Registry.

Once you've defined these variables, you can run the Azure CLI command to create the virtual machine. Add the --debug flag at the end to provide more detailed output for troubleshooting purposes.

To define these variables, use the following set commands and replace the example values with your preferred values. You can also use the default values for some of the variables, as shown in the following example:

# Azure parameters
RESOURCE_GROUP="myResourceGroup"
SUBSCRIPTION="<Azure subscription ID>"
CUSTOM_LOCATION="/subscriptions/<subscription_id>/resourceGroups/<managed_resource_group>/providers/microsoft.extendedlocation/customlocations/<custom-location-name>"
LOCATION="$(az group show --name $RESOURCE_GROUP --query location --subscription $SUBSCRIPTION -o tsv)"

# VM parameters
VM_NAME="myNexusVirtualMachine"

# VM credentials
ADMIN_USERNAME="azureuser"
SSH_PUBLIC_KEY="$(cat ~/.ssh/id_rsa.pub)"

# Network parameters
CSN_ARM_ID="/subscriptions/<subscription_id>/resourceGroups/<resource_group>/providers/Microsoft.NetworkCloud/cloudServicesNetworks/<csn-name>"
L3_NETWORK_ID="/subscriptions/<subscription_id>/resourceGroups/<resource_group>/providers/Microsoft.NetworkCloud/l3Networks/<l3Network-name>"
NETWORK_INTERFACE_NAME="mgmt0"

# VM Size parameters
CPU_CORES=4
MEMORY_SIZE=12
VM_DISK_SIZE="64"

# Virtual Machine Image parameters
VM_IMAGE="<VM image, example: myacr.azurecr.io/ubuntu:20.04>"
ACR_URL="<Azure container registry URL, example: myacr.azurecr.io>"
ACR_USERNAME="<Azure container registry username>"
ACR_PASSWORD="<Azure container registry password>"

Important

It is essential that you replace the placeholders for CUSTOM_LOCATION, CSN_ARM_ID, L3_NETWORK_ID and ACR parameters with your actual values before running these commands.

After defining these variables, you can create the virtual machine by executing the following Azure CLI command.

az networkcloud virtualmachine create \
    --name "$VM_NAME" \
    --resource-group "$RESOURCE_GROUP" \
    --subscription "$SUBSCRIPTION" \
    --extended-location name="$CUSTOM_LOCATION" type="CustomLocation" \
    --location "$LOCATION" \
    --admin-username "$ADMIN_USERNAME" \
    --csn "attached-network-id=$CSN_ARM_ID" \
    --cpu-cores $CPU_CORES \
    --memory-size $MEMORY_SIZE \
    --network-attachments '[{"attachedNetworkId":"'$L3_NETWORK_ID'","ipAllocationMethod":"Dynamic","defaultGateway":"True","networkAttachmentName":"'$NETWORK_INTERFACE_NAME'"}]'\
    --storage-profile create-option="Ephemeral" delete-option="Delete" disk-size="$VM_DISK_SIZE" \
    --vm-image "$VM_IMAGE" \
    --ssh-key-values "$SSH_PUBLIC_KEY" \
    --vm-image-repository-credentials registry-url="$ACR_URL" username="$ACR_USERNAME" password="$ACR_PASSWORD"

After a few minutes, the command completes and returns information about the virtual machine. You've created the virtual machine. You're now ready to use them.

Review deployed resources

After the deployment finishes, you can view the resources using the CLI or the Azure portal.

To view the details of the myNexusVirtualMachine cluster in the myResourceGroup resource group, execute the following

az networkcloud virtualmachine show --name myNexusVirtualMachine --resource-group myResourceGroup

Clean up resources

When no longer needed, delete the resource group. The resource group and all the resources in the resource group are deleted.

Use the az group delete command to remove the resource group, virtual machine, and all related resources except the Operator Nexus network resources.

az group delete --name myResourceGroup --yes --no-wait

Next steps

You've successfully created a Nexus virtual machine. You can now use the virtual machine to host virtual network functions (VNFs).