2

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://learn.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 ?

Soumya Mishra
  • 39
  • 1
  • 8

1 Answers1

2

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.

Nancy
  • 26,865
  • 3
  • 18
  • 34
  • Thanks Nancy for reply, where this command will be executed ? – Soumya Mishra Nov 15 '19 at 03:47
  • It will be executed on your existing Azure VM via RDP to that VM. After that, you can [detect that agent](https://learn.microsoft.com/en-us/azure/virtual-machines/extensions/agent-windows#detect-the-vm-agent), Alternatively, you can [install the VM agent for an offline windows VM](https://learn.microsoft.com/en-us/azure/virtual-machines/troubleshooting/install-vm-agent-offline). – Nancy Nov 15 '19 at 06:09