-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathloops.bicep
72 lines (67 loc) · 1.78 KB
/
loops.bicep
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
param stgCount int = 2
param Stgdeps array = [
'mercadeo'
'ventas'
]
param Stgdeps1 array = [
{
'dept': 'compras'
'sku': 'Standard_LRS'
}
{
'dept': 'finanzas'
'sku': 'Premium_LRS'
}
]
//Usando Int para indices
resource storageaccount 'Microsoft.Storage/storageAccounts@2021-02-01' = [for i in range(0, stgCount): {
name: 'stg${i}${uniqueString(resourceGroup().id)}'
location: resourceGroup().location
kind: 'StorageV2'
sku: {
name: 'Standard_LRS'
}
}]
resource storageaccount2 'Microsoft.Storage/storageAccounts@2021-02-01' = [for i in range(2, stgCount): {
name: 'stg${i}${uniqueString(resourceGroup().id)}'
location: resourceGroup().location
kind: 'StorageV2'
sku: {
name: 'Standard_LRS'
}
}]
// Arreglo (array)
resource storageaccount3 'Microsoft.Storage/storageAccounts@2021-02-01' = [for i in Stgdeps: {
name: 'stg${i}${uniqueString(resourceGroup().id)}'
location: resourceGroup().location
kind: 'StorageV2'
sku: {
name: 'Standard_LRS'
}
}]
resource storageaccount4 'Microsoft.Storage/storageAccounts@2021-02-01' = [for storage in Stgdeps1: {
name: 'stg${storage.dept}${uniqueString(resourceGroup().id)}'
location: resourceGroup().location
kind: 'StorageV2'
sku: {
name: storage.sku
}
}]
//output con INT en Arrays
output StorageNames1 array = [for i in range(0, stgCount): {
name: storageaccount[i].name
id: storageaccount[i].id
}]
output StorageNames2 array = [for i in range(0, stgCount): {
name: storageaccount2[i].name
id: storageaccount2[i].id
}]
//Output con String en arrays
output StorageNames3 array = [for (name,i) in Stgdeps: {
name: storageaccount3[i].name
id: storageaccount3[i].id
}]
output StorageNames4 array = [for (name, i) in Stgdeps1: {
name: storageaccount4[i].name
id: storageaccount4[i].id
}]