@@ -7,50 +7,92 @@ $ErrorActionPreference = "Stop"
7
7
$QuickStartsRepoPath = Resolve-Path $QuickStartsRepoPath
8
8
$OutputPath = Join-Path $PSScriptRoot " ../settings/samples/samples.json"
9
9
10
- function GetResourceTypes {
11
- param ([PSCustomObject ] $template )
12
-
13
- $resourceTypes = @ ()
14
- foreach ($resource in $template.resources ) {
15
- if ($resource.type -ieq " Microsoft.Resources/deployments" ) {
16
- foreach ($resourceType in GetResourceTypes($resource.properties.template )) {
17
- $resourceTypes += $resourceType
10
+ function GetQuickstartLinks {
11
+ function GetResourceTypes {
12
+ param ([PSCustomObject ] $template )
13
+
14
+ $resourceTypes = @ ()
15
+ foreach ($resource in $template.resources ) {
16
+ if ($resource.type -ieq " Microsoft.Resources/deployments" ) {
17
+ foreach ($resourceType in GetResourceTypes($resource.properties.template )) {
18
+ $resourceTypes += $resourceType
19
+ }
20
+ } else {
21
+ $resourceTypes += $resource.type
18
22
}
19
- } else {
20
- $resourceTypes += $resource.type
21
23
}
24
+
25
+ return $resourceTypes | Sort-Object - Unique
22
26
}
23
27
24
- return $resourceTypes | Sort-Object - Unique
28
+ $links = @ ()
29
+ $metadataPaths = Get-ChildItem $QuickStartsRepoPath - File - Recurse - Include " metadata.json" | Sort-Object FullName
30
+ foreach ($metadataPath in $metadataPaths ) {
31
+ Write-Host " Processing $metadataPath "
32
+ $templatePath = Join-Path $metadataPath.DirectoryName " azuredeploy.json" - Resolve
33
+ $bicepPath = Join-Path $metadataPath.DirectoryName " main.bicep"
34
+ $hasBicep = (Test-Path $bicepPath - PathType Leaf)
35
+
36
+ $metadataContent = Get-Content $metadataPath.FullName | ConvertFrom-Json
37
+ $description = $metadataContent.description
38
+ $displayName = $metadataContent.itemDisplayName
39
+
40
+ $templateContent = Get-Content $templatePath | ConvertFrom-Json
41
+ $resourceTypes = GetResourceTypes($templateContent )
42
+
43
+ $links += [ordered ]@ {
44
+ Title = $displayName ;
45
+ Description = $description ;
46
+ Path = [System.IO.Path ]::GetRelativePath($QuickStartsRepoPath , " $templatePath /.." ).Replace(" \" , " /" )
47
+ ResourceTypes = @ ($resourceTypes );
48
+ HasBicep = $hasBicep ;
49
+ }
50
+ }
51
+
52
+ return $links
25
53
}
26
54
27
- $quickstartLinks = @ ()
28
- $metadataPaths = Get-ChildItem $QuickStartsRepoPath - File - Recurse - Include " metadata.json" | Sort-Object FullName
29
- foreach ($metadataPath in $metadataPaths ) {
30
- Write-Host " Processing $metadataPath "
31
- $templatePath = Join-Path $metadataPath.DirectoryName " azuredeploy.json" - Resolve
32
- $bicepPath = Join-Path $metadataPath.DirectoryName " main.bicep"
33
- $hasBicep = (Test-Path $bicepPath - PathType Leaf)
34
-
35
- $metadataContent = Get-Content $metadataPath.FullName | ConvertFrom-Json
36
- $description = $metadataContent.description
37
- $displayName = $metadataContent.itemDisplayName
38
-
39
- $templateContent = Get-Content $templatePath | ConvertFrom-Json
40
- $resourceTypes = GetResourceTypes($templateContent )
41
-
42
- $quickstartLinks += [ordered ]@ {
43
- Title = $displayName ;
44
- Description = $description ;
45
- Path = [System.IO.Path ]::GetRelativePath($QuickStartsRepoPath , " $templatePath /.." ).Replace(" \\" , " /" )
46
- ResourceTypes = @ ($resourceTypes );
47
- HasBicep = $hasBicep ;
55
+ function GetAvmLinks {
56
+ $bicepLinks = " https://raw.githubusercontent.com/Azure/Azure-Verified-Modules/refs/heads/main/docs/static/module-indexes/BicepResourceModules.csv"
57
+ $tfLinks = " https://raw.githubusercontent.com/Azure/Azure-Verified-Modules/refs/heads/main/docs/static/module-indexes/TerraformResourceModules.csv"
58
+
59
+ $bicepModules = ConvertFrom-Csv (Invoke-WebRequest - Uri $bicepLinks ).Content
60
+ $tfModules = ConvertFrom-Csv (Invoke-WebRequest - Uri $tfLinks ).Content
61
+
62
+ $links = @ ()
63
+ foreach ($bicepModule in $bicepModules ) {
64
+ Write-Host " Processing $ ( $bicepModule.RepoURL ) "
65
+
66
+ $links += [ordered ]@ {
67
+ Type = " Bicep" ;
68
+ Title = $bicepModule.ModuleDisplayName ;
69
+ Description = $bicepModule.Description ;
70
+ ResourceType = " $ ( $bicepModule.ProviderNamespace ) /$ ( $bicepModule.ResourceType ) " ;
71
+ RepoUrl = $bicepModule.RepoURL ;
72
+ }
73
+ }
74
+ foreach ($tfModule in $tfModules ) {
75
+ Write-Host " Processing $ ( $tfModule.RepoURL ) "
76
+
77
+ $links += [ordered ]@ {
78
+ Type = " Terraform" ;
79
+ Title = $tfModule.ModuleDisplayName ;
80
+ Description = $tfModule.Description ;
81
+ ResourceType = " $ ( $tfModule.ProviderNamespace ) /$ ( $tfModule.ResourceType ) " ;
82
+ RepoUrl = $tfModule.RepoURL ;
83
+ }
48
84
}
85
+
86
+ return $links
49
87
}
50
88
89
+ $quickstartLinks = GetQuickstartLinks
90
+ $avmLinks = GetAvmLinks
91
+
51
92
$samples = [ordered ]@ {
52
93
" `$ schema" = " ../schemas/samples.schema.json" ;
53
94
QuickstartLinks = $quickstartLinks ;
95
+ AvmLinks = $avmLinks ;
54
96
}
55
97
56
98
$samples | ConvertTo-Json - depth 100 | Out-File $OutputPath
0 commit comments