Skip to content

Commit c5d9f9f

Browse files
1 parent 22c4cc5 commit c5d9f9f

File tree

13 files changed

+17735
-15207
lines changed

13 files changed

+17735
-15207
lines changed

docs/configuration.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ This file can be found under [settings/samples/samples.json](../settings/samples
1010

1111
`samples.json` is not manually maintained. It can be updated by running [scripts/UpdateSamples.ps1](../scripts/UpdateSamples.ps1).
1212

13+
> [!NOTE]
14+
> This process is not currently automated. The script needs to be re-run to pick up the latest set of samples.
15+
1316
## Config
1417

1518
This file can be found under [settings/config/config.json](../settings/config/config.json), and can be used to configure the generation process. The schema is available [here](../settings/config.schema.json).

scripts/UpdateSamples.ps1

Lines changed: 74 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -7,50 +7,92 @@ $ErrorActionPreference = "Stop"
77
$QuickStartsRepoPath = Resolve-Path $QuickStartsRepoPath
88
$OutputPath = Join-Path $PSScriptRoot "../settings/samples/samples.json"
99

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
1822
}
19-
} else {
20-
$resourceTypes += $resource.type
2123
}
24+
25+
return $resourceTypes | Sort-Object -Unique
2226
}
2327

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
2553
}
2654

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+
}
4884
}
85+
86+
return $links
4987
}
5088

89+
$quickstartLinks = GetQuickstartLinks
90+
$avmLinks = GetAvmLinks
91+
5192
$samples = [ordered]@{
5293
"`$schema" = "../schemas/samples.schema.json";
5394
QuickstartLinks = $quickstartLinks;
95+
AvmLinks = $avmLinks;
5496
}
5597

5698
$samples | ConvertTo-Json -depth 100 | Out-File $OutputPath

0 commit comments

Comments
 (0)