2016-12-15 12 views
1

しばらくAzure Classicポータルを使用していましたが、私のカスタムイメージからVMを作成できました。 新しいポータルを使用しようとしています。新しいVMを作成するときに画像を使用するオプションが表示されません。自分のイメージからVMを作成するにはどうすればいいですか?Azure Resource Managerを使用してカスタムイメージからVMを作成する方法

+0

これを削除して以前の投稿に含めるべきです – 4c74356b41

答えて

0

PowershellまたはARM Templateを使用できます。ここに貼り付けるにはあまりにも多くのコードがありますが、投稿したリンクが変更されても簡単に検索できます。ここで

1

あなたはJSON形式のテンプレートが必要ですfollows-

custom template uri path- https://myvmstore.blob.core.windows.net/vhds/CustomVHD.vhd 
RG Name - myVMsRG 
VNet Name - myVNET 
VmName = mytestvm 
userImageStorageAccountName = myvmstore 
adminUsername = adminuser 
adminPassword = PassWord123# 
osDiskVhdUri = https://myvmstore.blob.core.windows.net/vhds/CustomVHD.vhd 
dnsLabelPrefix = mytestvm 
osType = Windows 
vmSize = Standard_D2 
newOrExistingVnet = existing 
newOrExistingVnetName = myVNET 
newOrExistingSubnetName = mySubnet 

まず は、あなたのリソースグループが作成されたと仮定し、私のインフラの設定...それを行う方法をされています。私はこの形式で自分用に設定しました。同じコードをコピーして、Dドライブにdeployvm.jsonという名前で保存することができます。注:VNET名がmyVNETと異なる場合は、テンプレート内で同じ位置にハードコードしてください。

{ 
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#", 
    "contentVersion": "1.0.0.0", 
    "parameters": { 
    "customVmName": { 
     "type": "string", 
     "metadata": { 
     "description": "This is the name of the your VM" 
     } 
    }, 
    "userImageStorageAccountName": { 
     "type": "string", 
     "metadata": { 
     "description": "This is the name of the your storage account" 
     } 
    }, 
    "osDiskVhdUri": { 
     "type": "string", 
     "metadata": { 
     "description": "Uri of the your user image" 
     } 
    }, 
    "dnsLabelPrefix": { 
     "type": "string", 
     "metadata": { 
     "description": "DNS Label for the Public IP. Must be lowercase. It should match with the following regular expression: ^[a-z][a-z0-9-]{1,61}[a-z0-9]$ or it will raise an error." 
     } 
    }, 
    "adminUserName": { 
     "type": "string", 
     "metadata": { 
     "description": "User Name for the Virtual Machine" 
     } 
    }, 
    "adminPassword": { 
     "type": "securestring", 
     "metadata": { 
     "description": "Password for the Virtual Machine" 
     } 
    }, 
    "osType": { 
     "type": "string", 
     "allowedValues": [ 
     "Windows", 
     "Linux" 
     ], 
     "metadata": { 
     "description": "This is the OS that your VM will be running" 
     } 
    }, 
    "vmSize": { 
     "type": "string", 
     "metadata": { 
     "description": "This is the size of your VM" 
     } 
    }, 
    "newOrExistingVnet": { 
     "allowedValues": [ "new", "existing" ], 
     "type": "string", 
     "metadata": { 
     "description": "Select if this template needs a new VNet or will reference an existing VNet" 
     } 
    }, 
    "newOrExistingVnetName": { 
     "type": "string", 
     "defaultValue": "", 
     "metadata": { 
     "description": "New or Existing VNet Name" 
     } 
    }, 
    "newOrExistingSubnetName": { 
     "type": "string", 
     "defaultValue": "Subnet1", 
     "metadata": { 
     "description": "Subnet Name" 
     } 
    } 
    }, 
    "variables": { 
    "publicIPAddressName": "[parameters('customVmName')]", 
    "vmName": "[parameters('customVmName')]", 
    "nicName": "[parameters('customVmName')]", 
    "publicIPAddressType": "Dynamic", 
    "apiVersion": "2015-06-15", 
    "vnetID": "[resourceId('myVNET', 'Microsoft.Network/virtualNetworks', parameters('newOrExistingVnetName'))]", 
    "subnetRef": "[concat(variables('vnetID'),'/subnets/', parameters('newOrExistingSubnetName'))]", 
}, 
    "resources": [ 
    { 
     "apiVersion": "[variables('apiVersion')]", 
     "type": "Microsoft.Network/publicIPAddresses", 
     "name": "[variables('publicIPAddressName')]", 
     "location": "[resourceGroup().location]", 
     "properties": { 
     "publicIPAllocationMethod": "[variables('publicIPAddressType')]", 
     "dnsSettings": { 
      "domainNameLabel": "[parameters('dnsLabelPrefix')]" 
     } 
     } 
    }, 
    { 
     "apiVersion": "2016-03-30", 
     "type": "Microsoft.Network/networkInterfaces", 
     "name": "[variables('nicName')]", 
     "location": "[resourceGroup().location]", 
     "dependsOn": [ 
     "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]" 
     ], 
     "properties": { 
     "ipConfigurations": [ 
      { 
      "name": "ipconfig1", 
      "properties": { 
       "privateIPAllocationMethod": "Dynamic", 
       "publicIPAddress": { 
       "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]" 
       }, 
       "subnet": { 
       "id": "[variables('subnetRef')]" 
       } 
      } 
      } 
     ] 
     } 
    }, 
    { 
     "apiVersion": "[variables('apiVersion')]", 
     "type": "Microsoft.Compute/virtualMachines", 
     "name": "[variables('vmName')]", 
     "location": "[resourceGroup().location]", 
     "dependsOn": [ 
     "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]" 
     ], 
     "properties": { 
     "hardwareProfile": { 
      "vmSize": "[parameters('vmSize')]" 
     }, 
     "osProfile": { 
      "computerName": "[variables('vmName')]", 
      "adminUsername": "[parameters('adminUsername')]", 
      "adminPassword": "[parameters('adminPassword')]" 
     }, 
     "storageProfile": { 
      "osDisk": { 
      "name": "[concat(variables('vmName'),'-osDisk')]", 
      "osType": "[parameters('osType')]", 
      "caching": "ReadWrite", 
      "createOption": "FromImage", 
      "image": { 
       "uri": "[parameters('osDiskVhdUri')]" 
      }, 
      "vhd": { 
       "uri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', parameters('userImageStorageAccountName')), variables('apiVersion')).primaryEndpoints.blob, 'vhds/',variables('vmName'), uniquestring(resourceGroup().id), 'osDisk.vhd')]" 
      } 
      } 
     }, 
     "networkProfile": { 
      "networkInterfaces": [ 
      { 
       "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]" 
      } 
      ] 
     }, 
     "diagnosticsProfile": { 
      "bootDiagnostics": { 
      "enabled": "true", 
      "storageUri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', parameters('userImageStorageAccountName')), variables('apiVersion')).primaryEndpoints.blob)]" 
      } 
     } 
     } 
    } 
    ] 
} 

今Reference- https://github.com/Azure/azure-quickstart-templates/tree/master/101-vm-from-user-imageあなたのVM-

$paramList = 
    @{ 
     "Params1" = @{ customVmName = "mytestvm" ; userImageStorageAccountName = "myvmstore" ; adminUsername = "adminuser" ; adminPassword = "PassWord123#" ; osDiskVhdUri = "https://myvmstore.blob.core.windows.net/vhds/CustomVHD.vhd" ; dnsLabelPrefix = "mytestvm" ; osType ="Windows" ; vmSize = "Standard_D2" ; newOrExistingVnet = "existing" ; newOrExistingVnetName = "myVPN" ; newOrExistingSubnetName = "mySubnet"} 
     } 

     foreach ($keys in $paramList.Keys) 
     { 
      $paramvalues = $paramList.$keys 
      New-AzureRmResourceGroupDeployment -ResourceGroupName "myVMsRG" -TemplateFile "D:\deployvm.json" -TemplateParameterObject $paramValues 
     } 

を作成するために、PowerShellのコードの下に使用

0

(ここではすべてがリソースの下に格納されAzureのクラシックポータルからの新しいポータルにカスタムイメージをコピーグループ)ストレージアカウント。

これで、Azure CLIまたはPowerShellまたはARMテンプレートを使用して、カスタムイメージを使用して新しいVMを作成することができます。

関連する問題