Share via


クイックスタート: Bicep を使用して Azure Operator Nexus 仮想マシンを作成する

  • Bicep を使用して Azure Nexus 仮想マシンをデプロイする

このクイックスタート ガイドは、Nexus 仮想マシンを使用して仮想ネットワーク機能 (VNF) をホストする作業を開始するのに役立つよう設計されています。 このガイドで説明されている手順に従うことで、特定のニーズと要件を満たすカスタマイズされた Nexus 仮想マシンをすばやく簡単に作成できます。 初心者にも、Nexusネットワーキングの専門家にも、このガイドは有用です。 仮想ネットワーク機能をホストするために Nexus 仮想マシンを作成してカスタマイズするために必要なすべてのことが説明されています。

開始する前に

Azure サブスクリプションをお持ちでない場合は、開始する前に Azure 無料アカウントを作成してください。

  • Azure Cloud Shell で Bash 環境を使用します。 詳細については、「Azure Cloud Shell の Bash のクイックスタート」を参照してください。

  • CLI リファレンス コマンドをローカルで実行する場合、Azure CLI をインストールします。 Windows または macOS で実行している場合は、Docker コンテナーで Azure CLI を実行することを検討してください。 詳細については、「Docker コンテナーで Azure CLI を実行する方法」を参照してください。

    • ローカル インストールを使用する場合は、az login コマンドを使用して Azure CLI にサインインします。 認証プロセスを完了するには、ターミナルに表示される手順に従います。 その他のサインイン オプションについては、Azure CLI でのサインインに関するページを参照してください。

    • 初回使用時にインストールを求められたら、Azure CLI 拡張機能をインストールします。 拡張機能の詳細については、Azure CLI で拡張機能を使用する方法に関するページを参照してください。

    • az version を実行し、インストールされているバージョンおよび依存ライブラリを検索します。 最新バージョンにアップグレードするには、az upgrade を実行します。

  • 必要な Azure CLI 拡張機能の最新バージョンをインストールします。

  • この記事では、Azure CLI のバージョン 2.49.0 以降が必要です。 Azure Cloud Shell を使用している場合は、最新バージョンが既にインストールされています。

  • 複数の Azure サブスクリプションをお持ちの場合は、az account コマンドを使用して、リソースを課金する適切なサブスクリプション ID を選択してください。

  • 仮想マシンの作成に進む前に、使用するコンテナー イメージが手順に従って作成されていることを確認します。

  • az group create コマンドを使用して、リソース グループを作成します。 Azure リソース グループは、Azure リソースが展開され管理される論理グループです。 リソース グループを作成する際は、場所の指定を求めるプロンプトが表示されます。 この場所は、リソース グループのメタデータが格納される場所です。また、リソースの作成時に別のリージョンを指定しない場合は、Azure でリソースが実行される場所でもあります。 次の例では、myResourceGroup という名前のリソース グループを eastus に作成します。

    az group create --name myResourceGroup --location eastus
    

    リソース グループが正常に作成された場合の出力の例は、次のようになります。

    {
      "id": "/subscriptions/<guid>/resourceGroups/myResourceGroup",
      "location": "eastus",
      "managedBy": null,
      "name": "myResourceGroup",
      "properties": {
        "provisioningState": "Succeeded"
      },
      "tags": null
    }
    
  • Bicep ファイルまたは ARM テンプレートをデプロイするには、デプロイしているリソースに対する書き込みアクセス権が必要であり、また、Microsoft.Resources/デプロイ リソース タイプにあらゆる操作を実行するアクセス権かの゛必要です。 たとえば、クラスターをデプロイするには、Microsoft.NetworkCloud/kubernetesclusters/write と Microsoft.Resources/deployments/* のアクセス許可が必要です。 ロールとアクセス許可の一覧については、Azure の組み込みロールに関するページを参照してください。

  • Azure Operator Nexus クラスターの custom location リソース ID が必要です。

  • 特定のワークロード要件に従ってさまざまなネットワークを作成する必要があり、ワークロードに適切な IP アドレスを使用できるようにすることが重要です。 円滑な実装を行うには、関連するサポート チームに問い合わせて支援を求めることをお勧めします。

  • Nexus 仮想マシンをデプロイするための前提条件を満たします。

テンプレートを確認する

仮想マシン テンプレートをデプロイする前に、その構造を理解するためにコンテンツを確認しましょう。

@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 GB (max 224 GB)')
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@2023-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
      defaultGateway: 'False'
      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)
  }
}

virtual-machine-bicep-template.bicep という名前のテンプレート ファイルを確認して保存したら、次のセクションに進んでテンプレートをデプロイします。

テンプレートのデプロイ

  1. virtual-machine-parameters.json という名前のファイルを作成し、必要なパラメーターを JSON 形式で追加します。 開始点として、次の例を使用できます。 サンプルの値は実際の値に変更してください。
{
    "$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. テンプレートをデプロイします。
    az deployment group create --resource-group myResourceGroup --template-file virtual-machine-bicep-template.bicep --parameters @virtual-machine-parameters.json

デプロイされているリソースを確認する

デプロイが完了したら、CLI または Azure portal を使用してリソースを表示できます。

myResourceGroup リソース グループ内の myNexusVirtualMachine クラスターの詳細を表示するには、次のコマンドを実行します。

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

リソースをクリーンアップする

不要になったら、リソース グループを削除します。 リソース グループとリソース グループ内のすべてのリソースが削除されます。

az group delete コマンドを使用すると、リソース グループ、仮想マシンと、関連するすべてのリソース (Operator Nexus ネットワーク リソース以外) が削除されます。

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

次のステップ

Nexus 仮想マシンが正常に作成されました。 仮想マシンを使用して仮想ネットワーク機能 (VNF) をホストできるようになりました。