Skip to content

Commit f97b9e4

Browse files
committed
updates and lz-export
1 parent d4dbc25 commit f97b9e4

File tree

8 files changed

+165
-3
lines changed

8 files changed

+165
-3
lines changed

Deploy-AzTemplate.ps1

+1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ Param(
1515
[switch] $BuildDscPackage,
1616
[switch] $ValidateOnly,
1717
[string] $DebugOptions = "None",
18+
[string] $Mode = "Incremental",
1819
[string] $DeploymentName = ((Split-Path $TemplateFile -LeafBase) + '-' + ((Get-Date).ToUniversalTime()).ToString('MMdd-HHmm')),
1920
[switch] $Dev
2021
)

copy-zero/azuredeploy.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,12 @@
1919
"metadata": {
2020
"note": "the metadata property is ignored by ARM"
2121
},
22-
"name": "notDeployed",
22+
//"condition": "[greater(variables('emptyArray'),0)]",
23+
"name": "[if(greater(length(variables('emptyArray')),0), variables('emptyArray')[copyIndex()], 'notDeployed')]",
2324
"type": "Microsoft.Resources/deployments",
2425
"apiVersion": "2019-05-10",
2526
"copy": {
26-
"count": 0,
27+
"count": "[length(variables('emptyArray'))]",
2728
"name": "copyZero"
2829
},
2930
"properties": {

lz-export/export-mg.ps1

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
function Get-Children($id, $children){
3+
4+
Write-Host "Handling: $id"
5+
6+
foreach($c in $children){
7+
Get-Children $c.id $c.children
8+
9+
# if this is not a subscription, create the value - subscriptions have a different lifecycle so are not in the same template
10+
if($c.type -like "*/managementGroups"){
11+
$param = [ordered]@{
12+
name = $c.name
13+
displayName = $c.displayName
14+
parentName = $id.Split("/")[-1] # name is the last segment of the resourceId
15+
}
16+
$param | ConvertTo-Json | Add-Content -path ".\mg.dump.json"
17+
}else{
18+
$param = [ordered]@{
19+
displayName = $c.displayName
20+
subscription = $c.name
21+
parentName = $id.Split("/")[-1]
22+
}
23+
$param | ConvertTo-Json | Add-Content -path ".\subs.dump.json"
24+
}
25+
}
26+
}
27+
28+
$mg = Get-AzManagementGroup -GroupName 'bmoore-mgmt-group' -Expand -Recurse
29+
30+
Get-Children $mg.id $mg.children
31+

lz-export/groups.json

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
{
3+
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/tenantDeploymentTemplate.json#",
4+
"contentVersion": "1.0.0.0",
5+
"parameters": {
6+
"groups": {
7+
"type": "array"
8+
}
9+
},
10+
"resources": [
11+
{
12+
"type": "Microsoft.Management/managementGroups",
13+
"apiVersion": "2020-05-01",
14+
"name": "[parameters('groups')[copyIndex()].name]",
15+
"copy": {
16+
"count": "[length(parameters('groups'))]",
17+
"name": "group-loop",
18+
"mode": "serial"
19+
},
20+
"properties": {
21+
"displayName": "[parameters('groups')[copyIndex()].displayName]",
22+
"details": {
23+
"parent": {
24+
"id": "[if(not(empty(parameters('groups')[copyIndex()].parentName)),
25+
tenantResourceId('Microsoft.Management/managementGroups', parameters('groups')[copyIndex()].parentName),
26+
json('null'))]"
27+
}
28+
}
29+
}
30+
}
31+
]
32+
}

lz-export/groups.parameters.json

+55
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"groups": {
6+
"value": [
7+
{
8+
"name": "export-root",
9+
"displayName": "export-root",
10+
"parentName": ""
11+
},
12+
{
13+
"name": "child-a",
14+
"displayName": "Child A",
15+
"parentName": "export-root"
16+
},
17+
{
18+
"name": "grandchild-a-a",
19+
"displayName": "Grandchild A-A",
20+
"parentName": "child-a"
21+
},
22+
{
23+
"name": "grandchild-a-b",
24+
"displayName": "Grandchild A-B",
25+
"parentName": "child-a"
26+
},
27+
{
28+
"name": "grandchild-a-c",
29+
"displayName": "Grandchild A-C",
30+
"parentName": "child-a"
31+
},
32+
{
33+
"name": "greatgrandchild-A-C-A",
34+
"displayName": "Greatgrandchild A-C-A",
35+
"parentName": "grandchild-a-c"
36+
},
37+
{
38+
"name": "child-b",
39+
"displayName": "Child B",
40+
"parentName": "export-root"
41+
},
42+
{
43+
"name": "grandchild-b-1",
44+
"displayName": "Grandchild B-1",
45+
"parentName": "child-b"
46+
},
47+
{
48+
"name": "grandchild-b-2",
49+
"displayName": "Grandchild B-2",
50+
"parentName": "child-b"
51+
}
52+
]
53+
}
54+
}
55+
}

lz-export/subs-groups.json

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
{
3+
"$schema": "https://schema.management.azure.com/schemas/2019-08-01/tenantDeploymentTemplate.json#",
4+
"contentVersion": "1.0.0.0",
5+
"parameters": {
6+
"subscriptions": {
7+
"type": "array"
8+
}
9+
},
10+
"resources": [
11+
{
12+
"type": "Microsoft.Management/managementGroups/subscriptions",
13+
"apiVersion": "2020-05-01",
14+
"name": "[concat(parameters('subscriptions')[copyIndex()].parentName, '/', parameters('subscriptions')[copyIndex()].name)]",
15+
"copy": {
16+
"count": "[length(parameters('subscriptions'))]",
17+
"name": "mg-sub-loop"
18+
},
19+
"properties": { }
20+
}
21+
]
22+
}

lz-export/subs-groups.parameters.json

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentParameters.json#",
3+
"contentVersion": "1.0.0.0",
4+
"parameters": {
5+
"subscriptions": {
6+
"value": [
7+
{
8+
"subscription": "60bf0ebb-15da-4333-a0b9-9c8bcd865b48",
9+
"displayName": "QuickStarts Services",
10+
"parentName": "greatgrandchild-A-C-A"
11+
},
12+
{
13+
"subscription": "ceaedbb7-b827-4195-b55f-de9b6732010b",
14+
"displayName": "bmoore",
15+
"parentName": "bmoore-mgmt-group"
16+
}
17+
]
18+
}
19+
}
20+
}

non-deterministic-fn/azuredeploy.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"$schema": "https://schema.management.azure.com/schemas/2015-01-01/deploymentTemplate.json#",
2+
"$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
33
"contentVersion": "1.0.0.0",
44
"parameters": {
55
"time": {

0 commit comments

Comments
 (0)