0
votes

Try to update OsProfile after Virtual Machine is migrated from on premise to azure cloud because I need to install provisionVMAgent under osProfile ? Using this API Version-

Reference Url for APi -https://docs.microsoft.com/en-us/rest/api/compute/virtualmachines/createorupdate#request-body

PUT https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}?api-version=2019-03-01

{
  "location": "westus",
  "properties": {
    "hardwareProfile": {
      "vmSize": "Standard_D1_v2"
    },
    "storageProfile": {
      "osDisk": {
        "name": "myVMosdisk",
        "image": {
          "uri": "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/{existing-generalized-os-image-blob-name}.vhd"
        },
        "osType": "Windows",
        "createOption": "FromImage",
        "caching": "ReadWrite",
        "vhd": {
          "uri": "http://{existing-storage-account-name}.blob.core.windows.net/{existing-container-name}/myDisk.vhd"
        }
      }
    },
    "osProfile": {
      "adminUsername": "{your-username}",
      "computerName": "myVM",
      "adminPassword": "{your-password}"
    },
    "networkProfile": {
      "networkInterfaces": [
        {
          "id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Network/networkInterfaces/{existing-nic-name}",
          "properties": {
            "primary": true
          }
        }
      ]
    }
  }
}

Response In Postman -

{
"error": {
    "code": "PropertyChangeNotAllowed",
    "message": "Changing property 'osProfile' is not allowed.",
    "target": "osProfile"
}

Is This Possible to update Os Profile after Vm migration ? Or Can I install provisionVMAgent in virtual machine after migration of VM ?

1

1 Answers

2
votes

You could see provisionVMAgent working at the VM provision time from this, So it's not possible to update it after VM has created. enter image description here

In this case, when you have created a custom-image VM from an unmanaged generalized os image, you could manually install the Windows VM Agent. The VM Agent is supported on Windows Server 2008 R2 and later.

The VM Agent can be installed by double-clicking the Windows installer file. For an automated or unattended installation of the VM agent, run the following command:

msiexec.exe /i WindowsAzureVmAgent.2.7.1198.778.rd_art_stable.160617-1120.fre /quiet

Hope this could help you.