-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from takekazuomi/develop
bicep 0.3.126
- Loading branch information
Showing
13 changed files
with
255 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,22 @@ | ||
resource parentResources 'Microsoft.Example/examples@2020-06-06' = [for parent in parents where parent.enabled: { | ||
var parents = [ | ||
{ | ||
name: 'name' | ||
enabled: true | ||
children: [ | ||
{ | ||
name: 'name' | ||
settingValue: 'value' | ||
} | ||
] | ||
} | ||
] | ||
|
||
resource parentResources 'Microsoft.Example/examples@2020-06-06' = [for parent in parents: if (parent.enabled) { | ||
name: parent.name | ||
properties: { | ||
children: [for child in parent.children where parent.includeChildren && child.enabled: { | ||
children: [for child in parent.children: { | ||
name: child.name | ||
setting: child.settingValue | ||
}] | ||
} | ||
}] | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
param name string | ||
|
||
resource nsg 'Microsoft.Network/networkSecurityGroups@2020-06-01' = { | ||
name: name | ||
location: resourceGroup().location | ||
} | ||
|
||
output n object = { | ||
name: nsg.name | ||
id: nsg.id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Output loops. | ||
// Directly referencing a resource module or module collection is not currently supported in output loops. In order to loop outputs we need to apply an array indexer to the expression. | ||
|
||
var nsgNames = [ | ||
'nsg1' | ||
'nsg2' | ||
'nsg3' | ||
] | ||
|
||
output nsgs array = [for i in range(0, length(nsgNames)): { | ||
name: nsg[i].outputs.n.name | ||
resourceId: nsg[i].outputs.n.id | ||
}] | ||
|
||
module nsg 'nsg-module.bicep' = [for name in nsgNames: { | ||
name: name | ||
params:{ | ||
name: name | ||
} | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"functions": [], | ||
"variables": { | ||
"nsgNames": [ | ||
"nsg1", | ||
"nsg2", | ||
"nsg3" | ||
] | ||
}, | ||
"resources": [ | ||
{ | ||
"copy": { | ||
"name": "nsg", | ||
"count": "[length(variables('nsgNames'))]" | ||
}, | ||
"type": "Microsoft.Resources/deployments", | ||
"apiVersion": "2019-10-01", | ||
"name": "[variables('nsgNames')[copyIndex()]]", | ||
"properties": { | ||
"expressionEvaluationOptions": { | ||
"scope": "inner" | ||
}, | ||
"mode": "Incremental", | ||
"parameters": { | ||
"name": { | ||
"value": "[variables('nsgNames')[copyIndex()]]" | ||
} | ||
}, | ||
"template": { | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"parameters": { | ||
"name": { | ||
"type": "string" | ||
} | ||
}, | ||
"functions": [], | ||
"resources": [ | ||
{ | ||
"type": "Microsoft.Network/networkSecurityGroups", | ||
"apiVersion": "2020-06-01", | ||
"name": "[parameters('name')]", | ||
"location": "[resourceGroup().location]" | ||
} | ||
], | ||
"outputs": { | ||
"n": { | ||
"type": "object", | ||
"value": { | ||
"name": "[parameters('name')]", | ||
"id": "[resourceId('Microsoft.Network/networkSecurityGroups', parameters('name'))]" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
], | ||
"outputs": { | ||
"nsgs": { | ||
"type": "array", | ||
"copy": { | ||
"count": "[length(range(0, length(variables('nsgNames'))))]", | ||
"input": { | ||
"name": "[reference(resourceId('Microsoft.Resources/deployments', variables('nsgNames')[range(0, length(variables('nsgNames')))[copyIndex()]]), '2019-10-01').outputs.name]", | ||
"resourceId": "[reference(resourceId('Microsoft.Resources/deployments', variables('nsgNames')[range(0, length(variables('nsgNames')))[copyIndex()]]), '2019-10-01').outputs.n.value]" | ||
} | ||
} | ||
} | ||
}, | ||
"metadata": { | ||
"_generator": { | ||
"name": "bicep", | ||
"version": "0.3.1.62928", | ||
"templateHash": "11043703718792320070" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
// Output loops. | ||
// Directly referencing a resource module or module collection is not currently supported in output loops. In order to loop outputs we need to apply an array indexer to the expression. | ||
|
||
var nsgNames = [ | ||
'nsg1' | ||
'nsg2' | ||
'nsg3' | ||
] | ||
|
||
resource nsg 'Microsoft.Network/networkSecurityGroups@2020-06-01' = [for name in nsgNames: { | ||
name: name | ||
location: resourceGroup().location | ||
}] | ||
|
||
output nsgs array = [for i in range(0, length(nsgNames)): { | ||
name: nsg[i].name | ||
|
||
resourceId: nsg[i].id | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// Output loops. | ||
// Directly referencing a resource module or module collection is not currently supported in output loops. In order to loop outputs we need to apply an array indexer to the expression. | ||
|
||
var nsgNames = [ | ||
'nsg1' | ||
'nsg2' | ||
'nsg3' | ||
] | ||
|
||
resource nsg 'Microsoft.Network/networkSecurityGroups@2020-06-01' = [for name in nsgNames: { | ||
name: name | ||
location: resourceGroup().location | ||
}] | ||
|
||
output nsgs array = [for i in range(0, length(nsgNames)): { | ||
name: nsg[i].name | ||
resourceId: nsg[i].id | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
resource myParent 'My.Rp/parentType@2020-01-01' = { | ||
name: 'myParent' | ||
location: 'West US' | ||
} | ||
|
||
resource myChild 'My.Rp/parentType/childType@2020-01-01' = { | ||
parent: myParent // pass parent reference | ||
name: 'myChild' // don't require the full name to be formatted with '/' characters | ||
} | ||
|
||
output childProp string = myChild.properties.someProp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
// https://github.com/Azure/bicep/blob/main/docs/spec/resources.md#resource-nesting | ||
resource myParent 'My.Rp/parentType@2020-01-01' = { | ||
name: 'myParent' | ||
location: 'West US' | ||
|
||
// declares a resource of type 'My.Rp/parentType/childType@2020-01-01' | ||
resource myChild 'childType' = { | ||
name: 'myChild' | ||
properties: { | ||
displayName: 'child in ${parent.location}' | ||
} | ||
} | ||
} | ||
|
||
output childProp string = myParent::myChild.properties.displayName | ||
|
||
|
||
// Error BCP082: The name "parent" does not exist in the current context. Did you mean "myParent"? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#", | ||
"contentVersion": "1.0.0.0", | ||
"functions": [], | ||
"resources": [ | ||
{ | ||
"type": "My.Rp/parentType/childType", | ||
"apiVersion": "2020-01-01", | ||
"name": "[format('{0}/{1}', 'myParent', 'myChild')]", | ||
"properties": { | ||
"displayName": "[format('child in {0}', reference(resourceId('My.Rp/parentType', 'myParent'), '2020-01-01', 'full').location)]" | ||
}, | ||
"dependsOn": [ | ||
"[resourceId('My.Rp/parentType', 'myParent')]" | ||
] | ||
}, | ||
{ | ||
"type": "My.Rp/parentType", | ||
"apiVersion": "2020-01-01", | ||
"name": "myParent", | ||
"location": "West US" | ||
} | ||
], | ||
"outputs": { | ||
"childProp": { | ||
"type": "string", | ||
"value": "[reference(resourceId('My.Rp/parentType/childType', 'myParent', 'myChild')).displayName]" | ||
} | ||
}, | ||
"metadata": { | ||
"_generator": { | ||
"name": "bicep", | ||
"version": "0.3.126.58533", | ||
"templateHash": "13471392052954043995" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
var array1 = [ | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
] | ||
|
||
var array2 = [ | ||
1 | ||
2 | ||
3 | ||
4 | ||
5 | ||
] | ||
|
||
var array3 = [for i in array1: { | ||
i | ||
}] | ||
|
||
output r array = array3 |