如何使用两个数组生成副本?

问题描述 投票:0回答:1

我需要在具有两个不同数组的复制循环中创建连接名称

例:

Array1 [machine1, machine2]
Array2 [100, 100, 100]

我希望我的复制循环能够创建:

machine1_Disk0 - This will be 100GB
machine1_Disk1 - This will be 100GB
machine1_Disk3 - This will be 100GB

machine2_Disk1 - This will be 100GB
machine2_Disk2 - This will be 100GB
machine2_Disk3 - This will be 100GB 

我已经尝试过这个:

"name": "[concat(parameters('Array1'), '_Disk_' , copyIndex('Array2'))]",

没有工作cos数组1是一个数组,而不是数组内的位置。然后我尝试了这个:

"name": "[concat(parameters('Array1')[copyIndex()], '_Disk_' , copyIndex('Array2'))]",

这告诉我''资源不存在。

有任何想法吗?谢谢!

json arm-template
1个回答
0
投票

Java脚本:

['m1', 'm2'].forEach((e) => { 
  [100, 150, 200].forEach((n, i) => { 
     console.log(e + '_Disk' + i +' This will be '+ n + 'GB') 
  }) 
})
© www.soinside.com 2019 - 2024. All rights reserved.