Azure 虛擬機器擴展集和連結的資料磁碟

若要擴充可用的儲存體,Azure 虛擬機器擴展集支援 VM 執行個體連結資料磁碟。 您可以在擴展集建立時連結資料磁碟,或將資料磁碟連結至現有擴展集。

建立及管理擴展集中的磁碟

如需深入了解如何建立具有連結資料磁碟的擴展集、準備和格式化,或新增和移除資料磁碟,請參閱下列其中一個教學課程:

本文的其餘部分將概述特定使用案例,例如需要資料磁碟的 Service Fabric 叢集,或是將包含內容的現有資料磁碟連結至擴展集。

使用連結的資料磁碟建立 Service Fabric 叢集

在 Azure 中執行之 Service Fabric 叢集中的每個節點類型都是由虛擬機器擴展集提供支援。 使用 Azure Resource Manager 範本,您可以將資料磁碟連結到構成 Service Fabric 叢集的擴展集。 您可使用現有範本作為起點。 在範本中,於 Microsoft.Compute/virtualMachineScaleSets 資源的 storageProfile 中包含 dataDisks 區段並部署範本。 下列範例會連結 128 GB 資料磁碟:

"dataDisks": [
    {
    "diskSizeGB": 128,
    "lun": 0,
    "createOption": "Empty"
    }
]

您可以在部署叢集時自動分割、格式化及掛接資料磁碟。 將自訂指令碼擴充新增至擴展集之 virtualMachineProfile的 extensionProfile

若要在 Windows 叢集中自動準備資料磁碟,請新增下列內容:

{
    "name": "customScript",
    "properties": {
        "publisher": "Microsoft.Compute",
        "type": "CustomScriptExtension",
        "typeHandlerVersion": "1.8",
        "autoUpgradeMinorVersion": true,
        "settings": {
        "fileUris": [
            "https://raw.githubusercontent.com/Azure-Samples/compute-automation-configurations/master/prepare_vm_disks.ps1"
        ],
        "commandToExecute": "powershell -ExecutionPolicy Unrestricted -File prepare_vm_disks.ps1"
        }
    }
}

若要在 Linux 叢集中自動準備資料磁碟,請新增下列內容:

{
    "name": "lapextension",
    "properties": {
        "publisher": "Microsoft.Azure.Extensions",
        "type": "CustomScript",
        "typeHandlerVersion": "2.0",
        "autoUpgradeMinorVersion": true,
        "settings": {
        "fileUris": [
            "https://raw.githubusercontent.com/Azure-Samples/compute-automation-configurations/master/prepare_vm_disks.sh"
        ],
        "commandToExecute": "bash prepare_vm_disks.sh"
        }
    }
}

將預先填入的資料磁碟新增至現存的擴展集

在擴展集模型中指定的資料磁碟一律是空的。 不過,您可以將現有資料磁碟連結至擴展集中的特定 VM。 如果您希望將資料傳播到擴展集中的所有 VM,您可以複製資料磁碟並將它連結至擴展集中的每個 VM,或建立包含資料的自訂映像並從此自訂映像佈建擴展集,您也可以使用 Azure 檔案服務或類似的資料儲存體供應項目。

其他注意事項

API 版本 2016-04-30-preview 或更新版本的 Microsoft.Compute API 中提供 Azure 受控磁碟和擴展集連結資料磁碟的支援。

Azure 入口網站對於擴展集中連結資料磁碟的支援有所限制。 視您的需求而定,您可以使用 Azure 範本、CLI、PowerShell、SDK 和 REST API 來管理連結磁碟。