不支持将托管磁盘添加到具有基于Blob的磁盘的VM

时间:2018-11-09 22:40:47

标签: azure deployment

我正在尝试使用以下API和版本“ 2015-06-15”从托管映像和数据磁盘部署VM。在ARM模板下运行时,无法将数据磁盘连接到VM。我也尝试了预览,但是预览API版本不支持存储帐户。在尝试预览API版本和最新版本时,我对此发表了评论。

            {
                "$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
                "contentVersion": "1.0.0.0",
                "parameters": {
                    "customVmName": {
                    "type": "string",
                    "metadata": {
                      "description": "This is the name of the your VM"
                    }
                  },
                  "osDiskVhdUri": {
                    "type": "string",
                    "metadata": {
                      "description": "Uri of the your user image"
                    }
                  },      
                  "adminUserName": {
                    "type": "string",
                    "metadata": {
                      "description": "User Name for the Virtual Machine"
                    }
                  },
                  "adminPassword": {
                    "type": "securestring",
                    "metadata": {
                      "description": "Password for the Virtual Machine"
                    }
                  },
                  "userImageStorageAccountName": {
                    "type": "string",
                    "metadata": {
                      "description": "This is the name of the your storage account"
                    }
                  },
                  "osType": {
                    "type": "string",
                    "allowedValues": [
                      "Windows",
                      "Linux"
                    ],
                    "metadata": {
                      "description": "This is the OS that your VM will be running"
                    }
                  },
                  "vmSize": {
                    "type": "string",
                    "metadata": {
                      "description": "This is the size of your VM"
                    }
                  },
                  "ExistingVnet": {
                    "allowedValues": [ "new", "existing" ],
                    "type": "string",
                    "metadata": {
                      "description":  "Select if this template needs a new VNet or will reference an existing VNet"
                    }
                  },
                  "ExistingVnetName": {
                    "type": "string",
                    "defaultValue": "",
                    "metadata": {
                      "description": "New or Existing VNet Name"
                    }
                  },
                  "ExistingSubnetName": {
                    "type": "string",
                    "defaultValue": "subnet",
                    "metadata": {
                      "description": "Subnet Name"
                    }
                  },
                  "existingdiagnosticsStorageAccountName": {
                    "type": "string"
                  }
                },
                "variables": {
                  "vmName": "[parameters('customVmName')]",
                  "nicName": "[parameters('customVmName')]",
                  "apiVersion": "2015-06-15",
                  "vnetID": "[resourceId('ISE-MarkW', 'Microsoft.Network/virtualNetworks', parameters('ExistingVnetName'))]",
                  "subnetRef": "[concat(variables('vnetID'),'/subnets/', parameters('ExistingSubnetName'))]",
              },
                "resources": [
                    {
                    "apiVersion": "2016-06-01",
                    "type": "Microsoft.Network/networkInterfaces",
                    "name": "[variables('nicName')]",
                    "location": "[resourceGroup().location]",
                    "properties": {
                      "ipConfigurations": [
                        {
                          "name": "ipconfig1",
                          "properties": {
                            "privateIPAllocationMethod": "Dynamic",
                            "subnet": {
                              "id": "[variables('subnetRef')]"
                            }
                          }
                        }
                      ]
                    }
                  },
                  {
                    "type": "Microsoft.Compute/disks",
                    "name": "[concat(variables('vmName'),'-datadisk1')]",
                    "apiVersion": "2017-03-30",
                    "location": "[resourceGroup().location]",
                    "sku": {
                        "name": "Premium_LRS"
                    },
                    "properties": {
                        "creationData": {
                            "createOption": "Empty"
                        },
                        "diskSizeGB": 128
                    }
                },
                  {
                    "apiVersion": "[variables('apiVersion')]",
                    "type": "Microsoft.Compute/virtualMachines",
                    "name": "[variables('vmName')]",
                    "location": "[resourceGroup().location]",
                    "dependsOn": [
                      "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]",
                      "[resourceId('Microsoft.Compute/disks/', concat(variables('vmName'),'-datadisk1'))]"
                    ],
                    "properties": {
                      "hardwareProfile": {
                        "vmSize": "[parameters('vmSize')]"
                      },
                      "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('osDiskVhdUri')]"
                          },
                          "vhd": {
                            "uri": "[concat(reference(concat('/subscriptions/xxxx/resourceGroups/inflabimages-rg/providers/Microsoft.Storage/storageAccounts/', parameters('userImageStorageAccountName')), variables('apiVersion')).primaryEndpoints.blob, 'vhds/',variables('vmName'), uniquestring(resourceGroup().id), 'osDisk.vhd')]"
                          }
                        },
                        "dataDisks": [
                            {
                              "lun": 0,
                              "name": "[concat(variables('vmName'),'-datadisk1')]",
                              "createOption": "Attach",
                              "managedDisk": {
                                "id": "[resourceId('Microsoft.Compute/disks/', concat(variables('vmName'),'-datadisk1'))]"
                            },
                              "caching": "ReadWrite"
                            }
                        ]
                      },  
                      "networkProfile": {
                        "networkInterfaces": [
                          {
                            "id": "[resourceId('Microsoft.Network/networkInterfaces',variables('nicName'))]"
                          }
                        ]
                      },
                      "diagnosticsProfile": {
                        "bootDiagnostics": {
                          "enabled": true,
                          "storageUri": "[concat('http://', parameters('existingdiagnosticsStorageAccountName'), '.blob.core.windows.net')]"
                        }
                      }
                    }
                  }
                ]
              }

消息

下显示我的VM部署失败
            "error": {
                    "code": "OperationNotAllowed",
                    "message": "Addition of a managed disk to a VM with blob based disks is not supported.",
                    "target": "dataDisk"
            }

2 个答案:

答案 0 :(得分:1)

您未将托管磁盘用作OS磁盘,将示例磁盘与数据磁盘结合使用:

"imageReference": {
    "id": "[resourceId('Microsoft.Compute/images', variables('imageName'))]"
},
"osDisk": {
    "createOption": "FromImage",
    "managedDisk": {
        "storageAccountType": "Standard_LRS"
    }
},
"dataDisks": [
    {
        "lun": 2,
        "createOption": "Empty",
        "caching": "None",
        "managedDisk": {
            "storageAccountType": "Standard_LRS"
        },
        "diskSizeGB": 128
    }
]

答案 1 :(得分:0)

我能够通过使用图像引用而不是在API版本为2018-06-01的VHD URI上附加数据磁盘。

      {
    "apiVersion": "[variables('apiVersion')]",
    "type": "Microsoft.Compute/virtualMachines",
    "name": "[variables('vmName')]",
    "location": "[resourceGroup().location]",
    "dependsOn": [
      "[concat('Microsoft.Network/networkInterfaces/', variables('nicName'))]",
      "[resourceId('Microsoft.Compute/disks/', concat(variables('vmName'),'-datadisk1'))]"
    ],
    "properties": {
        "availabilitySet": {
            "id": "[resourceId('Microsoft.Compute/availabilitySets', parameters('availabilitySets_name'))]"
        },
      "hardwareProfile": {
        "vmSize": "[parameters('vmSize')]"
      },
      "osProfile": {
        "computerName": "[variables('vmName')]",
        "adminUsername": "[parameters('adminUsername')]",
        "adminPassword": "[parameters('adminPassword')]"
      },
      "storageProfile": {
        "imageReference": {
            "id": "[parameters('virtualMachines_image')]"
        },
        "osDisk": {
          "name": "[concat(variables('vmName'),'-osDisk')]",
          "osType": "[parameters('osType')]",
          "caching": "ReadWrite",
          "createOption": "FromImage",
        "managedDisk": {
            "storageAccountType":"Premium_LRS"
        }
        },
        "dataDisks": [
            {
              "lun": 1,
              "name": "[concat(variables('vmName'),'-datadisk1')]",
              "createOption": "Attach",
              "managedDisk": {
                "id": "[resourceId('Microsoft.Compute/disks/', concat(variables('vmName'),'-datadisk1'))]",
                "storageAccountType":"Premium_LRS"
            },
              "caching": "None"
            }
        ]
      },