Muokkaa

Jaa


Azure Virtual Machine Scale Sets and attached data disks

To expand your available storage, Azure Virtual Machine Scale Sets support VM instances with attached data disks. You can attach data disks when the scale set is created, or to an existing scale set.

Create and manage disks in a scale set

For detailed information on how to create a scale set with attached data disks, prepare and format, or add and remove data disks, see one of the following tutorials:

The rest of this article outlines specific use cases such as Service Fabric clusters that require data disks, or attaching existing data disks with content to a scale set.

Create a Service Fabric cluster with attached data disks

Each node type in a Service Fabric cluster running in Azure is backed by a Virtual Machine Scale Set. Using an Azure Resource Manager template, you can attach data disks to the scale set(s) that make up the Service Fabric cluster. You can use an existing template as a starting point. In the template, include a dataDisks section in the storageProfile of the Microsoft.Compute/virtualMachineScaleSets resource(s) and deploy the template. The following example attaches a 128 GB data disk:

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

You can automatically partition, format, and mount the data disks when the cluster is deployed. Add a custom script extension to the extensionProfile of the virtualMachineProfile of the scale set(s).

To automatically prepare the data disk(s) in a Windows cluster, add the following:

{
    "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"
        }
    }
}

To automatically prepare the data disk(s) in a Linux cluster, add the following:

{
    "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"
        }
    }
}

Adding pre-populated data disks to an existing scale set

Data disks specified in the scale set model are always empty. However, you may attach an existing data disk to a specific VM in a scale set. If you wish to propagate data across all VMs in the scale set, you may duplicate your data disk and attach it to each VM in the scale set, or create a custom image that contains the data and provision the scale set from this custom image, or you may use Azure Files or a similar data storage offering.

Additional notes

Support for Azure Managed disks and scale set attached data disks is available in API version 2016-04-30-preview or later of the Microsoft.Compute API.

Azure portal support for attached data disks in scale sets is limited. Depending on your requirements you can use Azure templates, CLI, PowerShell, SDKs, and REST API to manage attached disks.