【问题标题】:Addition of a managed disk to a VM with blob based disks is not supported不支持将托管磁盘添加到具有基于 blob 的磁盘的 VM
【发布时间】:2019-04-13 12:31:35
【问题描述】:

我正在尝试使用以下 API 版本“2015-06-15”的 VM 从托管映像和数据磁盘部署 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"
            }

【问题讨论】:

    标签: azure deployment


    【解决方案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
        }
    ]
    

    【讨论】:

    • 我们在StorageAccountType中传入什么参数? [parameters('bossObject')] 我也是 ARM 模板和 Azure 的新手。提前致谢!
    • 或者抱歉,这只是帐户类型,例如 Standard_LRSPremium_LRS
    • 我确实输入了存储帐户类型,但它为操作系统和数据磁盘引发了错误“错误”:“消息”:“在“OSDisk”类型的对象上找不到成员“managedDisk”。路径 'properties.storageProfile.osDisk.managedDisk',第 1 行,位置 318。”,“目标”:“vm.properties.storageProfile.osDisk.managedDisk”{“消息”:“在对象上找不到成员 'managedDisk'输入“DataDisk”。路径“properties.storageProfile.dataDisks[0].managedDisk”,第 1 行,位置 625。”,“目标”:“vm.properties.storageProfile.dataDisks[0].managedDisk”
    • 你为 vm 资源使用的 api 版本是什么?尝试使用这个"2016-04-30-preview"
    • 使用“apiVersion”:“2015-06-15”,我确实尝试过这个“2016-04-30-preview”,但出现错误 New-AzureRmResourceGroupDeployment : 3:22:13 PM -资源 Microsoft.Storage/storageAccounts 'inflabimageslrs' 失败并显示消息'{“error”:{“code”:“NoRegisteredProviderFound”,“message”:“找不到位置 'canadaeast' 和 API 版本'2016-04-的注册资源提供程序- 'storageAccounts' 类型的 30-preview'。支持的 api 版本为 '2018-07-01、2018-03-01-preview、2018-02-01、2017-10-01、2017-06-01、2016 -12-01、2016-05-01、2016-01-01、2015-06-15、2015-05-01-预览'
    【解决方案2】:

    我能够通过使用图像引用而不是使用 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"
                }
            ]
          },
    

    【讨论】:

      猜你喜欢
      • 2020-04-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-01-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-03-17
      相关资源
      最近更新 更多