简体   繁体   English

我可以使用 azure vm rest api (PUT) 更改现有虚拟机中的 Os 配置文件吗?

[英]can I change Os profile in existing virtual machine using azure vm rest api (PUT)?

Try to update OsProfile after Virtual Machine is migrated from on premise to azure cloud because I need to install provisionVMAgent under osProfile?虚拟机从本地迁移到 azure 云后尝试更新 OsProfile,因为我需要在 osProfile 下安装 provisionVMAgent? Using this API Version-使用这个 API 版本-

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

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

{
  "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 - Postman 中的响应 -

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

Is This Possible to update Os Profile after Vm migration?这是否可以在 Vm 迁移后更新 Os Profile? Or Can I install provisionVMAgent in virtual machine after migration of VM?或者我可以在虚拟机迁移后在虚拟机中安装 provisionVMAgent 吗?

You could see provisionVMAgent working at the VM provision time from this , So it's not possible to update it after VM has created.您可以从这里看到provisionVMAgent在 VM 配置时工作,因此在 VM 创建后无法更新它。 在此处输入图像描述

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 .在这种情况下,当您从非托管通用操作系统映像创建自定义映像 VM 时,您可以手动安装 Windows VM 代理 The VM Agent is supported on Windows Server 2008 R2 and later. Windows Server 2008 R2 及更高版本支持 VM 代理。

The VM Agent can be installed by double-clicking the Windows installer file.可以通过双击 Windows 安装程序文件来安装 VM 代理。 For an automated or unattended installation of the VM agent, run the following command:对于 VM 代理的自动或无人值守安装,请运行以下命令:

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

Hope this could help you.希望这可以帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用 Rest Api 创建 azure 虚拟机后,我可以更改虚拟机自动关闭时间吗? - Can I change virtual machine auto shut down time after azure virtual machine created using Rest Api? 如何更改 Azure 虚拟机中的操作系统磁盘大小? - How can I change the OS Disk size in Azure Virtual Machine? 我可以使用 Azure REST ZDB974238714CA8DE3CE38A 获取虚拟机规模集的公共 IP 吗? - Can I get the public IP of a Virtual Machine Scale Set using Azure REST API? 是否可以使用 azure rest api 找到现有虚拟机的可用位置? - Is it possible to find the available location for existing virtual machine using azure rest api? 将azure虚拟机操作系统从Windows更改为ubuntu。 如何更改操作系统? - change azure virtual machine operating system from windows to ubuntu. How I can change OS? 使用Azure REST API检索Linux虚拟机的存储使用情况 - retrieve the storage usage for a Linux Virtual Machine using the Azure REST API 创建虚拟机部署Azure REST API - Create Virtual Machine Deployment Azure REST API Azure 虚拟机备份 Rest API - Azure Virtual Machine BackUp Rest API azure rest api虚拟机cpu使用情况 - azure rest api virtual machine cpu usage Azure虚拟机-Rest API调用不起作用 - Azure Virtual Machine - Rest API calls are not working
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM