azure - 我可以使用 azure vm Rest api (PUT) 更改现有虚拟机中的操作系统配置文件吗?

标签 azure migration virtual-machine azure-functions azure-rest-api

在虚拟机从本地迁移到 Azure 云后尝试更新 OsProfile,因为我需要在 osProfile 下安装 ProvisionVMAgent? 使用此 API 版本-

APi 的引用网址 - https://learn.microsoft.com/en-us/rest/api/compute/virtualmachines/createorupdate#request-body

放置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
          }
        }
      ]
    }
  }
}

postman 中的回复 -

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

虚拟机迁移后是否可以更新操作系统配置文件?或者 迁移虚拟机后我可以在虚拟机中安装provisionVMAgent吗?

最佳答案

您可以看到 provisionVMAgent 在 VM 配置时间从 this 开始工作。 ,因此VM创建后无法更新它。 enter image description here

在这种情况下,当您有created a custom-image VM from an unmanaged generalized os image时,你可以manually install the Windows VM Agent 。 Windows Server 2008 R2 及更高版本支持 VM 代理。

可以通过双击 Windows 安装程序文件来安装 VM Agent。要自动或无人值守安装 VM 代理,请运行以下命令:

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

希望这可以帮助你。

关于azure - 我可以使用 azure vm Rest api (PUT) 更改现有虚拟机中的操作系统配置文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58854865/

相关文章:

virtual-machine - 错误VT-x不适用于Virtualbox内部的Vagrant机器

sql-server - 提供程序 : Session Provider, 错误:19 - 物理连接不可用 - Azure SQL 数据库

azure - 我如何知道哪些用户正在访问 Azure AD OAuth 2.0 中托管的 API,以便他们只能访问自己的私有(private)数据?

mysql - Laravel 5.6 - 不支持 ALGORITHM=COPY

swift - 无法使用类型为 'value' 的参数列表调用 '(String)'

azure - 在 Azure 上设置 Lync 服务器

ubuntu - VM 使用 latin1 的 native 名称编码运行,这可能会导致 Elixir 出现故障,因为它期望使用 utf8

Azure 应用服务自动缩放无法缩小

Azure 扩展事件目标文件

c# - EF6 - 运行不带种子的更新数据库命令