Azure模板,用于创建在多个存储帐户中具有磁盘的虚拟机

时间:2016-09-05 09:53:41

标签: azure virtual-machine

我需要创建具有多个存储帐户的虚拟机,以便安装多个磁盘。由于在使用当前模板时绑定到单个存储帐户,因此系统大小存在实际限制。存储帐户的带宽限制为5GB / s。

如果有人知道该怎么做或指针真的很有用。 TIA

1 个答案:

答案 0 :(得分:1)

我还没有测试过,但是长模板配方基于Azure quickstart template "Create a Virtual Machine from a Windows Image with 4 Empty Data Disks"

{
    "$schema" : "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
    "contentVersion" : "1.0.0.0",
    "parameters" : {
        "dnsLabelPrefix" : {
            "type" : "string",
            "metadata" : {
                "description" : "Unique DNS Name for the Storage Account where the Virtual Machine's disks will be placed."
            }
        },
        "adminUsername" : {
            "type" : "string",
            "metadata" : {
                "description" : "Username for the Virtual Machine."
            }
        },
        "adminPassword" : {
            "type" : "securestring",
            "metadata" : {
                "description" : "Password for the Virtual Machine."
            }
        },
        "vmSize" : {
            "type" : "string",
            "metadata" : {
                "description" : "Size of VM"
            }
        },
        "sizeOfEachDataDiskInGB" : {
            "type" : "string",
            "metadata" : {
                "description" : "Size of each data disk in GB"
            }
        }
    },
    "variables" : {
        "storageAccountName" : "[concat(uniquestring(resourceGroup().id), 'saddiskvm')]",
        "storageAccountNameDisk1" : "[concat(uniquestring(resourceGroup().id), 'saddiskvm1')]",
        "storageAccountNameDisk2" : "[concat(uniquestring(resourceGroup().id), 'saddiskvm2')]",
        "storageAccountNameDisk3" : "[concat(uniquestring(resourceGroup().id), 'saddiskvm3')]",
        "storageAccountNameDisk4" : "[concat(uniquestring(resourceGroup().id), 'saddiskvm4')]",
        "addressPrefix" : "10.0.0.0/16",
        "subnet1Name" : "Subnet-1",
        "subnet1Prefix" : "10.0.0.0/24",
        "vmStorageAccountContainerName" : "vhds",
        "imagePublisher" : "MicrosoftWindowsServer",
        "imageOffer" : "WindowsServer",
        "imageSKU" : "2012-Datacenter",
        "imageVersion" : "latest",
        "publicIPAddressName" : "myPublicIP",
        "publicIPAddressType" : "Dynamic",
        "storageAccountType" : "Standard_LRS",
        "virtualNetworkName" : "myVNET",
        "vmName" : "myVM",
        "vnetID" : "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
        "nicName" : "myNIC",
        "subnet1Ref" : "[concat(variables('vnetID'),'/subnets/',variables('subnet1Name'))]",
        "apiVersion" : "2015-06-15"
    },
    "resources" : [{
            "type" : "Microsoft.Storage/storageAccounts",
            "name" : "[variables('storageAccountName')]",
            "apiVersion" : "[variables('apiVersion')]",
            "location" : "[resourceGroup().location]",
            "properties" : {
                "accountType" : "[variables('storageAccountType')]"
            }
        },{
            "type" : "Microsoft.Storage/storageAccounts",
            "name" : "[variables('storageAccountNameDisk1')]",
            "apiVersion" : "[variables('apiVersion')]",
            "location" : "[resourceGroup().location]",
            "properties" : {
                "accountType" : "[variables('storageAccountType')]"
            }
        },{
            "type" : "Microsoft.Storage/storageAccounts",
            "name" : "[variables('storageAccountNameDisk2')]",
            "apiVersion" : "[variables('apiVersion')]",
            "location" : "[resourceGroup().location]",
            "properties" : {
                "accountType" : "[variables('storageAccountType')]"
            }
        },{
            "type" : "Microsoft.Storage/storageAccounts",
            "name" : "[variables('storageAccountNameDisk3')]",
            "apiVersion" : "[variables('apiVersion')]",
            "location" : "[resourceGroup().location]",
            "properties" : {
                "accountType" : "[variables('storageAccountType')]"
            }
        },{
            "type" : "Microsoft.Storage/storageAccounts",
            "name" : "[variables('storageAccountNameDisk4')]",
            "apiVersion" : "[variables('apiVersion')]",
            "location" : "[resourceGroup().location]",
            "properties" : {
                "accountType" : "[variables('storageAccountType')]"
            }
        }, {
            "apiVersion" : "[variables('apiVersion')]",
            "type" : "Microsoft.Network/publicIPAddresses",
            "name" : "[variables('publicIPAddressName')]",
            "location" : "[resourceGroup().location]",
            "properties" : {
                "publicIPAllocationMethod" : "[variables('publicIPAddressType')]",
                "dnsSettings" : {
                    "domainNameLabel" : "[parameters('dnsLabelPrefix')]"
                }
            }
        }, {
            "apiVersion" : "[variables('apiVersion')]",
            "type" : "Microsoft.Network/virtualNetworks",
            "name" : "[variables('virtualNetworkName')]",
            "location" : "[resourceGroup().location]",
            "properties" : {
                "addressSpace" : {
                    "addressPrefixes" : [
                        "[variables('addressPrefix')]"
                    ]
                },
                "subnets" : [{
                        "name" : "[variables('subnet1Name')]",
                        "properties" : {
                            "addressPrefix" : "[variables('subnet1Prefix')]"
                        }
                    }
                ]
            }
        }, {
            "apiVersion" : "[variables('apiVersion')]",
            "type" : "Microsoft.Network/networkInterfaces",
            "name" : "[variables('nicName')]",
            "location" : "[resourceGroup().location]",
            "dependsOn" : [
                "[concat('Microsoft.Network/publicIPAddresses/', variables('publicIPAddressName'))]",
                "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
            ],
            "properties" : {
                "ipConfigurations" : [{
                        "name" : "ipconfig1",
                        "properties" : {
                            "privateIPAllocationMethod" : "Dynamic",
                            "publicIPAddress" : {
                                "id" : "[resourceId('Microsoft.Network/publicIPAddresses',variables('publicIPAddressName'))]"
                            },
                            "subnet" : {
                                "id" : "[variables('subnet1Ref')]"
                            }
                        }
                    }
                ]
            }
        }, {
            "apiVersion" : "2015-06-15",
            "type" : "Microsoft.Compute/virtualMachines",
            "name" : "[variables('vmName')]",
            "location" : "[resourceGroup().location]",
            "dependsOn" : [
                "[concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName'))]",
                "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
            ],
            "properties" : {
                "hardwareProfile" : {
                    "vmSize" : "[parameters('vmSize')]"
                },
                "osProfile" : {
                    "computerName" : "[variables('vmName')]",
                    "adminUsername" : "[parameters('adminUsername')]",
                    "adminPassword" : "[parameters('adminPassword')]"
                },
                "storageProfile" : {
                    "imageReference" : {
                        "publisher" : "[variables('imagePublisher')]",
                        "offer" : "[variables('imageOffer')]",
                        "sku" : "[variables('imageSKU')]",
                        "version" : "[variables('imageVersion')]"
                    },
                    "dataDisks" : [{
                            "name" : "datadisk1",
                            "diskSizeGB" : "[parameters('sizeOfEachDataDiskInGB')]",
                            "lun" : 0,
                            "vhd" : {
                                "uri" : "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountNameDisk1')), variables('apiVersion')).primaryEndpoints.blob, variables('vmStorageAccountContainerName'),'/',variables('vmName'),'dataDisk1.vhd')]"
                            },
                            "createOption" : "Empty"
                        }, {
                            "name" : "datadisk2",
                            "diskSizeGB" : "[parameters('sizeOfEachDataDiskInGB')]",
                            "lun" : 1,
                            "vhd" : {
                                "uri" : "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountNameDisk2')), variables('apiVersion')).primaryEndpoints.blob, variables('vmStorageAccountContainerName'),'/',variables('vmName'),'dataDisk2.vhd')]"
                            },
                            "createOption" : "Empty"
                        }, {
                            "name" : "datadisk3",
                            "diskSizeGB" : "[parameters('sizeOfEachDataDiskInGB')]",
                            "lun" : 2,
                            "vhd" : {
                                "uri" : "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountNameDisk3')), variables('apiVersion')).primaryEndpoints.blob, variables('vmStorageAccountContainerName'),'/',variables('vmName'),'dataDisk3.vhd')]"
                            },
                            "createOption" : "Empty"
                        }, {
                            "name" : "datadisk4",
                            "diskSizeGB" : "[parameters('sizeOfEachDataDiskInGB')]",
                            "lun" : 3,
                            "vhd" : {
                                "uri" : "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountNameDisk4')), variables('apiVersion')).primaryEndpoints.blob, variables('vmStorageAccountContainerName'),'/',variables('vmName'),'dataDisk4.vhd')]"
                            },
                            "createOption" : "Empty"
                        }
                    ],
                    "osDisk" : {
                        "name" : "osdisk1",
                        "vhd" : {
                            "uri" : "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName')), variables('apiVersion')).primaryEndpoints.blob, variables('vmStorageAccountContainerName'),'/','osDisk1.vhd')]"
                        },
                        "caching" : "ReadWrite",
                        "createOption" : "FromImage"
                    }
                },
                "networkProfile" : {
                    "networkInterfaces" : [{
                            "id" : "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
                        }
                    ]
                },
                "diagnosticsProfile" : {
                    "bootDiagnostics" : {
                        "enabled" : "true",
                        "storageUri" : "[concat(reference(concat('Microsoft.Storage/storageAccounts/', variables('storageAccountName')), variables('apiVersion')).primaryEndpoints.blob)]"
                    }
                }
            }
        }
    ]
}

在原始模板中,我将"variables" storageAccountNameDisk1添加到storageAccountNameDisk4,将其添加到"resources"进行创建,并将"dataDisk"从单个存储修改为多个存储帐户。

*提示:以下说明是在Azure门户中添加磁盘。

您可以轻松地在门户中向虚拟机添加磁盘。磁盘可以放在不同的存储帐户中。

请从左到右查看每个刀片中的红色复选标记。

enter image description here