管理 Azure 本地上的 Arc VM

适用于:Azure Local 2311.2 及更高版本

本文介绍如何管理 Azure Local 版本 23H2 上运行的 Azure Arc 虚拟机(VM)。 其中介绍了启用来宾管理以及启动、停止、重启、暂停、保存和删除 Azure Arc VM 的过程。

先决条件

  • 访问已部署和注册的 Azure 本地实例。 Azure 本地实例的部署包括创建 Azure Arc 资源网桥和自定义位置。

    转到 Azure 中的资源组。 显示的信息包括为 Azure Local 创建的自定义位置和 Azure Arc 资源桥。 记下订阅、资源组和自定义位置。 本方案后面会用到它们。

  • 在 Azure 本地实例上运行的一个或多个 Azure Arc VM。 有关详细信息,请参阅 在 Azure 本地上创建 Azure Arc 虚拟机。

启用来宾管理

请务必了解来宾管理上下文中的两个代理:VM 来宾代理和 Azure Connected Machine 代理。 通过 Azure 门户或 Azure CLI 创建的每个 Azure Arc VM 都使用来宾代理(也称为 mocguestagent)对其进行预配。

在 Azure Arc VM 上启用来宾管理时,来宾代理将安装 Azure Connected Machine 代理。 使用 Azure Connected Machine 代理管理 VM 上的 Azure Arc VM 扩展。

以下是在为 VM 完成预配后启用来宾管理的一些关键注意事项:

  • 确保 Azure 本地实例正在运行 2311.2 或更高版本。
  • Windows Server 2012 和 Windows Server 2012 R2 不支持在 VM 预配后启用来宾管理。
  • 启用来宾管理的步骤因来宾代理是否在 Azure Arc VM 上运行而有所不同。

验证来宾代理是否正在运行

验证来宾代理是否在 Azure Arc VM 上运行:

  1. 连接到计算机。

  2. 运行下面的命令:

    az stack-hci-vm show --name "<VM name>" --resource-group "<Resource group name>"
    

    下面是一个示例输出片段,指示来宾代理正在运行。 在输出中的 vmAgent 下查找 statuses

    "instanceView": {
      "vmAgent": {
        "statuses": [
          {
            "code": "ProvisioningState/succeeded",
            "displayStatus": "Connected",
            "level": "Info",
            "message": "Successfully established connection with mocguestagent",
            "time": "2024-01-13T00:57:39Z"
          },
          {
            "code": "ProvisioningState/succeeded",
            "displayStatus": "Connected",
            "level": "Info",
            "message": "New mocguestagent version detected 'v0.13.0-3-gd13b4794",
            "time": "2024-01-13T00:57:39Z"
          }
        ],
        "vmConfigAgentVersion": "v0.13.0-3-gd13b4794"
      }
    }
    

    statuses 指示 codeProvisioningState/succeeded,指示 displayStatusConnected 时,来宾代理正在运行。

    如果运行的版本较旧,statuses 指示 codeOK,并指示 displayStatusActive.

如果状态与前面的输出不匹配,请按照在来宾代理未运行时启用来宾管理中的步骤进行操作。

在来宾代理运行时在 VM 上启用来宾管理

若要在运行来宾代理的 Azure Arc VM 上启用来宾管理,请执行以下作:

  1. 运行以下命令,将 enable-agent 参数设置为 true

    az stack-hci-vm update --name "mylocal-vm" --enable-agent true --resource-group "mylocal-rg"
    

    来宾管理需要几分钟才能启用。

  2. 验证是否已启用来宾管理。 请按照 中的步骤,验证在 Azure 门户中是否启用了来宾管理功能

当来宾代理未运行时,在 VM 上启用来宾管理

来宾代理不会在两种情况下运行:当状态为 Connecting 或状态为 null 时。 以下部分介绍这些方案和相应的步骤。

状态显示为“正在连接”

此示例输出片段显示 Connecting的状态:

"instanceView": {
      "vmAgent": {
        "statuses": [
          {
            "code": "ProvisioningState/InProgress",
            "displayStatus": "Connecting",
            "level": "Info",
            "message": "Waiting for connection with mocguestagent",
            "time": "2024-01-19T01:41:15Z"
          }
        ]
      }
    },

statuses 指示 codeProvisioningState/InProgress,指示 displayStatusConnecting 时,来宾代理未在运行。

如果运行的版本较旧,statuses 指示 codeOKdisplayStatusActivemessageSuccessfully started HyperV listener

执行以下步骤:

  1. 使用特定于 OS 的步骤连接到 VM。 以管理员身份运行 Azure PowerShell。

  2. 运行以下命令之一,以根据操作系统类型在虚拟机上启用客户代理。

    对 Linux 使用此命令:

    sudo -- sh -c 'mkdir /mociso && mount -L mocguestagentprov /mociso && bash /mociso/install.sh && umount /mociso && rm -df /mociso && eject LABEL=mocguestagentprov'
    

    对 Windows 使用此命令:

    $d=Get-Volume -FileSystemLabel mocguestagentprov;$p=Join-Path ($d.DriveLetter+':\') 'install.ps1';powershell $p
    

    下面是显示成功安装来宾代理的 Linux VM 的示例输出。

    显示来宾代理已成功在 VM 上启用的屏幕截图。

  3. 连接到其中一台计算机。 运行以下命令以启用来宾管理:

    az stack-hci-vm update --name "mylocal-vm" --enable-agent true --resource-group "mylocal-rg"
    
  4. 验证是否已启用来宾管理。 按照验证是否在 Azure 门户中启用了来宾管理中的步骤进行操作。

状态显示为 null

以下示例输出代码片段显示 null 状态。 此状态指示缺少来宾代理所需的 iso

"instanceView": {
      "vmAgent": {
        "statuses": []
      }
    },

执行以下步骤:

  1. 连接到计算机。

  2. 运行下面的命令:

    az stack-hci-vm update --name "<VM Name>" --resource-group "<Resource group name>" --enable-vm-config-agent true
    

    enable-vm-config-agent 参数装载来宾代理所需的 iso

  3. 等待几分钟,然后重新运行 az stack-hci-vm show 命令。 当状态显示 Connecting 时,请按照状态显示为正在连接中的步骤操作。

验证是否已在 Azure 门户中启用来宾管理

  1. 转到 Azure 门户。

  2. 转到 Azure 本地>虚拟机,然后选择启用了来宾管理的虚拟机。

  3. 概述 页的“属性”选项卡上,进入 配置来宾管理 应显示 启用(已连接)

    Azure 门户的屏幕截图,其中显示了用于验证是否已启用来宾管理的区域。

查看 VM 属性

若要查看 Azure 本地实例的 VM 属性,请在 Azure 门户中执行以下步骤:

  1. 转到 Azure 本地资源,然后转到 虚拟机

  2. 在虚拟机列表中,选择要查看其属性的 VM 的名称。

    从虚拟机列表中选择的虚拟机的屏幕截图。

  3. 概述 页上,选择“属性”选项卡以查看 VM 的属性。

    所选 Azure Arc 虚拟机属性的屏幕截图。

启动 VM

若要启动 VM,请在 Azure 门户中为 Azure 本地实例执行以下步骤:

  1. 转到 Azure 本地资源,然后转到 虚拟机

  2. 在虚拟机列表中,选择未运行且要启动的 VM。

  3. 在 VM 的概述页上,在命令栏中,选择开始

    用于在概述页上启动虚拟机的按钮的屏幕截图。

  4. 选择

  5. 验证 VM 是否已启动。

停止 VM

若要停止 VM,请在 Azure 门户中为 Azure 本地实例执行以下步骤:

  1. 转到 Azure 本地资源,然后转到 虚拟机

  2. 在虚拟机列表中,选择要停止的 VM。

  3. 在 VM 的 概述 页上,在命令栏上,选择 停止

    用于在概述页上停止虚拟机的按钮的屏幕截图。

  4. 选择

  5. 验证 VM 是否已停止。

重新启动 VM

若要重启 VM,请在 Azure 门户中为 Azure 本地实例执行以下步骤:

  1. 转到 Azure 本地资源,然后转到 虚拟机

  2. 在虚拟机列表中,选择一个已停止且要重启的 VM。

  3. 在 VM 的 概述 页上,在命令栏上,选择 重启

    用于在概述页上重启虚拟机的按钮的屏幕截图。

  4. 选择

  5. 验证 VM 是否已重启。

暂停 VM

暂停 VM 有助于在不使用 VM 时保存计算资源。 暂停 VM 会停止任何 CPU 活动。

只能暂停正在运行的 VM。 暂停 VM 后,可以稍后恢复。

  1. 连接到系统上的计算机。

  2. 运行以下 Azure Powershell cmdlet:

    #Set input parameters
    
    $rg = "<Resource group name>"
    $vmName = "<VM name>"
    
    #Pause the VM
    
    az stack-hci-vm pause --name $vmName --resource-group $rg
    

    此 cmdlet 的参数如下所示:

    参数 说明
    name 虚拟机名称。
    resource-group 资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
    subscription 订阅的名称或 ID。 可以使用 az account set -s NAME_OR_ID配置默认订阅。
  3. 检查 VM 状态以验证 VM 是否已暂停:

    #Check the VM status
    
    az stack-hci-vm show --name $vmName --resource-group $rg
    
  4. 启动 VM 以从暂停状态恢复 VM:

    #Start the VM
    
    az stack-hci-vm start --name $vmName --resource-group $rg
    
  5. 验证 VM 是否正在运行。

示例输出

展开此部分以查看示例输出。

#Set parameters

[v-host1]: PS C:\Users\HCIDeploymentUser> $rg = "<Resource group name>"    
[v-host1]: PS C:\Users\HCIDeploymentUser> $vmName = "<VM name>"

#Pause the VM

[v-host1]: PS C:\Users\HCIDeploymentUser> az stack-hci-vm pause --name $vmName --resource-group $rg

#Show the current state of the VM
[v-host1]: PS C:\Users\HCIDeploymentUser> az stack-hci-vm show -g $rg --name $vmName
{
  "attestationStatus": null,
  "virtualmachineinstance": {
    "extendedLocation": {
      "name": "/subscriptions/<Subscription ID>/resourcegroups/<Resource group name>/providers/Microsoft.ExtendedLocation/customLocations/s-cluster-customlocation",
      "type": "CustomLocation"
    },
    "id": "/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.HybridCompute/machines/testvm001/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default",
    "identity": null,
    "name": "default",
    "properties": {
      "guestAgentInstallStatus": null,
      "hardwareProfile": {
        "dynamicMemoryConfig": {
          "maximumMemoryMb": null,
          "minimumMemoryMb": null,
          "targetMemoryBuffer": null
        },
        "memoryMb": 2000,
        "processors": 2,
        "vmSize": "Custom"
      },
      "httpProxyConfig": null,
      "instanceView": {
        "vmAgent": {
          "statuses": [
            {
              "code": "ProvisioningState/succeeded",
              "displayStatus": "Connected",
              "level": "Info",
              "message": "Connection with mocguestagent was successfully reestablished",
              "time": "2024-06-24T16:30:05+00:00"
            },
          ],
          "vmConfigAgentVersion": "v0.18.0-4-gd54376b0"
        }
      },
      "networkProfile": {
        "networkInterfaces": []
      },
      "osProfile": {
        "adminPassword": null,
        "adminUsername": "azureuser",
        "computerName": "testvm001",
        "linuxConfiguration": {
          "disablePasswordAuthentication": false,
          "provisionVmAgent": false,
          "provisionVmConfigAgent": true,
          "ssh": {
            "publicKeys": null
          }
        },
        "windowsConfiguration": {
          "enableAutomaticUpdates": null,
          "provisionVmAgent": false,
          "provisionVmConfigAgent": true,
          "ssh": {
            "publicKeys": null
          },
          "timeZone": null
        }
      },
      "provisioningState": "Succeeded",
      "resourceUid": null,
      "securityProfile": {
        "enableTpm": false,
        "securityType": null,
        "uefiSettings": {
          "secureBootEnabled": true
        }
      },
      "status": {
        "errorCode": "",
        "errorMessage": "",
        "powerState": "Paused",
        "provisioningStatus": null
      },
      "storageProfile": {
        "dataDisks": [],
        "imageReference": {
          "id": "/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.AzureStackHCI/galleryImages/WinImage-26tdJUIS",
          "resourceGroup": "<Resource group name>"
        },
        "osDisk": {
          "id": null,
          "osType": "Windows"
        },
        "vmConfigStoragePathId": "/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.AzureStackHCI/storageContainers/UserStorage2-guid"
      },
      "vmId": "<guid>"
    },
    "resourceGroup": "<Resource group name>",
    "systemData": {
      "createdAt": "2024-06-24T01:29:06.594266+00:00",
      "createdBy": "7d6ffe2f-dac5-4e74-9bf2-4830cf7f4668",
      "createdByType": "Application",
      "lastModifiedAt": "2024-06-24T16:41:27.166668+00:00",
      "lastModifiedBy": "319f651f-7ddb-4fc6-9857-7aef9250bd05",
      "lastModifiedByType": "Application"
    },
    "type": "microsoft.azurestackhci/virtualmachineinstances"
  }
}

#Start the VM after it was paused. 

[v-host1]: PS C:\Users\HCIDeploymentUser> az stack-hci-vm start --name $vmName --resource-group $rg
Inside _start_initial/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.HybridCompute/machines/testvm0012024-02-01-preview/https://management.azure.com/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.HybridCompute/machines/testvm001/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/start?api-version=2024-02-01-preview

#Show the current state of the VM. The VM should be running.

[v-host1]: PS C:\Users\HCIDeploymentUser> az stack-hci-vm show -g $rg --name $vmName
{
  "attestationStatus": null,
  "virtualmachineinstance": {
    "extendedLocation": {
      "name": "/subscriptions/<Subscription ID>/resourcegroups/<Resource group name>/providers/Microsoft.ExtendedLocation/customLocations/s-cluster-customlocation",
      "type": "CustomLocation"
    },
    "id": "/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.HybridCompute/machines/testvm001/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default",
    "identity": null,
    "name": "default",
    "properties": {
      "guestAgentInstallStatus": null,
      "hardwareProfile": {
        "dynamicMemoryConfig": {
          "maximumMemoryMb": null,
          "minimumMemoryMb": null,
          "targetMemoryBuffer": null
        },
        "memoryMb": 2000,
        "processors": 2,
        "vmSize": "Custom"
      },
      "httpProxyConfig": null,
      "instanceView": {
        "vmAgent": {
          "statuses": [
            {
              "code": "ProvisioningState/succeeded",
              "displayStatus": "Connected",
              "level": "Info",
              "message": "Connection with mocguestagent was successfully reestablished",
              "time": "2024-06-24T17:25:19+00:00"
            }
          ],
          "vmConfigAgentVersion": "v0.18.0-4-gd54376b0"
        }
      },
      "networkProfile": {
        "networkInterfaces": []
      },
      "osProfile": {
        "adminPassword": null,
        "adminUsername": "azureuser",
        "computerName": "testvm001",
        "linuxConfiguration": {
          "disablePasswordAuthentication": false,
          "provisionVmAgent": false,
          "provisionVmConfigAgent": true,
          "ssh": {
            "publicKeys": null
          }
        },
        "windowsConfiguration": {
          "enableAutomaticUpdates": null,
          "provisionVmAgent": false,
          "provisionVmConfigAgent": true,
          "ssh": {
            "publicKeys": null
          },
          "timeZone": null
        }
      },
      "provisioningState": "Succeeded",
      "resourceUid": null,
      "securityProfile": {
        "enableTpm": false,
        "securityType": null,
        "uefiSettings": {
          "secureBootEnabled": true
        }
      },
      "status": {
        "errorCode": "",
        "errorMessage": "",
        "powerState": "Running",
        "provisioningStatus": null
      },
      "storageProfile": {
        "dataDisks": [],
        "imageReference": {
          "id": "/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.AzureStackHCI/galleryImages/WinImage-26tdJUIS",
          "resourceGroup": "<Resource group name>"
        },
        "osDisk": {
          "id": null,
          "osType": "Windows"
        },
        "vmConfigStoragePathId": "/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.AzureStackHCI/storageContainers/UserStorage2-guid"
      },
      "vmId": "<guid>"
    },
    "resourceGroup": "<Resource group name>",
    "systemData": {
      "createdAt": "2024-06-24T01:29:06.594266+00:00",
      "createdBy": "<guid>",
      "createdByType": "Application",
      "lastModifiedAt": "2024-06-24T17:28:13.206935+00:00",
      "lastModifiedBy": "<guid>",
      "lastModifiedByType": "Application"
    },
    "type": "microsoft.azurestackhci/virtualmachineinstances"
  }
}

保存 VM

保存 VM 会将其当前状态存储到磁盘并停止 VM。 保存 VM 会释放内存和 CPU 资源。 只能保存正在运行的 VM。

  1. 连接到系统上的计算机。

  2. 运行以下 Azure Powershell cmdlet:

    #Set input parameters
    
    $rg = "<Resource group name>"
    $vmName = "<VM name>"
    
    #Save the VM
    
    az stack-hci-vm save --name $vmName --resource-group $rg
    

    此 cmdlet 的参数如下所示:

    参数 说明
    name 虚拟机名称。
    resource-group 资源组的名称。 可以使用 az configure --defaults group=<name>配置默认组。
    subscription 订阅的名称或 ID。 可以使用 az account set -s <Subscription name or Subscription ID>配置默认订阅。
  3. 检查 VM 状态以验证 VM 是否已保存:

    #Check the VM status
    
    az stack-hci-vm show --name $vmName --resource-group $rg
    
  4. 启动 VM 以从已保存状态恢复 VM:

    #Start the VM
    
    az stack-hci-vm start --name $vmName --resource-group $rg
    
  5. 验证 VM 是否正在运行。

示例输出

展开此部分以查看示例输出。
#Set parameters

[v-host1]: PS C:\Users\HCIDeploymentUser> $rg = "<Resource group name>"    
[v-host1]: PS C:\Users\HCIDeploymentUser> $vmName = "<VM name>"

#Save the VM

[v-host1]: PS C:\Users\HCIDeploymentUser> az stack-hci-vm save --name $vmName --resource-group $rg

#Show the current state of the VM

[v-host1]: PS C:\Users\HCIDeploymentUser> az stack-hci-vm show -g $rg --name $vmName
{
  "attestationStatus": null,
  "virtualmachineinstance": {
    "extendedLocation": {
      "name": "/subscriptions/<Subscription ID>/resourcegroups/<Resource group name>/providers/Microsoft.ExtendedLocation/customLocations/s-cluster-customlocation",
      "type": "CustomLocation"
    },
    "id": "/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.HybridCompute/machines/testvm001/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default",
    "identity": null,
    "name": "default",
    "properties": {
      "guestAgentInstallStatus": null,
      "hardwareProfile": {
        "dynamicMemoryConfig": {
          "maximumMemoryMb": null,
          "minimumMemoryMb": null,
          "targetMemoryBuffer": null
        },
        "memoryMb": 2000,
        "processors": 2,
        "vmSize": "Custom"
      },
      "httpProxyConfig": null,
      "instanceView": {
        "vmAgent": {
          "statuses": [
            {
              "code": "ProvisioningState/succeeded",
              "displayStatus": "Connected",
              "level": "Info",
              "message": "Connection with mocguestagent was successfully reestablished",
              "time": "2024-06-24T17:25:19+00:00"
            },
          ],
          "vmConfigAgentVersion": "v0.18.0-4-gd54376b0"
        }
      },
      "networkProfile": {
        "networkInterfaces": []
      },
      "osProfile": {
        "adminPassword": null,
        "adminUsername": "azureuser",
        "computerName": "testvm001",
        "linuxConfiguration": {
          "disablePasswordAuthentication": false,
          "provisionVmAgent": false,
          "provisionVmConfigAgent": true,
          "ssh": {
            "publicKeys": null
          }
        },
        "windowsConfiguration": {
          "enableAutomaticUpdates": null,
          "provisionVmAgent": false,
          "provisionVmConfigAgent": true,
          "ssh": {
            "publicKeys": null
          },
          "timeZone": null
        }
      },
      "provisioningState": "Succeeded",
      "resourceUid": null,
      "securityProfile": {
        "enableTpm": false,
        "securityType": null,
        "uefiSettings": {
          "secureBootEnabled": true
        }
      },
      "status": {
        "errorCode": "",
        "errorMessage": "",
        "powerState": "Saved",
        "provisioningStatus": null
      },
      "storageProfile": {
        "dataDisks": [],
        "imageReference": {
          "id": "/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.AzureStackHCI/galleryImages/WinImage-26tdJUIS",
          "resourceGroup": "<Resource group name>"
        },
        "osDisk": {
          "id": null,
          "osType": "Windows"
        },
        "vmConfigStoragePathId": "/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.AzureStackHCI/storageContainers/UserStorage2-345d968fa1e74e99a9509ab7f3d259fd"
      },
      "vmId": "<guid>"
    },
    "resourceGroup": "<Resource group name>",
    "systemData": {
      "createdAt": "2024-06-24T01:29:06.594266+00:00",
      "createdBy": "<guid>",
      "createdByType": "Application",
      "lastModifiedAt": "2024-06-24T18:29:02.794305+00:00",
      "lastModifiedBy": "<guid>",
      "lastModifiedByType": "Application"
    },
    "type": "microsoft.azurestackhci/virtualmachineinstances"
  }
}
    
#Start the VM after it was saved

[v-host1]: PS C:\Users\HCIDeploymentUser> az stack-hci-vm start --name $vmName --resource-group $rg
Inside _start_initial/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.HybridCompute/machines/testvm0012024-02-01-previewhttps://management.azure.com/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.HybridCompute/machines/testvm001/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default/start?api-version=2024-02-01-preview

#Show the current state of the VM. The VM should be running.

[v-host1]: PS C:\Users\HCIDeploymentUser> az stack-hci-vm show -g $rg --name $vmName
{
  "attestationStatus": null,
  "virtualmachineinstance": {
    "extendedLocation": {
      "name": "/subscriptions/<Subscription ID>/resourcegroups/<Resource group name>/providers/Microsoft.ExtendedLocation/customLocations/s-cluster-customlocation",
      "type": "CustomLocation"
    },
    "id": "/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.HybridCompute/machines/testvm001/providers/Microsoft.AzureStackHCI/virtualMachineInstances/default",
    "identity": null,
    "name": "default",
    "properties": {
      "guestAgentInstallStatus": null,
      "hardwareProfile": {
        "dynamicMemoryConfig": {
          "maximumMemoryMb": null,
          "minimumMemoryMb": null,
          "targetMemoryBuffer": null
        },
        "memoryMb": 2000,
        "processors": 2,
        "vmSize": "Custom"
      },
      "httpProxyConfig": null,
      "instanceView": {
        "vmAgent": {
          "statuses": [
            {
              "code": "ProvisioningState/succeeded",
              "displayStatus": "Connected",
              "level": "Info",
              "message": "Connection with mocguestagent was successfully reestablished",
              "time": "2024-06-24T18:32:41+00:00"
            }
          ],
          "vmConfigAgentVersion": "v0.18.0-4-gd54376b0"
        }
      },
      "networkProfile": {
        "networkInterfaces": []
      },
      "osProfile": {
        "adminPassword": null,
        "adminUsername": "azureuser",
        "computerName": "testvm001",
        "linuxConfiguration": {
          "disablePasswordAuthentication": false,
          "provisionVmAgent": false,
          "provisionVmConfigAgent": true,
          "ssh": {
            "publicKeys": null
          }
        },
        "windowsConfiguration": {
          "enableAutomaticUpdates": null,
          "provisionVmAgent": false,
          "provisionVmConfigAgent": true,
          "ssh": {
            "publicKeys": null
          },
          "timeZone": null
        }
      },
      "provisioningState": "Succeeded",
      "resourceUid": null,
      "securityProfile": {
        "enableTpm": false,
        "securityType": null,
        "uefiSettings": {
          "secureBootEnabled": true
        }
      },
      "status": {
        "errorCode": "",
        "errorMessage": "",
        "powerState": "Running",
        "provisioningStatus": null
      },
      "storageProfile": {
        "dataDisks": [],
        "imageReference": {
          "id": "/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.AzureStackHCI/galleryImages/WinImage-26tdJUIS",
          "resourceGroup": "<Resource group name>"
        },
        "osDisk": {
          "id": null,
          "osType": "Windows"
        },
        "vmConfigStoragePathId": "/subscriptions/<Subscription ID>/resourceGroups/<Resource group name>/providers/Microsoft.AzureStackHCI/storageContainers/UserStorage2-guid"
      },
      "vmId": "<guid>"
    },
    "resourceGroup": "<Resource group name>",
    "systemData": {
      "createdAt": "2024-06-24T01:29:06.594266+00:00",
      "createdBy": "<guid>",
      "createdByType": "Application",
      "lastModifiedAt": "2024-06-24T18:35:18.206280+00:00",
      "lastModifiedBy": "<guid>",
      "lastModifiedByType": "Application"
    },
    "type": "microsoft.azurestackhci/virtualmachineinstances"
  }
}

更改本地帐户密码

按照以下步骤更改部署在 Azure 本地实例上的 Azure Arc VM 的本地帐户密码。 Windows 和 Linux VM 的步骤不同。

  1. 登录到 Azure Arc VM。

  2. 运行以下 Azure PowerShell 命令:

    # Define the username
    $username = "AccountName"
    
    # Prompt the user to enter the new password
    $newPassword = Read-Host -AsSecureString "Enter the new password for $username"
    
    # Prompt the user to re-enter the new password for verification
    $verifyPassword = Read-Host -AsSecureString "Re-enter the new password for verification"
    
    # Convert the secure strings to plain text for comparison
    $plainPassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($newPassword))
    $plainVerifyPassword = [Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($verifyPassword))
    
    # Check if the passwords match, and change the password if they match. Fail if the passwords don't match.
    if ($plainPassword -eq $plainVerifyPassword) {
        $account = [ADSI]"WinNT://./$username,user"
        $account.SetPassword($plainPassword)
        $account.SetInfo()
    
        Write-Host "Password for user $username has been reset successfully." -ForegroundColor Green
    } else {
        Write-Host "The passwords do not match. Please try again." -ForegroundColor Red
    }    
    

删除 VM

删除 VM 不会删除与 VM 关联的所有资源。 例如,它不会删除与 VM 关联的数据磁盘和网络接口。 需要单独查找和删除这些资源。

若要删除 VM,请在 Azure 门户中为 Azure 本地实例执行以下步骤:

  1. 转到 Azure 本地资源,然后转到 虚拟机

  2. 在虚拟机列表中,选择要从系统中删除的 VM。

  3. 在 VM 的 概述 页上,在命令栏上,选择 删除

  4. 系统会提示你确认该删除操作。 选择

    删除虚拟机时警告的屏幕截图。

  5. 转到部署此 VM 的资源组。 验证 VM 是否已从资源组中的资源列表中删除。

  6. 找到关联的资源,例如网络接口和数据磁盘,并删除它们。 可能需要选择 显示隐藏类型 查看与此 VM 关联的资源,这些资源未删除。

    与虚拟机关联的隐藏类型的资源的屏幕截图。

执行 Azure Arc VM 的实时迁移

通过本地工具(例如 故障转移群集管理器Windows Admin Center)支持跨 Azure 本地节点实时迁移 Azure Arc VM。 不支持实时迁移 VM 存储。

更改核心和内存

若要更改核心和内存,请在 Azure 门户中为 Azure 本地实例执行以下步骤:

  1. 转到你的 Azure 本地资源,然后转到 虚拟机

  2. 在 VM 列表中,选择并转到要修改其核心和内存的 VM。

  3. 在“设置”下,选择“大小” 。 编辑 虚拟处理器计数内存(MB) 值,以更改 VM 的核心或内存大小。 对于内存,只能更改大小。 创建 VM 后,无法更改内存类型。

    用于更改 VM 核心和内存大小的窗格的屏幕截图。