gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-02 06:42:24 24 4
gpt4 key购买 nike

在虚拟机从本地迁移到 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com