0
votes

I'm running into an issue when I attempt to run the 'Azure Resource Group Deploy' release task to create/update a resource group and the resources within it via an ARM Template. In particular, I need to have the Virtual Machine created by the ARM template accessible via WinRM; This needs to be done so that I can copy files (specifically a ZIP file containing the results of a build) to the VM in a later step.

Currently, I have the 'Template' portion of this task set up as follows: https://i.imgur.com/mvZDIMK.jpg (I can't post images since I don't have reputation here yet...)

Unless I've misunderstood (which is definitely possible), the "Configure with WinRM" option should allow the release step to create a WinRM Listener on any Virtual Machines created by this step.

I currently have the following resources in the ARM Template:

{
  "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": {}
}

This ARM Template currently works if I do not attempt to configure the VM to have the WinRM Listener.

When I attempt to run the release, I get the following error message:

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". 

In all honesty, my problem is likely a lack of understanding, as this is my first time working with VM Setup in any real capacity. Any insight and advice would be greatly appreciated.

1

1 Answers

0
votes

you just need to add this to the "windowsConfiguration":

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

you also need to provision certificates

reference: https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/createorupdate#winrmconfiguration
https://docs.microsoft.com/en-us/azure/virtual-machines/windows/winrm