共用方式為


建立 Azure 儲存路徑

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

本文說明如何為 Azure 本機實例上所使用的 VM 映射建立記憶體路徑。 記憶體路徑是 Azure 資源,可用來提供在您的系統上儲存 VM 組態檔、VM 映像和 VHD 的路徑。 您可以使用 Azure CLI 或 Azure 入口網站來建立記憶體路徑。

關於記憶體路徑

部署 Azure Local 環境時,儲存路徑會作為部署過程的一部分被建立。 預設選項會自動選取具有高可用性的記憶體路徑。 不過,您可能決定使用特定的記憶體路徑。 在此情況下,請確定指定的儲存路徑有足夠的儲存空間。

Azure 本機上的記憶體路徑應該指向系統上所有機器都可以存取的叢集共用磁碟區。 為了具有高可用性,強烈建議您在叢集共用磁碟區下建立記憶體路徑。

叢集共用磁碟區中的可用空間會決定儲存路徑上可用的存放區大小。 例如,如果儲存路徑是 C:\ClusterStorage\UserStorage_1\Volume01,而 Volume01 是 4 TB,那麼儲存路徑的大小是 Volume01 上的可用空間(在 4 TB 的限制內)。

必要條件

開始之前,請確定已符合下列先決條件:

  1. 請確定完成 Azure 本機需求

  2. 請確定叢集共用磁碟區存在於您的 Azure 本機上,可從系統中的所有機器存取。 您想要在叢集共用磁碟區上提供的記憶體路徑應該有足夠的空間來儲存 VM 映像。 根據預設,叢集共用磁碟區會在 Azure Local 部署期間建立。

    您只能在系統中提供的叢集共用磁碟區內建立記憶體路徑。 如需詳細資訊,請參閱 建立叢集共用磁碟區

在您的系統上建立記憶體路徑

您可以使用 Azure CLI 或 Azure 入口網站,在您的系統上建立記憶體路徑。

您可以使用 stack-hci-vm storagepath Cmdlet 來建立、顯示及列出 Azure 本機上的記憶體路徑。

檢閱用來建立記憶體路徑的參數

當您建立記憶體路徑時,需要下列參數

參數 描述:
name 您為 Azure 本機建立的儲存路徑名稱。 請務必提供遵循 Azure 資源規則的名稱。 您無法在建立記憶體路徑之後重新命名。
資源群組 您在其中建立記憶體路徑的資源群組名稱。 為了方便管理,我們建議您使用與 Azure 本機相同的資源群組。
訂閱 您部署 Azure 本地的訂閱名稱或 ID。 這也可能是您用於 Azure 本機記憶體路徑的另一個訂用帳戶。
自定義位置 與您建立此儲存路徑的 Azure 本地相關聯的自定位置名稱或識別碼。
path 磁碟上的路徑用於建立儲存路徑。 選取的路徑應該有足夠的空間可供儲存 VM 映像。

您也可以使用下列 選擇性 參數:

參數 描述:
位置 Azure 區域,如 az locations 所指定。

建立記憶體路徑

在 Azure 本機實例的其中一部機器上遵循下列步驟來建立記憶體路徑:

登入並設定訂用帳戶

  1. 連線到您的 Azure 本機上的機器

  2. 登入。 類型:

    az login --use-device-code
    
  3. 設定您的訂用帳戶。

    az account set --subscription <Subscription ID>
    

設定參數

  1. 為您的訂用帳戶、資源群組、位置、映像的OS類型設定參數。 將< >替換為適當的值。

    $storagepathname="<Storage path name>"
    $path="<Path on the disk to cluster shared volume>"
    $subscription="<Subscription ID>"
    $resource_group="<Resource group name>"
    $customLocName="<Custom location of your Azure Local>"
    $customLocationID="/subscriptions/<Subscription ID>/resourceGroups/$resource_group/providers/Microsoft.ExtendedLocation/customLocations/$customLocName"
    $location="<Azure region where the system is deployed>"
    
  2. 在下列路徑建立記憶體路徑 test-storagepathC:\ClusterStorage\test-storagepath。 執行以下 cmdlet:

    az stack-hci-vm storagepath create --resource-group $resource_group --custom-location $customLocationID --name $storagepathname --path $path
    

    如需此 Cmdlet 的詳細資訊,請參閱 az stack-hci-vm storagepath create

    以下是範例輸出:

    PS C:\windows\system32> $storagepathname="test-storagepath"
    PS C:\windows\system32> $path="C:\ClusterStorage\UserStorage_1\mypath"
    PS C:\windows\system32> $subscription="<Subscription ID>"
    PS C:\windows\system32> $resource_group="mylocal-rg"
    PS C:\windows\system32> $customLocationID="/subscriptions/<Subscription ID>/resourceGroups/mylocal-rg/providers/Microsoft.ExtendedLocation/customLocations/mylocal-cl"
    
    PS C:\windows\system32> az stack-hci-vm storagepath create --name $storagepathname --resource-group $resource_group --custom-location $customLocationID --path $path
    Command group 'stack-hci-vm' is experimental and under development. Reference and support levels: https://aka.ms/CLI_refstatus
    {
      "extendedLocation": {
        "name": "/subscriptions/<Subscription ID>/resourceGroups/mylocal-rg/providers/Microsoft.ExtendedLocation/customLocations/mylocal-cl",
        "type": "CustomLocation"
      },
      "id": "/subscriptions/<Subscription ID>/resourceGroups/mylocal-rg/providers/Microsoft.AzureStackHCI/storagecontainers/test-storagepath",
      "location": "eastus",
      "name": "test-storagepath",
      "properties": {
        "path": "C:\\ClusterStorage\\UserStorage_1\\mypath",
        "provisioningState": "Succeeded",
        "status": {
          "availableSizeMB": 36761,
          "containerSizeMB": 243097
        }
      },
      "resourceGroup": "mylocal-rg",
      "systemData": {
        "createdAt": "2023-10-06T04:45:30.458242+00:00",
        "createdBy": "guspinto@contoso.com",
        "createdByType": "User",
        "lastModifiedAt": "2023-10-06T04:45:57.386895+00:00",
        "lastModifiedBy": "319f651f-7ddb-4fc6-9857-7aef9250bd05",
        "lastModifiedByType": "Application"
      },
      "tags": null,
      "type": "microsoft.azurestackhci/storagecontainers"
    }
    

記憶體路徑建立完成後,您就可以建立虛擬機映像。

刪除記憶體路徑

如果不需要記憶體路徑,您可以將其刪除。 若要刪除記憶體路徑,請先移除相關聯的工作負載,然後執行下列命令來刪除記憶體路徑:

az stack-hci-vm storagepath delete --resource-group "<resource group name>" --name "<storagepath name>" --yes

若要確認記憶體路徑已刪除,請執行下列命令:

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

您會收到記憶體路徑不存在的通知。

若要刪除磁碟區,請先移除相關聯的工作負載,然後移除記憶體路徑,然後刪除磁碟區。 如需詳細資訊,請參閱 刪除磁碟區

如果記憶體路徑的空間不足,則使用該記憶體路徑的 VM 布建將會失敗。 您可能需要擴展與儲存路徑相關聯的磁碟區。 如需詳細資訊,請參閱 擴展磁碟區

若要針對嘗試刪除記憶體路徑時發生的任何錯誤進行疑難解答,請參閱 刪除記憶體路徑失敗。

下一步