Как создать виртуальную машину с WinRM из шаблона ARM? - PullRequest
0 голосов
/ 27 декабря 2018

У меня возникает проблема, когда я пытаюсь запустить задачу выпуска «Развертывание группы ресурсов Azure», чтобы создать / обновить группу ресурсов и ресурсы внутри нее через шаблон ARM.В частности, мне нужно, чтобы виртуальная машина, созданная шаблоном ARM, была доступна через WinRM;Это необходимо сделать, чтобы я мог скопировать файлы (в частности, ZIP-файл, содержащий результаты сборки) на виртуальную машину на более позднем этапе.

В настоящее время у меня есть часть «Шаблон» этого набора задач.в следующем порядке: https://i.imgur.com/mvZDIMK.jpg (я не могу публиковать изображения, так как у меня еще нет репутации здесь ...)

Если я не понял (что вполне возможно), ""Параметр «Настроить с WinRM» должен позволять этапу выпуска создавать прослушиватель WinRM на любых виртуальных машинах, созданных этим шагом.

В настоящее время у меня есть следующие ресурсы в шаблоне ARM:

{
  "type": "Microsoft.Storage/storageAccounts",
  "sku": {
    "name": "Standard_LRS",
    "tier": "Standard"
  },
  "kind": "Storage",
  "name": "[variables('StorageAccountName')]",
  "apiVersion": "2018-02-01",
  "location": "[parameters('LocationPrimary')]",
  "scale": null,
  "tags": {},
  "properties": {
    "networkAcls": {
      "bypass": "AzureServices",
      "virtualNetworkRules": [],
      "ipRules": [],
      "defaultAction": "Allow"
    },
    "supportsHttpsTrafficOnly": false,
    "encryption": {
      "services": {
        "file": {
          "enabled": true
        },
        "blob": {
          "enabled": true
        }
      },
      "keySource": "Microsoft.Storage"
    }
  },
  "dependsOn": []
},
{
  "name": "[variables('NetworkInterfaceName')]",
  "type": "Microsoft.Network/networkInterfaces",
  "apiVersion": "2018-04-01",
  "location": "[parameters('LocationPrimary')]",
  "dependsOn": [
    "[concat('Microsoft.Network/networkSecurityGroups/', variables('NetworkSecurityGroupName'))]",
    "[concat('Microsoft.Network/virtualNetworks/', variables('VNetName'))]",
    "[concat('Microsoft.Network/publicIpAddresses/', variables('PublicIPAddressName'))]"
  ],
  "properties": {
    "ipConfigurations": [
      {
        "name": "ipconfig1",
        "properties": {
          "subnet": {
            "id": "[variables('subnetRef')]"
          },
          "privateIPAllocationMethod": "Dynamic",
          "publicIpAddress": {
            "id": "[resourceId(resourceGroup().name, 'Microsoft.Network/publicIpAddresses', variables('PublicIPAddressName'))]"
          }
        }
      }
    ],
    "networkSecurityGroup": {
      "id": "[variables('nsgId')]"
    }
  },
  "tags": {}
},
{
  "name": "[variables('NetworkSecurityGroupName')]",
  "type": "Microsoft.Network/networkSecurityGroups",
  "apiVersion": "2018-08-01",
  "location": "[parameters('LocationPrimary')]",
  "properties": {
    "securityRules": [
      {
        "name": "RDP",
        "properties": {
          "priority": 300,
          "protocol": "TCP",
          "access": "Allow",
          "direction": "Inbound",
          "sourceAddressPrefix": "*",
          "sourcePortRange": "*",
          "destinationAddressPrefix": "*",
          "destinationPortRange": "3389"
        }
      }
    ]
  },
  "tags": {}
},
{
  "name": "[variables('VNetName')]",
  "type": "Microsoft.Network/virtualNetworks",
  "apiVersion": "2018-08-01",
  "location": "[parameters('LocationPrimary')]",
  "properties": {
    "addressSpace": {
      "addressPrefixes": [ "10.0.0.0/24" ]
    },
    "subnets": [
      {
        "name": "default",
        "properties": {
          "addressPrefix": "10.0.0.0/24"
        }
      }
    ]
  },
  "tags": {}
},
{
  "name": "[variables('PublicIPAddressName')]",
  "type": "Microsoft.Network/publicIpAddresses",
  "apiVersion": "2018-08-01",
  "location": "[parameters('LocationPrimary')]",
  "properties": {
    "publicIpAllocationMethod": "Dynamic"
  },
  "sku": {
    "name": "Basic"
  },
  "tags": {}
},
{
  "name": "[variables('VMName')]",
  "type": "Microsoft.Compute/virtualMachines",
  "apiVersion": "2018-06-01",
  "location": "[parameters('LocationPrimary')]",
  "dependsOn": [
    "[concat('Microsoft.Network/networkInterfaces/', variables('NetworkInterfaceName'))]",
    "[concat('Microsoft.Storage/storageAccounts/', variables('StorageAccountName'))]"
  ],
  "properties": {
    "hardwareProfile": {
      "vmSize": "Standard_A7"
    },
    "storageProfile": {
      "osDisk": {
        "createOption": "fromImage",
        "managedDisk": {
          "storageAccountType": "Standard_LRS"
        }
      },
      "imageReference": {
        "publisher": "MicrosoftWindowsDesktop",
        "offer": "Windows-10",
        "sku": "rs4-pro",
        "version": "latest"
      }
    },
    "networkProfile": {
      "networkInterfaces": [
        {
          "id": "[resourceId('Microsoft.Network/networkInterfaces', variables('NetworkInterfaceName'))]"
        }
      ]
    },
    "osProfile": {
      "computerName": "[variables('VMName')]",
      "adminUsername": "[parameters('AdminUsername')]",
      "adminPassword": "[parameters('AdminPassword')]",
      "windowsConfiguration": {
        "enableAutomaticUpdates": true,
        "provisionVmAgent": true
      }
    },
    "licenseType": "Windows_Client",
    "diagnosticsProfile": {
      "bootDiagnostics": {
        "enabled": true,
        "storageUri": "[concat('https://', variables('StorageAccountName'), '.blob.core.windows.net/')]"
      }
    }
  },
  "tags": {}
}

Этот шаблон ARM в настоящее время работает, если я не пытаюсь настроить виртуальную машину для прослушивания WinRM.

Когда я пытаюсь запустить релиз, я получаю следующее сообщение об ошибке:

Error number:  -2144108526 0x80338012
The client cannot connect to the destination specified in the request. Verify that the service on the destination is running and is accepting requests. Consult the logs and documentation for the WS-Management service running on the destination, most commonly IIS or WinRM. If the destination is the WinRM service, run the following command on the destination to analyze and configure the WinRM service: "winrm quickconfig". 

Честно говоря, моя проблема, скорее всего, заключается в отсутствии понимания, поскольку я впервые работаю с установщиком виртуальных машин в любой реальной работе.Будем весьма благодарны за любые идеи и советы.

1 Ответ

0 голосов
/ 27 декабря 2018

вам просто нужно добавить это к "windowsConfiguration":

"winRM": {
     "listeners": [
         {
             "protocol": "http"
         },
         {
             "protocol": "https",
             "certificateUrl": "<URL for the certificate you got in Step 4>"
         }
    ]
}

, вам также необходимо предоставить сертификаты

ссылка: https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/createorupdate#winrmconfiguration
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/winrm

...