【问题标题】:Azure ARM Template add second diskAzure ARM 模板添加第二个磁盘
【发布时间】:2016-07-06 05:59:22
【问题描述】:

我想为基于“userImageStorageAccountName”的第二个磁盘添加我的模板选项我的模板一直在工作,直到我尝试添加第二个磁盘然后当我尝试部署 Vm 时我收到:

Blockquote {"code":"StorageAccountAlreadyExists","message":"订阅下已存在名为 TEST 的存储帐户。"}}

但我的目标是在该存储帐户中创建我不想创建新的存储帐户

顺便说一句,您是否有一个很好的文档来为假人创建模板:D

{
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
"contentVersion": "0.0.4.0",
"parameters": {

    "VM_name": {
        "type": "string",
        "minLength": 11,
        "maxLength": 12,
        "defaultValue": "testxxx0021",
        "metadata": {
            "description": "Hostnem+dns name"
        }
    },
    "VM_Class": {
        "type": "string",
        "allowedValues": [
            "Standard_A1",
            "Standard_A2",
            "Standard_A3"
        ],
        "defaultValue": "Standard_A2",
        "metadata": {
            "description": "type VM"
        }

    },
    "sizeOfEachDataDiskInGB": {
        "type": "string",
        "defaultValue": "20",
        "metadata": {
            "description": "Size of each data disk in GB"
        }
    },


    "userImageStorageAccountName": {
        "type": "string",
        "defaultValue": "TEST",
        "metadata": {
            "description": "Storage account for machine"
        }
    },
    "Windows_template": {
        "type": "string",
        "allowedValues": [
            "https://TEST.blob.core.windows.net/system/Microsoft.Compute/Images/xxxxxxxx/template-dddosDisk.vhd",
            "https://TEST.blob.core.windows.net/testtemp/xxxxxxx.vhd",
            "https://TEST.blob.core.windows.net/testtemp/template-xxxxx.vhd"
        ],
        "defaultValue": "https://TEST.blob.core.windows.net/TESTtemp/template-xxxxxxxxx.vhd",
        "metadata": {
            "description": "Uri of the your user image"
        }


    },
    "adminUserName": {
        "type": "securestring",
        "defaultValue": "testadmin",
        "metadata": {
            "description": "UserName for the Virtual Machine"
        }

    },
    "adminPassword": {
        "type": "securestring",

        "metadata": {
            "description": "Password for the Virtual Machine"
        }
    },
    "osType": {
        "type": "string",
        "allowedValues": [
            "Windows",
            "Linux"
        ],
        "defaultValue": "Windows",

        "metadata": {
            "description": "This is the OS that your VM will be running"
        }
    }

},
"variables": {
    "location": "[resourceGroup().location]",
    "vmName": "[parameters('VM_name')]",
    "virtualNetworkName": "xx.xxx.xxx.0-xx-vnet",
    "nicName": "[parameters('VM_name')]",
    "addressPrefix": "xx.xxx.xxx.0/22",
    "subnet1Name": "xx.xxx.xxx.0-xx-vnet",
    "subnet1Prefix": "xx.xxx.xxx.0/24",
    "vmStorageAccountContainerName": "vhds",
    "storageAccountType": "Standard_LRS",
    "storageAccountName": "[parameters('userImageStorageAccountName')]",
    "vnetID": "[resourceId('Microsoft.Network/virtualNetworks',variables('virtualNetworkName'))]",
    "subnet1Ref": "[concat(variables('vnetID'),'/subnets/',variables('subnet1Name'))]",
    "osDiskVhdName": "[concat('http://',parameters('userImageStorageAccountName'),'.blob.core.windows.net/vhds/',variables('vmName'),'osDisk.vhd')]",
    "apiVersion": "2015-06-15",
     "dataDisk1VhdName": "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('vmName'),'dataDisk1.vhd')]"
},
"resources": [

    {
        "type": "Microsoft.Storage/storageAccounts",
        "name": "[variables('storageAccountName')]",
        "apiVersion": "[variables('apiVersion')]",
        "location": "[variables('location')]",
        "properties": {
            "accountType": "[variables('storageAccountType')]"
        }
    },
    {
        "apiVersion": "[variables('apiVersion')]",
        "type": "Microsoft.Network/virtualNetworks",
        "name": "[variables('virtualNetworkName')]",
        "location": "[variables('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": "[variables('location')]",
        "dependsOn": [

            "[concat('Microsoft.Network/virtualNetworks/', variables('virtualNetworkName'))]"
        ],
        "properties": {
            "ipConfigurations": [
                {
                    "name": "ipconfig1",
                    "properties": {
                        "privateIPAllocationMethod": "Dynamic",

                        "subnet": {
                            "id": "[variables('subnet1Ref')]"
                        }
                    }
                }
            ]
        }
    },
    {
        "apiVersion": "[variables('apiVersion')]",
        "type": "Microsoft.Compute/virtualMachines",
        "name": "[variables('vmName')]",
        "location": "[variables('location')]",
        "dependsOn": [

            "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]"
        ],
        "properties": {
            "hardwareProfile": {
                "vmSize": "[parameters('VM_Class')]"
            },

            "osProfile": {
                "computerName": "[variables('vmName')]",
                "adminUsername": "[parameters('adminUsername')]",
                "adminPassword": "[parameters('adminPassword')]"
            },
            "storageProfile": {
                "osDisk": {
                    "name": "[concat(variables('vmName'),'-osDisk')]",
                    "osType": "[parameters('osType')]",
                    "caching": "ReadWrite",
                    "createOption": "FromImage",
                    "image": {
                        "uri": "[parameters('Windows_template')]"
                    },
                    "vhd": {
                        "uri": "[variables('osDiskVhdName')]"
                    }
                }
            },

            "dataDisks": [
                {
                    "name": "datadisk1",
                    "diskSizeGB": "[parameters('sizeOfEachDataDiskInGB')]",
                    "lun": 0,
                    "vhd": {
                        "Uri": "[variables('dataDisk1VhdName')]"
                    },
                    "createOption": "Empty"
                }
            ],
            "networkProfile": {
                "networkInterfaces": [
                    {
                        "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
                    }
                ]
            },
            "diagnosticsProfile": {
                "bootDiagnostics": {
                    "enabled": "true",
                    "storageUri": "[concat('http://',parameters('userImageStorageAccountName'),'.blob.core.windows.net')]"
                }
            }
        }
    }
]
    }

感谢帮助

【问题讨论】:

  • 我对@9​​87654321@ 问题的回答可能对文档位有所帮助(虽然不多,因为 Azure 文档很糟糕;))-我正在考虑您的实际问题!

标签: json templates azure


【解决方案1】:

查看 JSON,您正在请求平台要求用户提供新的存储帐户。要使用现有的存储帐户,您可以参考您已经提供的现有参数。

原始 JSON:

"dataDisk1VhdName": "[concat('http://',variables('storageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('vmName'),'dataDisk1.vhd')]"

建议的 JSON

"dataDisk1VhdName": "[concat('http://',parameters('userImageStorageAccountName'),'.blob.core.windows.net/',variables('vmStorageAccountContainerName'),'/',variables('vmName'),'dataDisk1.vhd')]"

希望这会有所帮助。

【讨论】:

  • 还是同样的错误 {"error":{"code":"StorageAccountAlreadyExists","message":"订阅下已经存在名为 fiodwtemp 的存储帐户。"}}
【解决方案2】:

检查存储帐户标签是否已被其他人通过 Azure/PowerShell 门户更改,是否与 ARM 模板上指定的标签不同。

听起来像是 ARM 部署系统上的一个错误,标签应该可以更新,但目前存储帐户资源失败。

欲了解更多信息,请参阅http://davidjrh.intelequia.com/2016/07/the-storage-account-already-exists.html

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-04-18
    • 2017-05-24
    • 2020-06-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-01-29
    • 1970-01-01
    相关资源
    最近更新 更多