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

  • Deploy an Azure Nexus virtual machine using Bicep

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.61.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.

Review the template

Before deploying the virtual machine template, let's review the content to understand its structure.

@description('The name of Nexus virtual machine')
param vmName string

@description('The Azure region where the VM is to be deployed')
param location string = resourceGroup().location

@description('The custom location of the Nexus instance')
param extendedLocation string

@description('The metadata tags to be associated with the cluster resource')
param tags object = {}

@description('The name of the administrator to which the ssh public keys will be added into the authorized keys.')
@minLength(1)
@maxLength(32)
param adminUsername string = 'azureuser'

@description('Selects the boot method for the virtual machine.')
@allowed([
  'UEFI'
  'BIOS'
])
param bootMethod string = 'UEFI'

@description('The Cloud Services Network attachment ARM ID to attach to virtual machine.')
param cloudServicesNetworkId string

@description('Number of CPU cores for the virtual machine. Choose a value between 2 and 46.')
param cpuCores int = 2

@description('The memory size of the virtual machine in GiB (max 224 GiB)')
param memorySizeGB int = 4

@description('The list of network attachments to the virtual machine.')
param networkAttachments array

// {
//   attachedNetworkId: "string"
//   defaultGateway: "True"/"False"
//   ipAllocationMethod: "Dynamic"/"Static","Disabled"
//   ipv4Address: "string"
//   ipv6Address: "string"
//   networkAttachmentName: "string"
// }

@description('The Base64 encoded cloud-init network data.')
param networkData string = ''

@description('The placement hints for the virtual machine.')
param placementHints array = []
// {
//   hintType: "Affinity/AntiAffinity"
//   resourceId: string
//   schedulingExecution: "Hard/Soft"
//   scope: "Rack/Machine"
// }

@description('The list of SSH public keys for the virtual machine.')
param sshPublicKeys array
// {
//   keyData: 'string'
// }

@description('StorageProfile represents information about a disk.')
param storageProfile object = {
  osDisk: {
    createOption: 'Ephemeral'
    deleteOption: 'Delete'
    diskSizeGB: 64
  }
}

@description('The Base64 encoded cloud-init user data.')
param userData string = ''

@description('The type of the device model to use.')
@allowed([
  'T1'
  'T2'
])
param vmDeviceModel string = 'T2'

@description('The virtual machine image that is currently provisioned to the OS disk, using the full URL and tag notation used to pull the image.')
param vmImage string

@description('Credentials used to login to the image repository.')
param vmImageRepositoryCredentials object = {}
// password: "string"
// registryUrl: "string"
// username: "string"

resource vm 'Microsoft.NetworkCloud/virtualMachines@2024-07-01' = {
  name: vmName
  location: location
  extendedLocation: {
    type: 'CustomLocation'
    name: extendedLocation
  }
  tags: tags
  properties: {
    adminUsername: (empty(adminUsername) ? null : adminUsername)
    bootMethod: (empty(bootMethod) ? null : bootMethod)
    cloudServicesNetworkAttachment: {
      attachedNetworkId: cloudServicesNetworkId
      ipAllocationMethod: 'Dynamic'
    }
    cpuCores: cpuCores
    memorySizeGB: memorySizeGB
    networkData: (empty(networkData) ? null : networkData)
    networkAttachments: (empty(networkAttachments) ? null : networkAttachments)
    placementHints: (empty(placementHints) ? null : placementHints)
    sshPublicKeys: (empty(sshPublicKeys) ? null : sshPublicKeys)
    storageProfile: (empty(storageProfile) ? null : storageProfile)
    userData: (empty(userData) ? null : userData)
    vmDeviceModel: (empty(vmDeviceModel) ? null : vmDeviceModel)
    vmImage: (empty(vmImage) ? null : vmImage)
    vmImageRepositoryCredentials: (empty(vmImageRepositoryCredentials) ? null : vmImageRepositoryCredentials)
  }
}

Warning

User data will not be encrypted, and any process on the VM can query this data. You should not store confidential information in user data. For more information, see Azure data security and encryption best practices.

Once you have reviewed and saved the template file named virtual-machine-bicep-template.bicep, proceed to the next section to deploy the template.

Deploy the template

  1. Create a file named virtual-machine-parameters.json and add the required parameters in JSON format. You can use the following example as a starting point. Replace the values with your own.
{
    "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
      "vmName": {
        "value": "myNexusVirtualMachine"
      },
      "location": {
        "value": "eastus"
      },
      "extendedLocation": {
        "value": "/subscriptions/<subscription>/resourcegroups/<cluster-managed-resource-group>/providers/microsoft.extendedlocation/customlocations/<custom-location-name>"
      },
      "cloudServicesNetworkId": {
          "value": "/subscriptions/<subscription>/resourceGroups/<network-resource-group>/providers/Microsoft.NetworkCloud/cloudServicesNetworks/<csn-name>"
      },
      "networkAttachments": {
          "value": [
            {
                "attachedNetworkId": "/subscriptions/<subscription>/resourceGroups/<network-resource-group>/providers/Microsoft.NetworkCloud/l3Networks/<l3network-name>",
                "ipAllocationMethod": "Dynamic",
                "defaultGateway": "True",
                "networkAttachmentName": "mgmt0"
            }
        ]
      },
      "sshPublicKeys": {
          "value": [
            {
                "keyData": "ssh-rsa AAAAB3...."
            }
        ]
      },
      "vmImage": {
          "value": "<Image ACR URL>"
      },
      "vmImageRepositoryCredentials": {
          "value": {
              "password": "********************",
              "registryUrl": "<ACR registry URL>",
              "username": "<ACR user name>"
          }
      }
    }
  }
  1. Deploy the template.
    az deployment group create --resource-group myResourceGroup --template-file virtual-machine-bicep-template.bicep --parameters @virtual-machine-parameters.json

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).