如何将RDP导入Azure虚拟机

如何将RDP导入Azure虚拟机,azure,virtual-machine,load-balancing,autoscaling,Azure,Virtual Machine,Load Balancing,Autoscaling,通过下面的链接,我能够创建一个带有自定义VHD的Azure VMS,它支持负载平衡和自动缩放。 但是使用上面的链接,我必须在同一个VNET中创建一个新的VM,以便在vms中RDP到VM中 有没有什么方法可以直接在虚拟机内部将RDP导入虚拟机 有没有什么方法可以直接在虚拟机内部将RDP导入虚拟机 根据您的描述,我们可以在该负载平衡器中配置NAT规则 以下是一个模板,用于使用现有VHD创建虚拟机,并配置NAT规则(3389)、负载平衡规则(端口80)和CPU自动扩展: { "$schema":

通过下面的链接,我能够创建一个带有自定义VHD的Azure VMS,它支持负载平衡和自动缩放。

但是使用上面的链接,我必须在同一个VNET中创建一个新的VM,以便在vms中RDP到VM中

有没有什么方法可以直接在虚拟机内部将RDP导入虚拟机

有没有什么方法可以直接在虚拟机内部将RDP导入虚拟机

根据您的描述,我们可以在该负载平衡器中配置NAT规则

以下是一个模板,用于使用现有VHD创建虚拟机,并配置NAT规则(3389)、负载平衡规则(端口80)和CPU自动扩展:

{
  "$schema": "http://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "vmSku": {
      "type": "string",
      "defaultValue": "Standard_D1",
      "metadata": {
        "description": "Size of VMs in the VM Scale Set."
      }
    },
    "sourceImageVhdUri": {
            "type": "string",
            "metadata": {
                "description": "The source of the blob containing the custom image"
            }
        },
    "vmssName": {
      "type": "string",
      "metadata": {
        "description": "String used as a base for naming resources. Must be 3-61 characters in length and globally unique across Azure. A hash is prepended to this string for some resources, and resource-specific information is appended."
      },
      "maxLength": 61
    },
    "instanceCount": {
      "type": "int",
      "metadata": {
        "description": "Number of VM instances (100 or less)."
      },
      "maxValue": 100
    },
    "adminUsername": {
      "type": "string",
      "metadata": {
        "description": "Admin username on all VMs."
      }
    },
    "adminPassword": {
      "type": "securestring",
      "metadata": {
        "description": "Admin password on all VMs."
      }
    },
    "frontEndLBPort": {
      "type": "int",
      "metadata": {
        "description": "The front end port to load balance"
      },
      "defaultValue": 80
    },
    "backEndLBPort": {
      "type": "int",
      "metadata": {
        "description": "The back end port to load balance"
      },
      "defaultValue": 80
    },
    "probeIntervalInSeconds": {
      "type": "int",
      "metadata": {
        "description": "The interval between load balancer health probes"
      },
      "defaultValue": 15
    },
    "numberOfProbes": {
      "type": "int",
      "metadata": {
        "description": "The number of probes that need to fail before a VM instance is deemed unhealthy"
      },
      "defaultValue": 5
    },
    "probeRequestPath": {
      "type": "string",
      "metadata": {
        "description": "The path used for the load balancer health probe"
      },
      "defaultValue": "/iisstart.htm"
    }
  },
  "variables": {
    "namingInfix": "[toLower(substring(concat(parameters('vmssName'), uniqueString(resourceGroup().id)), 0, 9))]",
    "longNamingInfix": "[toLower(parameters('vmssName'))]",
    "addressPrefix": "10.0.0.0/16",
    "subnetPrefix": "10.0.0.0/24",
    "virtualNetworkName": "[concat(variables('namingInfix'), 'vnet')]",
    "publicIPAddressName": "[concat(variables('namingInfix'), 'pip')]",
    "subnetName": "[concat(variables('namingInfix'), 'subnet')]",
    "loadBalancerName": "[concat(variables('namingInfix'), 'lb')]",
    "publicIPAddressID": "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]",
    "lbID": "[resourceId('Microsoft.Network/loadBalancers',variables('loadBalancerName'))]",
    "natPoolName": "[concat(variables('namingInfix'), 'natpool')]",
    "bePoolName": "[concat(variables('namingInfix'), 'bepool')]",
    "lbFEName": "loadBalancerFrontEnd",
    "lbWebProbeName": "loadBalancerWebProbe",
    "natStartPort": 50000,
    "natEndPort": 50119,
    "natBackendPort": 3389,
    "nicName": "[concat(variables('namingInfix'), 'nic')]",
    "ipConfigName": "[concat(variables('namingInfix'), 'ipconfig')]",
    "frontEndIPConfigID": "[concat(variables('lbID'),'/frontendIPConfigurations/loadBalancerFrontEnd')]",
    "lbFEIPConfigID": "[concat(variables('lbID'),'/frontendIPConfigurations/',variables('lbFEName'))]",
    "lbBEAddressPoolID": "[concat(variables('lbID'),'/backendAddressPools/',variables('bePoolName'))]",
    "lbWebProbeID": "[concat(variables('lbID'),'/probes/',variables('lbWebProbeName'))]",
    "computeApiVersion": "2016-04-30-preview",
    "networkApiVersion": "2016-03-30",
    "storageApiVersion": "2015-06-15",
    "insightsApiVersion": "2015-04-01"
  },
  "resources": [
    {
      "type": "Microsoft.Network/virtualNetworks",
      "name": "[variables('virtualNetworkName')]",
      "location": "[resourceGroup().location]",
      "apiVersion": "[variables('networkApiVersion')]",
      "properties": {
        "addressSpace": {
          "addressPrefixes": [
            "[variables('addressPrefix')]"
          ]
        },
        "subnets": [
          {
            "name": "[variables('subnetName')]",
            "properties": {
              "addressPrefix": "[variables('subnetPrefix')]"
            }
          }
        ]
      }
    },
    {
      "type": "Microsoft.Network/publicIPAddresses",
      "name": "[variables('publicIPAddressName')]",
      "location": "[resourceGroup().location]",
      "apiVersion": "[variables('networkApiVersion')]",
      "properties": {
        "publicIPAllocationMethod": "Dynamic",
        "dnsSettings": {
          "domainNameLabel": "[variables('longNamingInfix')]"
        }
      }
    },
    {
      "type": "Microsoft.Network/loadBalancers",
      "name": "[variables('loadBalancerName')]",
      "location": "[resourceGroup().location]",
      "apiVersion": "[variables('networkApiVersion')]",
      "dependsOn": [
        "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]"
      ],
      "properties": {
        "frontendIPConfigurations": [
          {
            "name": "LoadBalancerFrontEnd",
            "properties": {
              "publicIPAddress": {
                "id": "[variables('publicIPAddressID')]"
              }
            }
          }
        ],
        "backendAddressPools": [
          {
            "name": "[variables('bePoolName')]"
          }
        ],
        "inboundNatPools": [
          {
            "name": "[variables('natPoolName')]",
            "properties": {
              "frontendIPConfiguration": {
                "id": "[variables('frontEndIPConfigID')]"
              },
              "protocol": "tcp",
              "frontendPortRangeStart": "[variables('natStartPort')]",
              "frontendPortRangeEnd": "[variables('natEndPort')]",
              "backendPort": "[variables('natBackendPort')]"
            }
          }
        ],
        "loadBalancingRules": [
          {
            "name": "weblb",
            "properties": {
              "frontendIPConfiguration": {
                "id": "[variables('lbFEIPConfigID')]"
              },
              "backendAddressPool": {
                "id": "[variables('lbBEAddressPoolID')]"
              },
              "probe": {
                "id": "[variables('lbWebProbeID')]"
              },
              "protocol": "tcp",
              "frontendPort": "[parameters('frontEndLBPort')]",
              "backendPort": "[parameters('backEndLBPort')]",
              "enableFloatingIP": false
            }
          }
        ],
        "probes": [
          {
            "name": "[variables('lbWebProbeName')]",
            "properties": {
              "protocol": "Http",
              "port": "[parameters('backEndLBPort')]",
              "intervalInSeconds": "[parameters('probeIntervalInSeconds')]",
              "numberOfProbes": "[parameters('numberOfProbes')]",
              "requestPath": "[parameters('probeRequestPath')]"
            }
          }
        ]

      }
    },
    {
      "type": "Microsoft.Compute/virtualMachineScaleSets",
      "name": "[variables('namingInfix')]",
      "location": "[resourceGroup().location]",
      "apiVersion": "[variables('computeApiVersion')]",
      "dependsOn": [
        "[concat('Microsoft.Network/loadBalancers/', variables('loadBalancerName'))]",
        "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
      ],
      "sku": {
        "name": "[parameters('vmSku')]",
        "tier": "Standard",
        "capacity": "[parameters('instanceCount')]"
      },
      "properties": {
        "overprovision": "true",
        "upgradePolicy": {
          "mode": "Manual"
        },
        "virtualMachineProfile": {
          "storageProfile": {
            "osDisk": {
             "name": "vmssosdisk",
             "createOption": "FromImage",
             "osType": "Windows",
             "image": {
              "uri": "[parameters('sourceImageVhdUri')]"
             }
            }
          },
          "osProfile": {
            "computerNamePrefix": "[variables('namingInfix')]",
            "adminUsername": "[parameters('adminUsername')]",
            "adminPassword": "[parameters('adminPassword')]"
          },
          "networkProfile": {
            "networkInterfaceConfigurations": [
              {
                "name": "[variables('nicName')]",
                "properties": {
                  "primary": "true",
                  "ipConfigurations": [
                    {
                      "name": "[variables('ipConfigName')]",
                      "properties": {
                        "subnet": {
                          "id": "[concat('/subscriptions/', subscription().subscriptionId,'/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'), '/subnets/', variables('subnetName'))]"
                        },
                        "loadBalancerBackendAddressPools": [
                          {
                            "id": "[concat('/subscriptions/', subscription().subscriptionId,'/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/loadBalancers/', variables('loadBalancerName'), '/backendAddressPools/', variables('bePoolName'))]"
                          }
                        ],
                        "loadBalancerInboundNatPools": [
                          {
                            "id": "[concat('/subscriptions/', subscription().subscriptionId,'/resourceGroups/', resourceGroup().name, '/providers/Microsoft.Network/loadBalancers/', variables('loadBalancerName'), '/inboundNatPools/', variables('natPoolName'))]"
                          }
                        ]
                      }
                    }
                  ]
                }
              }
            ]
          }
        }
      }
    },
    {
      "type": "Microsoft.Insights/autoscaleSettings",
      "apiVersion": "[variables('insightsApiVersion')]",
      "name": "autoscalewad",
      "location": "[resourceGroup().location]",
      "dependsOn": [
        "[concat('Microsoft.Compute/virtualMachineScaleSets/', variables('namingInfix'))]"
      ],
      "properties": {
        "name": "autoscalewad",
        "targetResourceUri": "[concat('/subscriptions/',subscription().subscriptionId, '/resourceGroups/',  resourceGroup().name, '/providers/Microsoft.Compute/virtualMachineScaleSets/', variables('namingInfix'))]",
        "enabled": true,
        "profiles": [
          {
            "name": "Profile1",
            "capacity": {
              "minimum": "1",
              "maximum": "10",
              "default": "1"
            },
            "rules": [
              {
                "metricTrigger": {
                  "metricName": "Percentage CPU",
                  "metricNamespace": "",
                  "metricResourceUri": "[concat('/subscriptions/',subscription().subscriptionId, '/resourceGroups/',  resourceGroup().name, '/providers/Microsoft.Compute/virtualMachineScaleSets/', variables('namingInfix'))]",
                  "timeGrain": "PT1M",
                  "statistic": "Average",
                  "timeWindow": "PT5M",
                  "timeAggregation": "Average",
                  "operator": "GreaterThan",
                  "threshold": 60.0
                },
                "scaleAction": {
                  "direction": "Increase",
                  "type": "ChangeCount",
                  "value": "1",
                  "cooldown": "PT1M"
                }
              },
              {
                "metricTrigger": {
                  "metricName": "Percentage CPU",
                  "metricNamespace": "",
                  "metricResourceUri": "[concat('/subscriptions/',subscription().subscriptionId, '/resourceGroups/',  resourceGroup().name, '/providers/Microsoft.Compute/virtualMachineScaleSets/', variables('namingInfix'))]",
                  "timeGrain": "PT1M",
                  "statistic": "Average",
                  "timeWindow": "PT5M",
                  "timeAggregation": "Average",
                  "operator": "LessThan",
                  "threshold": 30.0
                },
                "scaleAction": {
                  "direction": "Decrease",
                  "type": "ChangeCount",
                  "value": "1",
                  "cooldown": "PT5M"
                }
              }
            ]
          }
        ]
      }
    }
  ]
}

有关此模板的详细信息,请参阅此。

如果您不想创建跳转框,在某些地区,Azure Bastion是另一种方法。如果单击VM实例名称,您可以看到菜单刀片

谢谢@Jason这么快的回答。我测试了上面的模板,并且能够将RDP转换到虚拟机内部的虚拟机中。再次感谢您的模板。NAT端口范围有什么原因吗?为什么从50000到50119?是否有必要在此范围内包含这么多端口,或者它只能是一个端口?