共用方式為


管理 Azure 本機上的 Arc VM

適用於:Azure Local 2311.2 和更新版本

本文說明如何管理在 Azure 本機版本 23H2 上執行的 Azure Arc 虛擬機(VM)。 其涵蓋程序以啟用來賓管理,並啟動、停止、重新啟動、暫停、儲存及刪除 Azure Arc VM。

必要條件

  • 存取已部署和註冊的 Azure 本機實例。 Azure 本機實例的部署包括建立 Azure Arc 資源網橋和自定義位置。

    移至 Azure 中的資源群組。 顯示的資訊包括為本地 Azure 環境建立的自訂位置和 Azure Arc 資源橋接器。 記下訂用帳戶、資源群組和自定義位置。 您稍後會在此案例中使用它們。

  • 在 Azure 本地執行個體上運行的一或多個 Azure Arc 虛擬機器。 如需詳細資訊,請參閱 在 Azure 本機上建立 Azure Arc 虛擬機。

啟用客體管理

請務必瞭解客體管理內容中的兩個代理程式:VM 客體代理程式和 Azure 連線機器代理程式。 透過 Azure 入口網站或 Azure CLI 所建立的每個 Azure Arc VM 都會佈建並安裝一個客體代理程式(也稱為 mocguestagent)。

當您在 Azure Arc VM 上啟用客體管理時,客體代理程式會安裝 Azure Connected Machine 代理程式。 您可以使用 Azure Connected Machine 代理程式來管理 VM 上的 Azure Arc VM 擴充功能。

以下是您在配置 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>"
    

    以下是範例輸出的代碼段,指出客體代理程式正在執行。 在輸出中尋找 statusesvmAgent 底下。

    "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. 執行下列其中一個命令,以根據OS類型在您的 VM 上啟用客體代理程式。

    針對 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 之後,您可以稍後再繼續。

  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 訂用帳戶的名稱或標識碼。 您可以使用 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 以恢復其暫停狀態。

    #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 訂用帳戶的名稱或標識碼。 您可以使用 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 的即時移轉

透過內部部署工具支援跨 Azure 本機節點的 Azure Arc VM 實時移轉,例如 故障轉移叢集管理員Windows Admin Center。 不支援 VM 記憶體的即時移轉。

變更核心和記憶體

若要變更核心和記憶體,請遵循 Azure 入口網站中 Azure 本機實例的下列步驟:

  1. 前往您的 Azure 本機資源,然後前往 虛擬機

  2. 在 VM 清單中,選取並移至您要修改其核心和記憶體的 VM。

  3. 在 [設定] 下方,選取 [大小]。 編輯 虛擬處理器計數記憶體 (MB) 值,以變更 VM 的核心或記憶體大小。 針對記憶體,只能變更大小。 建立 VM 之後,您無法變更記憶體類型。

    變更 VM 核心和記憶體大小的窗格螢幕快照。