Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/225.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在不使用powershell的情况下从现有VHD创建Azure VM_Azure_Azure Vm Templates - Fatal编程技术网

在不使用powershell的情况下从现有VHD创建Azure VM

在不使用powershell的情况下从现有VHD创建Azure VM,azure,azure-vm-templates,Azure,Azure Vm Templates,至于2018年5月28日,我想知道我们是否可以在不使用azure powershell模板的情况下从VDH创建VM。我在网上找到了很多教程,我试着说通过存储帐户将vhd连接到当前VM。但这不是我想要的,因为虚拟机运行的是预先定义好的linux,而不是连接在虚拟机上的linux 您可以尝试使用Azure模板来执行此操作 azuredeploy.json { "$schema": "https://schema.management.azure.com/schemas/2015-01-01/de

至于2018年5月28日,我想知道我们是否可以在不使用azure powershell模板的情况下从VDH创建VM。我在网上找到了很多教程,我试着说通过存储帐户将vhd连接到当前VM。但这不是我想要的,因为虚拟机运行的是预先定义好的linux,而不是连接在虚拟机上的linux

您可以尝试使用Azure模板来执行此操作

azuredeploy.json

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "vmName": {
      "type": "string",
      "metadata": {
        "description": "Name of the VM"
      }
    },
    "osType": {
      "type": "string",
      "allowedValues": [
        "Windows",
        "Linux"
      ],
      "metadata": {
        "description": "Type of OS on the existing vhd"
      }
    },
    "osDiskVhdUri": {
      "type": "string",
      "metadata": {
        "description": "Uri of the existing VHD in ARM standard or premium storage"
      }
    },
    "vmSize": {
      "type": "string",
      "metadata": {
        "description": "Size of the VM"
      }
    },
    "existingVirtualNetworkName": {
      "type": "string",
      "metadata": {
        "description": "Name of the existing VNET"
      }
    },
    "existingVirtualNetworkResourceGroup": {
      "type": "string",
      "metadata": {
        "description": "Name of the existing VNET resource group"
      }
    },
    "subnetName": {
      "type": "string",
      "metadata": {
        "description": "Name of the subnet in the virtual network you want to use"
      }
    },
    "dnsNameForPublicIP": {
      "type": "string",
      "metadata": {
        "description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    }
  },
  "variables": {
    "diagStorageAccountName": "[concat(uniquestring(resourceGroup().id), 'specvm')]",
    "publicIPAddressType": "Dynamic",
    "subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('existingVirtualNetworkName'),  parameters('subnetName'))]",
    "nicName": "[parameters('vmName')]",
    "publicIPAddressName": "[parameters('vmName')]"
  },
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "name": "[variables('diagStorageAccountName')]",
      "apiVersion": "2016-01-01",
      "location": "[parameters('location')]",
      "sku": {
        "name": "Standard_GRS"
      },
      "kind": "Storage",
      "properties": {}
    },
    {
      "apiVersion": "2015-06-15",
      "type": "Microsoft.Network/publicIPAddresses",
      "name": "[variables('publicIPAddressName')]",
      "location": "[parameters('location')]",
      "tags": {
        "displayName": "PublicIPAddress"
      },
      "properties": {
        "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
        "dnsSettings": {
          "domainNameLabel": "[parameters('dnsNameForPublicIP')]"
        }
      }
    },
    {
      "apiVersion": "2015-06-15",
      "type": "Microsoft.Network/networkInterfaces",
      "name": "[variables('nicName')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]"
      ],
      "tags": {
        "displayName": "NetworkInterface"
      },
      "properties": {
        "ipConfigurations": [
          {
            "name": "ipconfig1",
            "properties": {
              "privateIPAllocationMethod": "Dynamic",
              "publicIPAddress": {
                "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
              },
              "subnet": {
                "id": "[variables('subnetRef')]"
              }
            }
          }
        ]
      }
    },
    {
      "apiVersion": "2015-06-15",
      "type": "Microsoft.Compute/virtualMachines",
      "name": "[parameters('vmName')]",
      "location": "[parameters('location')]",
      "tags": {
        "displayName": "VirtualMachine"
      },
      "dependsOn": [
        "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
      ],
      "properties": {
        "hardwareProfile": {
          "vmSize": "[parameters('vmSize')]"
        },
        "storageProfile": {
          "osDisk": {
            "name": "[concat(parameters('vmName'))]",
            "osType": "[parameters('osType')]",
            "caching": "ReadWrite",
            "vhd": {
              "uri": "[parameters('osDiskVhdUri')]"
            },
            "createOption": "Attach"
          }
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
            }
          ]
        },
        "diagnosticsProfile": {
          "bootDiagnostics": {
            "enabled": "true",
            "storageUri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('diagStorageAccountName')), '2016-01-01').primaryEndpoints.blob)]"
          }
        }
      }
    }
  ]
}
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "dnsNameForPublicIP": {
            "value": "GEN-UNIQUE"
        },
        "existingVirtualNetworkName": {
            "value": "GET-PREREQ-existingVnetName"
        },
        "existingVirtualNetworkResourceGroup": {
            "value": "GET-PREREQ-existingVnetRG"
        },
        "subnetName": {
            "value": "GET-PREREQ-subnetName"
        },
        "osDiskVhdUri": {
            "value": "GEN-SPECIALIZED-WINVHD-URI"
        },
        "vmName": {
            "value": "GEN-UNIQUE-8"
        },
        "osType": {
            "value": "Windows"
        },
        "vmSize": {
            "value": "Standard_DS1"
        }
    }
}
azuredeploy.parameters.json

{
  "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "vmName": {
      "type": "string",
      "metadata": {
        "description": "Name of the VM"
      }
    },
    "osType": {
      "type": "string",
      "allowedValues": [
        "Windows",
        "Linux"
      ],
      "metadata": {
        "description": "Type of OS on the existing vhd"
      }
    },
    "osDiskVhdUri": {
      "type": "string",
      "metadata": {
        "description": "Uri of the existing VHD in ARM standard or premium storage"
      }
    },
    "vmSize": {
      "type": "string",
      "metadata": {
        "description": "Size of the VM"
      }
    },
    "existingVirtualNetworkName": {
      "type": "string",
      "metadata": {
        "description": "Name of the existing VNET"
      }
    },
    "existingVirtualNetworkResourceGroup": {
      "type": "string",
      "metadata": {
        "description": "Name of the existing VNET resource group"
      }
    },
    "subnetName": {
      "type": "string",
      "metadata": {
        "description": "Name of the subnet in the virtual network you want to use"
      }
    },
    "dnsNameForPublicIP": {
      "type": "string",
      "metadata": {
        "description": "Unique DNS Name for the Public IP used to access the Virtual Machine."
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    }
  },
  "variables": {
    "diagStorageAccountName": "[concat(uniquestring(resourceGroup().id), 'specvm')]",
    "publicIPAddressType": "Dynamic",
    "subnetRef": "[resourceId('Microsoft.Network/virtualNetworks/subnets', parameters('existingVirtualNetworkName'),  parameters('subnetName'))]",
    "nicName": "[parameters('vmName')]",
    "publicIPAddressName": "[parameters('vmName')]"
  },
  "resources": [
    {
      "type": "Microsoft.Storage/storageAccounts",
      "name": "[variables('diagStorageAccountName')]",
      "apiVersion": "2016-01-01",
      "location": "[parameters('location')]",
      "sku": {
        "name": "Standard_GRS"
      },
      "kind": "Storage",
      "properties": {}
    },
    {
      "apiVersion": "2015-06-15",
      "type": "Microsoft.Network/publicIPAddresses",
      "name": "[variables('publicIPAddressName')]",
      "location": "[parameters('location')]",
      "tags": {
        "displayName": "PublicIPAddress"
      },
      "properties": {
        "publicIPAllocationMethod": "[variables('publicIPAddressType')]",
        "dnsSettings": {
          "domainNameLabel": "[parameters('dnsNameForPublicIP')]"
        }
      }
    },
    {
      "apiVersion": "2015-06-15",
      "type": "Microsoft.Network/networkInterfaces",
      "name": "[variables('nicName')]",
      "location": "[parameters('location')]",
      "dependsOn": [
        "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]"
      ],
      "tags": {
        "displayName": "NetworkInterface"
      },
      "properties": {
        "ipConfigurations": [
          {
            "name": "ipconfig1",
            "properties": {
              "privateIPAllocationMethod": "Dynamic",
              "publicIPAddress": {
                "id": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
              },
              "subnet": {
                "id": "[variables('subnetRef')]"
              }
            }
          }
        ]
      }
    },
    {
      "apiVersion": "2015-06-15",
      "type": "Microsoft.Compute/virtualMachines",
      "name": "[parameters('vmName')]",
      "location": "[parameters('location')]",
      "tags": {
        "displayName": "VirtualMachine"
      },
      "dependsOn": [
        "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
      ],
      "properties": {
        "hardwareProfile": {
          "vmSize": "[parameters('vmSize')]"
        },
        "storageProfile": {
          "osDisk": {
            "name": "[concat(parameters('vmName'))]",
            "osType": "[parameters('osType')]",
            "caching": "ReadWrite",
            "vhd": {
              "uri": "[parameters('osDiskVhdUri')]"
            },
            "createOption": "Attach"
          }
        },
        "networkProfile": {
          "networkInterfaces": [
            {
              "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
            }
          ]
        },
        "diagnosticsProfile": {
          "bootDiagnostics": {
            "enabled": "true",
            "storageUri": "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('diagStorageAccountName')), '2016-01-01').primaryEndpoints.blob)]"
          }
        }
      }
    }
  ]
}
{
    "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentParameters.json#",
    "contentVersion": "1.0.0.0",
    "parameters": {
        "dnsNameForPublicIP": {
            "value": "GEN-UNIQUE"
        },
        "existingVirtualNetworkName": {
            "value": "GET-PREREQ-existingVnetName"
        },
        "existingVirtualNetworkResourceGroup": {
            "value": "GET-PREREQ-existingVnetRG"
        },
        "subnetName": {
            "value": "GET-PREREQ-subnetName"
        },
        "osDiskVhdUri": {
            "value": "GEN-SPECIALIZED-WINVHD-URI"
        },
        "vmName": {
            "value": "GEN-UNIQUE-8"
        },
        "osType": {
            "value": "Windows"
        },
        "vmSize": {
            "value": "Standard_DS1"
        }
    }
}
有关更多详细信息,请参阅此

此模板从专用VHD创建VM,并允许您将其连接到现有VNET,该VNET可以驻留在另一个资源组中,然后是虚拟机

你可以到这里:

并填写所需信息。然后将从VDH uri自动部署VM