使用JSON复制磁盘时出错-循环中无效的disk.name

时间:2019-01-27 16:47:40

标签: json azure powershell

我正在尝试创建一个ARM模板,该模板将遍历某些磁盘并进行复制,但是却出现磁盘名称无效的错误。我希望有人可以阐明我要去哪里。

错误:

`New-AzureRmResourceGroupDeployment : 16:38:35 - Resource Microsoft.Compute/disks 'parameters('newDataDisk2')' failed with message '{
  "error": {
    "code": "InvalidParameter",
    "message": "The value of parameter disk.name is invalid.",
    "target": "disk.name"
  }
}'
At line:1 char:1
+ New-AzureRmResourceGroupDeployment -Name "RenameDisks" -ResourceGroup ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet

New-AzureRmResourceGroupDeployment : 16:38:35 - Resource Microsoft.Compute/disks 'parameters('newDataDisk3')' failed with message '{
  "error": {
    "code": "InvalidParameter",
    "message": "The value of parameter disk.name is invalid.",
    "target": "disk.name"
  }
}'
At line:1 char:1
+ New-AzureRmResourceGroupDeployment -Name "RenameDisks" -ResourceGroup ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet

New-AzureRmResourceGroupDeployment : 16:38:35 - Resource Microsoft.Compute/disks 'parameters('osdiskNewname')' failed with message '{
  "error": {
    "code": "InvalidParameter",
    "message": "The value of parameter disk.name is invalid.",
    "target": "disk.name"
  }
}'
At line:1 char:1
+ New-AzureRmResourceGroupDeployment -Name "RenameDisks" -ResourceGroup ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [New-AzureRmResourceGroupDeployment], Exception
    + FullyQualifiedErrorId : Microsoft.Azure.Commands.ResourceManager.Cmdlets.Implementation.NewAzureResourceGroupDeploymentCmdlet

New-AzureRmResourceGroupDeployment : 16:38:35 - Resource Microsoft.Compute/disks 'parameters('newDataDisk1')' failed with message '{
  "error": {
    "code": "InvalidParameter",
    "message": "The value of parameter disk.name is invalid.",
    "target": "disk.name"
  }
}'`

完整的参数和模板文件位于: https://pastebin.com/embed_iframe/YK5V4agX

我正在使用Powershell new-azurermresourcegroupdeployment调用模板和参数文件

1 个答案:

答案 0 :(得分:1)

根据this,您的sourceUri参数应称为sourceResourceId

properties": {
    "creationData": {
        "createOption": "Copy",
        "sourceResourceId": "subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/disks/myDisk1"
    }
}

那是我能发现的唯一区别。另外,可能值得尝试并删除sku属性(对此不确定(可能不确定)。

确保您的VM支持您要使用的SKU。