From 66bfb7a39fe6af7cdac803b4dc4d6e470e1bfa34 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Sun, 30 Jul 2023 13:07:36 +0200 Subject: [PATCH 01/13] Replaced first couple paths --- .../resourceDeployment/New-TemplateDeployment.ps1 | 10 +++++----- .../resourceDeployment/Test-TemplateDeployment.ps1 | 6 +++--- .../resourceRemoval/Initialize-DeploymentRemoval.ps1 | 4 ++-- .../staticValidation/Set-PesterGitHubOutput.ps1 | 4 ++-- utilities/tools/Set-ModuleReadMe.ps1 | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 b/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 index a892d8a2e1..ad5bafbdec 100644 --- a/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 +++ b/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 @@ -102,17 +102,17 @@ Optional. Maximum retry limit if the deployment fails. Default is 3. Optional. Do not throw an exception if it failed. Still returns the error message though .EXAMPLE -New-TemplateDeploymentInner -templateFilePath 'C:/KeyVault/main.json' -parameterFilePath 'C:/KeyVault/.test/parameters.json' -location 'WestEurope' -resourceGroupName 'aLegendaryRg' +New-TemplateDeploymentInner -templateFilePath 'C:/key-vault/vault/main.json' -parameterFilePath 'C:/key-vault/vault/.test/parameters.json' -location 'WestEurope' -resourceGroupName 'aLegendaryRg' Deploy the main.json of the KeyVault module with the parameter file 'parameters.json' using the resource group 'aLegendaryRg' in location 'WestEurope' .EXAMPLE -New-TemplateDeploymentInner -templateFilePath 'C:/KeyVault/main.bicep' -location 'WestEurope' -resourceGroupName 'aLegendaryRg' +New-TemplateDeploymentInner -templateFilePath 'C:/key-vault/vault/main.bicep' -location 'WestEurope' -resourceGroupName 'aLegendaryRg' Deploy the main.bicep of the KeyVault module using the resource group 'aLegendaryRg' in location 'WestEurope' .EXAMPLE -New-TemplateDeploymentInner -templateFilePath 'C:/ResourceGroup/main.json' -location 'WestEurope' +New-TemplateDeploymentInner -templateFilePath 'C:/resources/resource-group/main.json' -location 'WestEurope' Deploy the main.json of the ResourceGroup module without a parameter file in location 'WestEurope' #> @@ -374,12 +374,12 @@ Optional. Maximum retry limit if the deployment fails. Default is 3. Optional. Do not throw an exception if it failed. Still returns the error message though .EXAMPLE -New-TemplateDeployment -templateFilePath 'C:/KeyVault/main.bicep' -parameterFilePath 'C:/KeyVault/.test/parameters.json' -location 'WestEurope' -resourceGroupName 'aLegendaryRg' +New-TemplateDeployment -templateFilePath 'C:/key-vault/vault/main.bicep' -parameterFilePath 'C:/key-vault/vault/.test/parameters.json' -location 'WestEurope' -resourceGroupName 'aLegendaryRg' Deploy the main.bicep of the KeyVault module with the parameter file 'parameters.json' using the resource group 'aLegendaryRg' in location 'WestEurope' .EXAMPLE -New-TemplateDeployment -templateFilePath 'C:/ResourceGroup/main.bicep' -location 'WestEurope' +New-TemplateDeployment -templateFilePath 'C:/resources/resource-group/main.bicep' -location 'WestEurope' Deploy the main.bicep of the ResourceGroup module in location 'WestEurope' without a parameter file diff --git a/utilities/pipelines/resourceDeployment/Test-TemplateDeployment.ps1 b/utilities/pipelines/resourceDeployment/Test-TemplateDeployment.ps1 index 42fc1bc6d7..2593de5df6 100644 --- a/utilities/pipelines/resourceDeployment/Test-TemplateDeployment.ps1 +++ b/utilities/pipelines/resourceDeployment/Test-TemplateDeployment.ps1 @@ -31,17 +31,17 @@ Optional. Name of the management group to deploy into. Mandatory if deploying in Optional. Additional parameters you can provide with the deployment. E.g. @{ resourceGroupName = 'myResourceGroup' } .EXAMPLE -Test-TemplateDeployment -templateFilePath 'C:/KeyVault/main.bicep' -parameterFilePath 'C:/KeyVault/.test/parameters.json' -location 'WestEurope' -resourceGroupName 'aLegendaryRg' +Test-TemplateDeployment -templateFilePath 'C:/key-vault/vault/main.bicep' -parameterFilePath 'C:/key-vault/vault/.test/parameters.json' -location 'WestEurope' -resourceGroupName 'aLegendaryRg' Test the main.bicep of the KeyVault module with the parameter file 'parameters.json' using the resource group 'aLegendaryRg' in location 'WestEurope' .EXAMPLE -Test-TemplateDeployment -templateFilePath 'C:/KeyVault/main.bicep' -location 'WestEurope' -resourceGroupName 'aLegendaryRg' +Test-TemplateDeployment -templateFilePath 'C:/key-vault/vault/main.bicep' -location 'WestEurope' -resourceGroupName 'aLegendaryRg' Test the main.bicep of the KeyVault module using the resource group 'aLegendaryRg' in location 'WestEurope' .EXAMPLE -Test-TemplateDeployment -templateFilePath 'C:/ResourceGroup/main.json' -parameterFilePath 'C:/ResourceGroup/.test/parameters.json' -location 'WestEurope' +Test-TemplateDeployment -templateFilePath 'C:/resources/resource-group/main.json' -parameterFilePath 'C:/resources/resource-group/.test/parameters.json' -location 'WestEurope' Test the main.json of the ResourceGroup module with the parameter file 'parameters.json' in location 'WestEurope' #> diff --git a/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 b/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 index baf596c065..4462fffdcb 100644 --- a/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 +++ b/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 @@ -18,9 +18,9 @@ Optional. The name of the resource group the deployment was happening in. Releva Optional. The ID of the management group to fetch deployments from. Relevant for management-group level deployments. .EXAMPLE -Initialize-DeploymentRemoval -DeploymentName 'virtualWans-20211204T1812029146Z' -TemplateFilePath "$home/ResourceModules/modules/network/virtual-wans/main.bicep" -resourceGroupName 'test-virtualWan-rg' +Initialize-DeploymentRemoval -DeploymentName 'virtualWans-20211204T1812029146Z' -TemplateFilePath "$home/ResourceModules/modules/network/virtual-wan/main.bicep" -resourceGroupName 'test-virtualWan-rg' -Remove the deployment 'virtualWans-20211204T1812029146Z' from resource group 'test-virtualWan-rg' that was executed using template in path "$home/ResourceModules/modules/network/virtual-wans/main.bicep" +Remove the deployment 'virtualWans-20211204T1812029146Z' from resource group 'test-virtualWan-rg' that was executed using template in path "$home/ResourceModules/modules/network/virtual-wan/main.bicep" #> function Initialize-DeploymentRemoval { diff --git a/utilities/pipelines/staticValidation/Set-PesterGitHubOutput.ps1 b/utilities/pipelines/staticValidation/Set-PesterGitHubOutput.ps1 index 539d9b8b17..2459000cae 100644 --- a/utilities/pipelines/staticValidation/Set-PesterGitHubOutput.ps1 +++ b/utilities/pipelines/staticValidation/Set-PesterGitHubOutput.ps1 @@ -34,9 +34,9 @@ Mandatory. The Pester tests results to parse. Can be fetched by running Pester w Failed = '' FailedBlocks = '' FailedContainers = '' - Passed = '[+] [Microsoft.KeyVault/vaults/secrets] Module should contain a [main.json/main.bicep] file. [+] ...' + Passed = '[+] [key-vault/vault/secret] Module should contain a [main.json/main.bicep] file. [+] ...' NotRun = '' - Tests = '[+] [Microsoft.KeyVault/vaults/secrets] Module should contain a [main.json/main.bicep] file. [+] ...' + Tests = '[+] [key-vault/vault/secret] Module should contain a [main.json/main.bicep] file. [+] ...' CodeCoverage = null } diff --git a/utilities/tools/Set-ModuleReadMe.ps1 b/utilities/tools/Set-ModuleReadMe.ps1 index 755a41ae59..f8049fd829 100644 --- a/utilities/tools/Set-ModuleReadMe.ps1 +++ b/utilities/tools/Set-ModuleReadMe.ps1 @@ -1510,17 +1510,17 @@ Set-ModuleReadMe -TemplateFilePath 'C:\main.bicep' Update the readme in path 'C:\README.md' based on the bicep template in path 'C:\main.bicep' .EXAMPLE -Set-ModuleReadMe -TemplateFilePath 'C:/Network/loadBalancers/main.bicep' -SectionsToRefresh @('Parameters', 'Outputs') +Set-ModuleReadMe -TemplateFilePath 'C:/network/load-balancer/main.bicep' -SectionsToRefresh @('Parameters', 'Outputs') Generate the Module ReadMe only for specific sections. Updates only the sections `Parameters` & `Outputs`. Other sections remain untouched. .EXAMPLE -Set-ModuleReadMe -TemplateFilePath 'C:/Network/loadBalancers/main.bicep' -TemplateFileContent @{...} +Set-ModuleReadMe -TemplateFilePath 'C:/network/load-balancer/main.bicep' -TemplateFileContent @{...} (Re)Generate the readme file for template 'loadBalancer' based on the content provided in the TemplateFileContent parameter .EXAMPLE -Set-ModuleReadMe -TemplateFilePath 'C:/Network/loadBalancers/main.bicep' -ReadMeFilePath 'C:/differentFolder' +Set-ModuleReadMe -TemplateFilePath 'C:/network/load-balancer/main.bicep' -ReadMeFilePath 'C:/differentFolder' Generate the Module ReadMe files into a specific folder path From 3a639d64ddc9fe2d80e656e033181f9f5df25edb Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Sun, 30 Jul 2023 16:41:44 +0200 Subject: [PATCH 02/13] Updated tools folder --- utilities/tools/ConvertTo-ARMTemplate.ps1 | 2 +- .../tools/Get-CrossReferencedModuleList.ps1 | 12 +++---- utilities/tools/Set-ModuleReadMe.ps1 | 14 ++++---- utilities/tools/Test-ModuleLocally.ps1 | 20 +++++------ utilities/tools/Update-RoleAssignmentList.ps1 | 20 +++++------ .../helper/Get-ModulesAsMarkdownTable.ps1 | 36 +++++++++---------- 6 files changed, 52 insertions(+), 52 deletions(-) diff --git a/utilities/tools/ConvertTo-ARMTemplate.ps1 b/utilities/tools/ConvertTo-ARMTemplate.ps1 index 83bbff81fc..764d9a0b0c 100644 --- a/utilities/tools/ConvertTo-ARMTemplate.ps1 +++ b/utilities/tools/ConvertTo-ARMTemplate.ps1 @@ -46,7 +46,7 @@ Converts bicep modules to json-based ARM template, cleaning up all bicep files a Regenerates compiled 'main.json' for the whole library. .EXAMPLE -. .\utilities\tools\ConvertTo-ARMTemplate.ps1 -ModuleRelativePath "modules\desktop-virtualization\application-groups" -RemoveExistingTemplates -SkipMetadataCleanup -SkipBicepCleanUp -SkipPipelineUpdate -SkipTest -Verbose +. .\utilities\tools\ConvertTo-ARMTemplate.ps1 -ModuleRelativePath "modules\desktop-virtualization\application-group" -RemoveExistingTemplates -SkipMetadataCleanup -SkipBicepCleanUp -SkipPipelineUpdate -SkipTest -Verbose Regenerates compiled 'main.json' for the provided ModuleRelativePath folder. diff --git a/utilities/tools/Get-CrossReferencedModuleList.ps1 b/utilities/tools/Get-CrossReferencedModuleList.ps1 index f0b07a3904..cddeaa1bd6 100644 --- a/utilities/tools/Get-CrossReferencedModuleList.ps1 +++ b/utilities/tools/Get-CrossReferencedModuleList.ps1 @@ -61,9 +61,9 @@ Invoke the function with the default path. Returns an object such as: { "Compute/availabilitySets": { "localPathReferences": [ - RecoveryServices/vaults/protectionContainers/protectedItems - Network/publicIPAddresses - Network/networkInterfaces + recovery-service/vault/protection-container/protected-item + network/public-ip-address + network/network-interface ], "remoteReferences": null, "resourceReferences": [ @@ -78,9 +78,9 @@ Invoke the function with the default path. Returns an object such as: } .EXAMPLE -Get-CrossReferencedModuleList -Path './Sql' +Get-CrossReferencedModuleList -Path './sql' -Get only the references of the modules in folder path './Sql' +Get only the references of the modules in folder path './sql' #> function Get-CrossReferencedModuleList { @@ -133,7 +133,7 @@ function Get-CrossReferencedModuleList { # remove leading path elements ($_ -replace '\\', '/') -match '^[\.\/]*(.+)$' } | ForEach-Object { - # We have to differentate the case that the referenced resources is inside or outside the same provider namespace (e.g. '../publicIPAddresses') + # We have to differentate the case that the referenced resources is inside or outside the same provider namespace (e.g. '../public-ip-address') if ($matches[1] -like '*/*') { # Reference outside of namespace $matches[1] diff --git a/utilities/tools/Set-ModuleReadMe.ps1 b/utilities/tools/Set-ModuleReadMe.ps1 index f8049fd829..cbcf718c2b 100644 --- a/utilities/tools/Set-ModuleReadMe.ps1 +++ b/utilities/tools/Set-ModuleReadMe.ps1 @@ -336,7 +336,7 @@ Mandatory. The readme file content array to update Optional. The identifier of the 'outputs' section. Defaults to '## Cross-referenced modules' .EXAMPLE -Set-CrossReferencesSection -ModuleRoot 'C:/KeyVault/vaults' -FullModuleIdentifier 'Microsoft.KeyVault/vaults' -TemplateFileContent @{ resource = @{}; ... } -ReadMeFileContent @('# Title', '', '## Section 1', ...) +Set-CrossReferencesSection -ModuleRoot 'C:/key-vault/vault' -FullModuleIdentifier 'key-vault/vault' -TemplateFileContent @{ resource = @{}; ... } -ReadMeFileContent @('# Title', '', '## Section 1', ...) Update the given readme file's 'Cross-referenced modules' section based on the given template file content #> function Set-CrossReferencesSection { @@ -892,7 +892,7 @@ Optional. A switch to control whether or not to add a ARM-JSON-Parameter file ex Optional. A switch to control whether or not to add a Bicep deployment example. Defaults to true. .EXAMPLE -Set-DeploymentExamplesSection -ModuleRoot 'C:/KeyVault/vaults' -FullModuleIdentifier 'Microsoft.KeyVault/vaults' -TemplateFileContent @{ resource = @{}; ... } -ReadMeFileContent @('# Title', '', '## Section 1', ...) +Set-DeploymentExamplesSection -ModuleRoot 'C:/key-vault/vault' -FullModuleIdentifier 'key-vault/vault' -TemplateFileContent @{ resource = @{}; ... } -ReadMeFileContent @('# Title', '', '## Section 1', ...) Update the given readme file's 'Deployment Examples' section based on the given template file content #> @@ -1393,15 +1393,15 @@ If a readme file does exist, its title and description are updated with whatever Required. The path to the readme file to initialize. .PARAMETER FullModuleIdentifier -Required. The full identifier of the module. For example: 'sql/managed-instances/administrators' +Required. The full identifier of the module. For example: 'sql/managed-instance/administrator' .PARAMETER TemplateFileContent Mandatory. The template file content object to crawl data from .EXAMPLE -Initialize-ReadMe -ReadMeFilePath 'C:/ResourceModules/modules/sql/managed-instances/administrators/readme.md' -FullModuleIdentifier 'sql/managed-instances/administrators' -TemplateFileContent @{ resource = @{}; ... } +Initialize-ReadMe -ReadMeFilePath 'C:/ResourceModules/modules/sql/managed-instances/administrators/readme.md' -FullModuleIdentifier 'sql/managed-instance/administrator' -TemplateFileContent @{ resource = @{}; ... } -Initialize the readme of the 'sql/managed-instances/administrators' module +Initialize the readme of the 'sql/managed-instance/administrator' module #> function Initialize-ReadMe { @@ -1525,7 +1525,7 @@ Set-ModuleReadMe -TemplateFilePath 'C:/network/load-balancer/main.bicep' -ReadMe Generate the Module ReadMe files into a specific folder path .EXAMPLE -$templatePaths = (Get-ChildItem 'C:/Network' -Filter 'main.bicep' -Recurse).FullName +$templatePaths = (Get-ChildItem 'C:/network' -Filter 'main.bicep' -Recurse).FullName $templatePaths | ForEach-Object -Parallel { . '/utilities/tools/Set-ModuleReadMe.ps1' ; Set-ModuleReadMe -TemplateFilePath $_ } Generate the Module ReadMe for any template in a folder path @@ -1595,7 +1595,7 @@ function Set-ModuleReadMe { $moduleRoot = Split-Path $TemplateFilePath -Parent $fullModuleIdentifier = $moduleRoot.Replace('\', '/').split('modules/')[1] # Custom modules are modules having the same resource type but different properties based on the name - # E.g., web/sites/config--appsettings vs web/sites/config--authsettingsv2 + # E.g., web/site/config--appsetting vs web/site/config--authsettingv2 $customModuleSeparator = '--' if ($fullModuleIdentifier.Contains($customModuleSeparator)) { $fullModuleIdentifier = $fullModuleIdentifier.split($customModuleSeparator)[0] diff --git a/utilities/tools/Test-ModuleLocally.ps1 b/utilities/tools/Test-ModuleLocally.ps1 index 535b502c3a..cc291faa18 100644 --- a/utilities/tools/Test-ModuleLocally.ps1 +++ b/utilities/tools/Test-ModuleLocally.ps1 @@ -33,8 +33,8 @@ Optional. A hashtable parameter that contains custom tokens to be replaced in th .EXAMPLE $TestModuleLocallyInput = @{ - TemplateFilePath = 'C:\Network\routeTables\main.bicep' - ModuleTestFilePath = 'C:\Network\routeTables\.test\parameters.json' + TemplateFilePath = 'C:\network\route-table\main.bicep' + ModuleTestFilePath = 'C:\network\route-table\.test\parameters.json' PesterTest = $false DeploymentTest = $false ValidationTest = $true @@ -56,8 +56,8 @@ Run a Test-Az*Deployment using a specific parameter-template combination with th .EXAMPLE $TestModuleLocallyInput = @{ - TemplateFilePath = 'C:\Network\routeTables\main.bicep' - ModuleTestFilePath = 'C:\Network\routeTables\.test\common\main.test.bicep' + TemplateFilePath = 'C:\network\route-table\main.bicep' + ModuleTestFilePath = 'C:\network\route-table\.test\common\main.test.bicep' PesterTest = $false DeploymentTest = $false ValidationTest = $true @@ -79,7 +79,7 @@ Run a Test-Az*Deployment using a test file with the provided tokens .EXAMPLE $TestModuleLocallyInput = @{ - TemplateFilePath = 'C:\Network\routeTables\main.bicep' + TemplateFilePath = 'C:\network\route-table\main.bicep' PesterTest = $true DeploymentTest = $false ValidationTest = $true @@ -101,7 +101,7 @@ Run all Pester tests for a given template and a Test-Az*Deployment using each te .EXAMPLE $TestModuleLocallyInput = @{ - TemplateFilePath = 'C:\Network\routeTables\main.bicep' + TemplateFilePath = 'C:\network\route-table\main.bicep' PesterTest = $true } Test-ModuleLocally @TestModuleLocallyInput -Verbose @@ -111,7 +111,7 @@ Run all Pester tests for the given template file .EXAMPLE $TestModuleLocallyInput = @{ - TemplateFilePath = 'C:\Network\routeTables\main.bicep' + TemplateFilePath = 'C:\network\route-table\main.bicep' PesterTest = $true ValidateOrDeployParameters = @{ SubscriptionId = '00000000-0000-0000-0000-000000000000' @@ -180,12 +180,12 @@ function Test-ModuleLocally { } # Construct Token Configuration Input - $GlobalVariablesObject = Get-Content -Path (Join-Path $repoRootPath 'settings.yml') | ConvertFrom-Yaml -ErrorAction Stop | Select-Object -ExpandProperty variables + $GlobalVariablesObject = Get-Content -Path (Join-Path $repoRootPath 'settings.yml') | ConvertFrom-Yaml -ErrorAction Stop | Select-Object -ExpandProperty 'variables' $tokenConfiguration = @{ FilePathList = $moduleTestFiles Tokens = @{} - TokenPrefix = $GlobalVariablesObject | Select-Object -ExpandProperty tokenPrefix - TokenSuffix = $GlobalVariablesObject | Select-Object -ExpandProperty tokenSuffix + TokenPrefix = $GlobalVariablesObject | Select-Object -ExpandProperty 'tokenPrefix' + TokenSuffix = $GlobalVariablesObject | Select-Object -ExpandProperty 'tokenSuffix' } # Add Enforced Tokens diff --git a/utilities/tools/Update-RoleAssignmentList.ps1 b/utilities/tools/Update-RoleAssignmentList.ps1 index ab0023d5c1..e66d8e5028 100644 --- a/utilities/tools/Update-RoleAssignmentList.ps1 +++ b/utilities/tools/Update-RoleAssignmentList.ps1 @@ -12,9 +12,9 @@ Mandatory. The Provider Namespace to fetch the role definitions for Mandatory. The ResourceType to fetch the role definitions for .EXAMPLE -Update-RoleAssignmentListInner -ProviderNamespace 'Microsoft.KeyVault' -ResourceType 'vaults' +Update-RoleAssignmentListInner -ProviderNamespace 'key-vault' -ResourceType 'vault' -Update nested_roleassignments.bicep template for [Microsoft.KeyVault/vaults] module with latest available Role Definitions +Update nested_roleassignments.bicep template for module [key-vault/vault] with latest available Role Definitions #> function Update-RoleAssignmentListInner { @@ -55,11 +55,11 @@ function Update-RoleAssignmentListInner { ## Create array of file names ## ################################## $filesToProcess = @() - if ("$ProviderNamespace/$ResourceType" -eq 'Microsoft.Authorization/RoleAssignments') { - # for the module 'Microsoft.Authorization/RoleAssignments' looking recursiverly for + if ("$ProviderNamespace/$ResourceType" -eq 'authorization/role-assignment') { + # for the module 'authorization/role-assignment' looking recursiverly for # all 'main.bicep' files in the module folder Set-Location $modulesPath - $searchFile = Join-Path $modulesPath 'Microsoft.Authorization' 'roleAssignments' '**' 'main.bicep' + $searchFile = Join-Path $modulesPath 'authorization' 'role-assignment' '**' 'main.bicep' $rbacPathList = Get-ChildItem -Path $searchFile -Recurse foreach ($item in $rbacPathList) { $FullFilePath = $item.FullName @@ -115,9 +115,9 @@ Update-RoleAssignmentList Update all nested_roleassignments.bicep found in the library with latest available Role Definitions .EXAMPLE -Update-RoleAssignmentList -ProviderNamespace 'Microsoft.KeyVault' -ResourceType 'vaults' +Update-RoleAssignmentList -ProviderNamespace 'key-vault' -ResourceType 'vault' -Update nested_roleassignments.bicep template for [Microsoft.KeyVault/vaults] module with latest available Role Definitions +Update nested_roleassignments.bicep template for module [key-vault/vault] with latest available Role Definitions #> function Update-RoleAssignmentList { @@ -163,11 +163,11 @@ function Update-RoleAssignmentList { $null = Update-RoleAssignmentListInner -ProviderNamespace $provider -ResourceType $type -Verbose } } - # also updating the roles in the [Microsoft.Authorization/RoleAssignments] module, + # also updating the roles in the [authorization/role-assignments] module, # which needs to be triggered separately, as the roles are not stored in the nested_roleAssignments.bicep # and therefore it's not detected by the search - if ($PSCmdlet.ShouldProcess('Role Assignments for module [Microsoft.Authorization/RoleAssignments]', 'Update')) { - $null = Update-RoleAssignmentListInner -ProviderNamespace 'Microsoft.Authorization' -ResourceType 'RoleAssignments' -Verbose + if ($PSCmdlet.ShouldProcess('Role Assignments for module [authorization/role-assignments]', 'Update')) { + $null = Update-RoleAssignmentListInner -ProviderNamespace 'authorization' -ResourceType 'role-assignments' -Verbose } } } diff --git a/utilities/tools/helper/Get-ModulesAsMarkdownTable.ps1 b/utilities/tools/helper/Get-ModulesAsMarkdownTable.ps1 index f5ccbdfb3e..7b4baa2d6f 100644 --- a/utilities/tools/helper/Get-ModulesAsMarkdownTable.ps1 +++ b/utilities/tools/helper/Get-ModulesAsMarkdownTable.ps1 @@ -61,9 +61,9 @@ Extract the resource name from the provided module path's readme Mandatory. The path to the module to process .EXAMPLE -Get-ResourceModuleName -path 'C:\KeyVault' +Get-ResourceModuleName -path 'C:\key-vault\vault' -Get the resource name defined in the KeyVault-Module's readme. E.g. 'Key Vault' +Get the resource name defined in the 'key-vault\vault'-module's readme. E.g. 'Key Vault' #> function Get-ResourceModuleName { @@ -150,9 +150,9 @@ In other words, a module would contain a folder with e.g. a '.test' folder and w Mandatory. The path to search in. .EXAMPLE -Measure-FolderHasNestedModule -path 'C:\dev\ApiManagement' +Measure-FolderHasNestedModule -path 'C:\dev\api-management' -Check if the path 'C:\dev\ApiManagement' contains any number of nested modules +Check if the path 'C:\dev\api-management' contains any number of nested modules #> function Measure-FolderHasNestedModule { @@ -208,9 +208,9 @@ Mandatory. The name of the repository the code resides in Mandatory. The name of the Organization the code resides in .EXAMPLE -Get-ResolvedSubServiceRow -subPath 'C:\dev\ApiManagement\serviceResources' -concatedBase "ApiManagement\serviceResources" -output @() -provider 'ApiManagement' -ColumnsInOrder @('Name','ProviderNamespace') -SortByColumn 'Name' +Get-ResolvedSubServiceRow -subPath 'C:\dev\api-management\api' -concatedBase "api-management\api" -output @() -provider 'api-management' -ColumnsInOrder @('Name','ProviderNamespace') -SortByColumn 'Name' -Adds a hashtable like @{ Name = 'API Management'; 'Provider Namespace' = `ApiManagement` }. As the specified column for sorting is 'Name', the 'Provider Namespace' will be added to each entry. +Adds a hashtable like @{ Name = 'API Management'; 'Provider Namespace' = `api-management` }. As the specified column for sorting is 'Name', the 'Provider Namespace' will be added to each entry. #> function Get-ResolvedSubServiceRow { @@ -343,10 +343,10 @@ Where sub-resources are part of a subfolder [Resources] Results in a table like - "| Name | Provider namespace | Resource Type |" - "| ------------------------------ | ------------------ | ------------------------------------------------------------------------------- |" - "| SQL Managed Instances | `Sql` | [managedInstances](Sql/managedInstances) |" - "| SQL Managed Instances Database | | [managedInstances\databases](Sql\managedInstancesResources\databases) |" + "| Name | Provider namespace | Resource Type |" + "| ------------------------------ | ------------------ | ------------------------------------------------------------|" + "| SQL Managed Instances | `Sql` | [managedInstances](sql/managed-instance) |" + "| SQL Managed Instances Database | | [managedInstances/databases](sql/managed-instance/database) |" .PARAMETER Path Mandatory. The path to resolve @@ -374,29 +374,29 @@ Mandatory. The DevOps environment to generate the status badges for Optional. The project the repository is hosted in. Required if the 'environment' is 'ADO' .EXAMPLE -Get-ModulesAsMarkdownTable -path 'C:\dev\Modules' +Get-ModulesAsMarkdownTable -path 'C:\dev\modules' -Generate a markdown table for all modules in path 'C:\dev\Modules' with all default columns, sorted by 'Provider Namespace' +Generate a markdown table for all modules in path 'C:\dev\modules' with all default columns, sorted by 'Provider Namespace' .EXAMPLE -Get-ModulesAsMarkdownTable -path 'C:\dev\Modules' -ColumnsInOrder @('Resource Type', 'Name') +Get-ModulesAsMarkdownTable -path 'C:\dev\modules' -ColumnsInOrder @('Resource Type', 'Name') -Generate a markdown table for all modules in path 'C:\dev\Modules' with only the 'Resource Type' & 'Name' columns, sorted by 'Provider Namespace' +Generate a markdown table for all modules in path 'C:\dev\modules' with only the 'Resource Type' & 'Name' columns, sorted by 'Provider Namespace' .EXAMPLE -Get-ModulesAsMarkdownTable -path 'C:\dev\Modules' -ColumnsInOrder @('Resource Type', 'Name') -SortByColumn 'Name' +Get-ModulesAsMarkdownTable -path 'C:\dev\modules' -ColumnsInOrder @('Resource Type', 'Name') -SortByColumn 'Name' -Generate a markdown table for all modules in path 'C:\dev\Modules' with only the 'Resource Type' & 'Name' columns, , sorted by 'Name' +Generate a markdown table for all modules in path 'C:\dev\modules' with only the 'Resource Type' & 'Name' columns, , sorted by 'Name' .EXAMPLE Get-ModulesAsMarkdownTable -path 'C:\dev\ip\Azure-ResourceModules\ResourceModules\modules' -RepositoryName 'ResourceModules' -Organization 'Azure' -ColumnsInOrder @('Name','TemplateType','Status','Deploy') -Environment 'GitHub' -Generate a markdown table for all modules in path 'C:\dev\Modules' with only the 'Name', 'TemplateType', 'Status' &'Deploy' columns, sorted by 'Name' for GitHub +Generate a markdown table for all modules in path 'C:\dev\modules' with only the 'Name', 'TemplateType', 'Status' &'Deploy' columns, sorted by 'Name' for GitHub .EXAMPLE Get-ModulesAsMarkdownTable -path 'C:\dev\ip\Azure-ResourceModules\ResourceModules\modules' -RepositoryName 'ResourceModules' -Organization 'CARML' -ProjectName 'ResourceModules' -Environment 'ADO' -ColumnsInOrder @('Name', 'TemplateType', 'Status', 'Deploy') -Generate a markdown table for all modules in path 'C:\dev\Modules' with only the 'Name', 'TemplateType', 'Status' & 'Deploy' columns, sorted by 'Name' for Azure DevOps +Generate a markdown table for all modules in path 'C:\dev\modules' with only the 'Name', 'TemplateType', 'Status' & 'Deploy' columns, sorted by 'Name' for Azure DevOps #> function Get-ModulesAsMarkdownTable { From 9c582b4449a5220cad5d9eb2c80cb2748a650a52 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Sun, 30 Jul 2023 17:14:24 +0200 Subject: [PATCH 03/13] Updated pipelines folder --- .../New-TemplateDeployment.ps1 | 10 +++--- ...ModulesMissingFromPrivateBicepRegistry.ps1 | 18 +++++----- .../Get-ModulesMissingFromTemplateSpecsRG.ps1 | 34 +++++++++---------- ...dulesMissingFromUniversalArtifactsFeed.ps1 | 10 +++--- .../resourcePublish/Get-ModulesToPublish.ps1 | 30 ++++++++-------- .../Get-PrivateRegistryRepositoryName.ps1 | 4 +-- .../resourcePublish/Get-TemplateSpecsName.ps1 | 10 +++--- .../Get-UniversalArtifactsName.ps1 | 4 +-- .../Publish-ModuleToPrivateBicepRegistry.ps1 | 4 +-- .../Publish-ModuleToTemplateSpecsRG.ps1 | 4 +-- ...Publish-ModuleToUniversalArtifactsFeed.ps1 | 4 +-- .../sharedScripts/Get-ModuleTestFileList.ps1 | 10 +++--- .../sharedScripts/Get-NestedResourceList.ps1 | 3 +- 13 files changed, 72 insertions(+), 73 deletions(-) diff --git a/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 b/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 index ad5bafbdec..39305b0e85 100644 --- a/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 +++ b/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 @@ -362,7 +362,7 @@ Optional. ID of the subscription to deploy into. Mandatory if deploying into a s Optional. Name of the management group to deploy into. Mandatory if deploying into a management group (management group level) .PARAMETER additionalTags -Optional. Provde a Key Value Pair (Object) that will be appended to the Parameter file tags. Example: @{myKey = 'myValue',myKey2 = 'myValue2'}. +Optional. Provde a Key Value Pair (Object) that will be appended to the Parameter file tags. Example: @{myKey = 'myValue', myKey2 = 'myValue2'}. .PARAMETER additionalParameters Optional. Additional parameters you can provide with the deployment. E.g. @{ resourceGroupName = 'myResourceGroup' } @@ -376,17 +376,17 @@ Optional. Do not throw an exception if it failed. Still returns the error messag .EXAMPLE New-TemplateDeployment -templateFilePath 'C:/key-vault/vault/main.bicep' -parameterFilePath 'C:/key-vault/vault/.test/parameters.json' -location 'WestEurope' -resourceGroupName 'aLegendaryRg' -Deploy the main.bicep of the KeyVault module with the parameter file 'parameters.json' using the resource group 'aLegendaryRg' in location 'WestEurope' +Deploy the main.bicep of the 'key-vault/vault' module with the parameter file 'parameters.json' using the resource group 'aLegendaryRg' in location 'WestEurope' .EXAMPLE New-TemplateDeployment -templateFilePath 'C:/resources/resource-group/main.bicep' -location 'WestEurope' -Deploy the main.bicep of the ResourceGroup module in location 'WestEurope' without a parameter file +Deploy the main.bicep of the 'resources/resource-group' module in location 'WestEurope' without a parameter file .EXAMPLE -New-TemplateDeployment -templateFilePath 'C:/ResourceGroup/main.json' -parameterFilePath 'C:/ResourceGroup/.test/parameters.json' -location 'WestEurope' +New-TemplateDeployment -templateFilePath 'C:/resources/resource-group/main.json' -parameterFilePath 'C:/resources/resource-group/.test/parameters.json' -location 'WestEurope' -Deploy the main.json of the ResourceGroup module with the parameter file 'parameters.json' in location 'WestEurope' +Deploy the main.json of the 'resources/resource-group' module with the parameter file 'parameters.json' in location 'WestEurope' #> function New-TemplateDeployment { diff --git a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromPrivateBicepRegistry.ps1 b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromPrivateBicepRegistry.ps1 index 930da05b94..aa31cbbecb 100644 --- a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromPrivateBicepRegistry.ps1 +++ b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromPrivateBicepRegistry.ps1 @@ -19,7 +19,7 @@ Optional. Publish an absolute latest version. Note: This version may include breaking changes and is not recommended for production environments .EXAMPLE -Get-ModulesMissingFromPrivateBicepRegistry -TemplateFilePath 'C:\ResourceModules\modules\compute\virtual-machines\main.bicep' -BicepRegistryName 'adpsxxazacrx001' -BicepRegistryRgName 'artifacts-rg' +Get-ModulesMissingFromPrivateBicepRegistry -TemplateFilePath 'C:\ResourceModules\modules\compute\virtual-machine\main.bicep' -BicepRegistryName 'adpsxxazacrx001' -BicepRegistryRgName 'artifacts-rg' Check if either the Virtual Machine module or any of its children (e.g. 'extension') is missing in the Container Registry 'adpsxxazacrx001' of Resource Group 'artifacts-rg' @@ -27,21 +27,21 @@ Returns for example: Name Value ---- ----- Version 0.4.0 -TemplateFilePath C:\ResourceModules\modules\compute\virtual-machines\extensions\main.bicep +TemplateFilePath C:\ResourceModules\modules\compute\virtual-machine\extension\main.bicep Version 0.4 -TemplateFilePath C:\ResourceModules\modules\compute\virtual-machines\extensions\main.bicep +TemplateFilePath C:\ResourceModules\modules\compute\virtual-machine\extension\main.bicep Version 0 -TemplateFilePath C:\ResourceModules\modules\compute\virtual-machines\extensions\main.bicep +TemplateFilePath C:\ResourceModules\modules\compute\virtual-machine\extension\main.bicep Version latest -TemplateFilePath C:\ResourceModules\modules\compute\virtual-machines\extensions\main.bicep +TemplateFilePath C:\ResourceModules\modules\compute\virtual-machine\extension\main.bicep Version 0.6.0 -TemplateFilePath C:\ResourceModules\modules\compute\virtual-machines\main.bicep +TemplateFilePath C:\ResourceModules\modules\compute\virtual-machine\main.bicep Version 0.6 -TemplateFilePath C:\ResourceModules\modules\compute\virtual-machines\main.bicep +TemplateFilePath C:\ResourceModules\modules\compute\virtual-machine\main.bicep Version 0 -TemplateFilePath C:\ResourceModules\modules\compute\virtual-machines\main.bicep +TemplateFilePath C:\ResourceModules\modules\compute\virtual-machine\main.bicep Version latest -TemplateFilePath C:\ResourceModules\modules\compute\virtual-machines\main.bicep +TemplateFilePath C:\ResourceModules\modules\compute\virtual-machine\main.bicep #> function Get-ModulesMissingFromPrivateBicepRegistry { diff --git a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromTemplateSpecsRG.ps1 b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromTemplateSpecsRG.ps1 index 8cb9a05f9b..64228c088e 100644 --- a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromTemplateSpecsRG.ps1 +++ b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromTemplateSpecsRG.ps1 @@ -16,7 +16,7 @@ Optional. Publish an absolute latest version. Note: This version may include breaking changes and is not recommended for production environments .EXAMPLE -Get-ModulesMissingFromTemplateSpecsRG -TemplateFilePath 'C:\ResourceModules\modules\key-vault\vaults\main.bicep' -TemplateSpecsRGName 'artifacts-rg' +Get-ModulesMissingFromTemplateSpecsRG -TemplateFilePath 'C:\ResourceModules\modules\key-vault\vault\main.bicep' -TemplateSpecsRGName 'artifacts-rg' Check if either the Key Vault module or any of its children (e.g. 'secret') is missing in the Resource Group 'artifacts-rg' @@ -24,37 +24,37 @@ Returns for example: Name Value ---- ----- Version 0.4.0 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\access-policies\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\access-policy\main.bicep Version 0.4 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\access-policies\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\access-policy\main.bicep Version 0 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\access-policies\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\access-policy\main.bicep Version latest -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\access-policies\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\access-policy\main.bicep Version 0.4.0 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\keys\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\key\main.bicep Version 0.4 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\keys\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\key\main.bicep Version 0 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\keys\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\key\main.bicep Version latest -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\keys\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\key\main.bicep Version 0.4.0 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\secrets\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\secret\main.bicep Version 0.4 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\secrets\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\secret\main.bicep Version 0 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\secrets\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\secret\main.bicep Version latest -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\secrets\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\secret\main.bicep Version 0.5.0 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\main.bicep Version 0.5 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\main.bicep Version 0 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\main.bicep Version latest -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\main.bicep #> function Get-ModulesMissingFromTemplateSpecsRG { diff --git a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromUniversalArtifactsFeed.ps1 b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromUniversalArtifactsFeed.ps1 index 4e5a064e09..339d16d425 100644 --- a/utilities/pipelines/resourcePublish/Get-ModulesMissingFromUniversalArtifactsFeed.ps1 +++ b/utilities/pipelines/resourcePublish/Get-ModulesMissingFromUniversalArtifactsFeed.ps1 @@ -24,7 +24,7 @@ Example: 'Artifacts'. Optional. The bearer token to use to authenticate the request. If not provided it MUST be existing in your environment as `$env:TOKEN` .EXAMPLE -Get-ModulesMissingFromUniversalArtifactsFeed -TemplateFilePath 'C:\modules\key-vault\vaults\main.bicep' -vstsOrganizationUri 'https://dev.azure.com/fabrikam' -VstsProject 'IaC' -VstsFeedName 'Artifacts' +Get-ModulesMissingFromUniversalArtifactsFeed -TemplateFilePath 'C:\modules\key-vault\vault\main.bicep' -vstsOrganizationUri 'https://dev.azure.com/fabrikam' -VstsProject 'IaC' -VstsFeedName 'Artifacts' Check if either the Key Vault module or any of its children (e.g. 'secret') is missing in artifacts feed 'Artifacts' of Azure DevOps project 'https://dev.azure.com/fabrikam/IaC' @@ -32,13 +32,13 @@ Returns for example: Name Value ---- ----- Version 0.4.0 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\access-policies\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\access-policy\main.bicep Version 0.4.0 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\keys\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\key\main.bicep Version 0.4.0 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\secrets\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\secret\main.bicep Version 0.5.0 -TemplateFilePath C:\ResourceModules\modules\key-vault\vaults\main.bicep +TemplateFilePath C:\ResourceModules\modules\key-vault\vault\main.bicep #> function Get-ModulesMissingFromUniversalArtifactsFeed { diff --git a/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 b/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 index f373015e26..9ac9320207 100644 --- a/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 +++ b/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 @@ -79,9 +79,9 @@ This function will search the current directory and all parent directories for a Mandatory. Path to the folder/file that should be searched .EXAMPLE -Find-TemplateFile -Path "C:\Repos\Azure\ResourceModules\modules\storage\storage-accounts\table-services\tables\.bicep\nested_roleAssignments.bicep" +Find-TemplateFile -Path "C:\Repos\Azure\ResourceModules\modules\storage\storage-account\table-service\table\.bicep\nested_roleAssignments.bicep" - Directory: C:\Repos\Azure\ResourceModules\modules\storage\storage-accounts\table-services\tables + Directory: C:\Repos\Azure\ResourceModules\modules\storage\storage-account\table-service\table Mode LastWriteTime Length Name ---- ------------- ------ ---- @@ -126,12 +126,12 @@ Find the closest main.bicep/json file to the changed files in the module folder Mandatory. Path to the main/parent module folder. .EXAMPLE -Get-TemplateFileToPublish -ModuleFolderPath "C:\Repos\Azure\ResourceModules\modules\storage\storage-accounts\" +Get-TemplateFileToPublish -ModuleFolderPath "C:\Repos\Azure\ResourceModules\modules\storage\storage-account\" -C:\Repos\Azure\ResourceModules\modules\storage\storage-accounts\table-services\tables\main.bicep +C:\Repos\Azure\ResourceModules\modules\storage\storage-account\table-service\table\main.bicep Gets the closest main.bicep/json file to the changed files in the module folder structure. -Assuming there is a changed file in 'Microsoft.Storage\storageAccounts\tableServices\tables' +Assuming there is a changed file in 'storage\storage-account\table-service\table' the function would return the main.bicep file in the same folder. #> @@ -179,15 +179,15 @@ Mandatory. Path to a main.bicep/json file. Optional. If true, the function will recurse up the folder structure to find the closest main.bicep/json file. .EXAMPLE -Get-ParentModuleTemplateFile -TemplateFilePath 'C:\Repos\Azure\ResourceModules\modules\storage\storage-accounts\table-services\tables\main.bicep' -Recurse +Get-ParentModuleTemplateFile -TemplateFilePath 'C:\Repos\Azure\ResourceModules\modules\storage\storage-account\table-service\table\main.bicep' -Recurse - Directory: C:\Repos\Azure\ResourceModules\modules\storage\storage-accounts\tableServices + Directory: C:\Repos\Azure\ResourceModules\modules\storage\storage-account\tableService Mode LastWriteTime Length Name ---- ------------- ------ ---- la--- 05.12.2021 22:45 1427 main.bicep - Directory: C:\Repos\Azure\ResourceModules\modules\storage\storage-accounts + Directory: C:\Repos\Azure\ResourceModules\modules\storage\storage-account Mode LastWriteTime Length Name ---- ------------- ------ ---- @@ -268,7 +268,7 @@ The file needs to be in the same folder as the template file itself. Mandatory. Path to a main.bicep/json file. .EXAMPLE -Get-ModuleVersionFromFile -TemplateFilePath 'C:\Repos\Azure\ResourceModules\modules\storage\storage-accounts\table-services\tables\main.bicep' +Get-ModuleVersionFromFile -TemplateFilePath 'C:\Repos\Azure\ResourceModules\modules\storage\storage-account\table-service\table\main.bicep' 0.3 @@ -307,11 +307,11 @@ Patch version number is calculated based on the git commit count on the branch. Mandatory. Path to a main.bicep/json file. .EXAMPLE -Get-NewModuleVersion -TemplateFilePath 'C:\Repos\Azure\ResourceModules\modules\storage\storage-accounts\table-services\tables\main.bicep' +Get-NewModuleVersion -TemplateFilePath 'C:\Repos\Azure\ResourceModules\modules\storage\storage-account\table-service\table\main.bicep' 0.3.630 -Generates a new version for the tables module. +Generates a new version for the table module. #> function Get-NewModuleVersion { @@ -351,15 +351,15 @@ Optional. Publish an absolute latest version. Note: This version may include breaking changes and is not recommended for production environments .EXAMPLE -Get-ModulesToPublish -TemplateFilePath 'C:\Repos\Azure\ResourceModules\modules\storage\storage-accounts\main.bicep' +Get-ModulesToPublish -TemplateFilePath 'C:\Repos\Azure\ResourceModules\modules\storage\storage-account\main.bicep' Name Value ---- ----- -TemplateFilePath C:\Repos\Azure\ResourceModules\modules\storage\storage-accounts\file-services\shares\main.bicep +TemplateFilePath C:\Repos\Azure\ResourceModules\modules\storage\storage-account\file-service\share\main.bicep Version 0.3.848-prerelease -TemplateFilePath C:\Repos\Azure\ResourceModules\modules\storage\storage-accounts\file-services\main.bicep +TemplateFilePath C:\Repos\Azure\ResourceModules\modules\storage\storage-account\file-service\main.bicep Version 0.3.848-prerelease -TemplateFilePath C:\Repos\Azure\ResourceModules\modules\storage\storage-accounts\main.bicep +TemplateFilePath C:\Repos\Azure\ResourceModules\modules\storage\storage-account\main.bicep Version 0.3.848-prerelease Generates a hashtable with template file paths to publish and their new versions. diff --git a/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 b/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 index b6fc626b94..7b93cb8ca0 100644 --- a/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-PrivateRegistryRepositoryName.ps1 @@ -9,9 +9,9 @@ Convert the given template file path into a valid Container Registry repository Mandatory. The template file path to convert .EXAMPLE -Get-PrivateRegistryRepositoryName -TemplateFilePath 'C:\modules\key-vault\vaults\main.bicep' +Get-PrivateRegistryRepositoryName -TemplateFilePath 'C:\modules\key-vault\vault\main.bicep' -Convert 'C:\modules\key-vault\vaults\main.bicep' to e.g. 'bicep/modules/keyvault.vaults' +Convert 'C:\modules\key-vault\vault\main.bicep' to e.g. 'bicep/modules/key-vault.vault' #> function Get-PrivateRegistryRepositoryName { diff --git a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 index 257d12d158..3c880a5eaf 100644 --- a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 @@ -9,9 +9,9 @@ Convert the given template file path into a valid Template Specs repository name Mandatory. The template file path to convert .EXAMPLE -Get-TemplateSpecsName -TemplateFilePath 'C:\modules\key-vault\vaults\main.bicep' +Get-TemplateSpecsName -TemplateFilePath 'C:\modules\key-vault\vault\main.bicep' -Convert 'C:\modules\key-vault\vaults\main.bicep' to e.g. 'microsoft.keyvault.vaults' +Convert 'C:\modules\key-vault\vault\main.bicep' to e.g. 'microsoft.key-vault.vault' #> function Get-TemplateSpecsName { @@ -26,8 +26,8 @@ function Get-TemplateSpecsName { $templateSpecIdentifier = $templateSpecIdentifier -replace 'microsoft', 'ms' # Shorten the name - # This is requried as certain modules generate names such as `MS.RecoveryServices.vaults.replicationFabrics.replicationProtectionContainers.replicationProtectionContainerMappings` which are longer than the allowed 90 characters for template specs - # Using the logic below, the name is shortened to `MS.RecoveryServices.vaults.replicationFabrics.replicationProtectionContainers.Mappings` which has 'only' 86 characters + # This is requried as certain modules generate names such as `ms.recovery-services.vault.replication-fabric.replication-protection-container.replication-protection-container-mapping` which are longer than the allowed 90 characters for template specs + # Using the logic below, the name is shortened to `ms.recovery-services.vault.replication-fabric.replication-protection-container.mapping` which has 'only' 86 characters $nameElems = $templateSpecIdentifier -split '\.' # Starting at index 2 to skip the resource provider for ($index = 2; $index -lt $nameElems.Count; $index++) { @@ -36,7 +36,7 @@ function Get-TemplateSpecsName { $stringToCheck = $nameElems[($index + 1)] # If a name is replicated in a path, it is usually plural in the parent, and singular in the child path. - # For example: /virtualNetworks/ (plural) & /virtualNetworks/virtualNetworkPeerings/ (singular) + # For example: /virtual-networks/ (plural) & /virtual-networks/virtualNetwork-peering/ (singular) # In this case we want to remove the singular version from the subsequent string & format it accordingly if ($stringToRemove.EndsWith('s') -and $stringToCheck.StartsWith($stringToRemove.Substring(0, $stringToRemove.length - 1))) { $singularString = $stringToRemove.Substring(0, $stringToRemove.length - 1) diff --git a/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 b/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 index 7cb01e9d82..95dc5a6a31 100644 --- a/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-UniversalArtifactsName.ps1 @@ -10,9 +10,9 @@ Must be lowercase alphanumerics, dashes, dots or underscores, under 256 characte Mandatory. The template file path to convert .EXAMPLE -Get-UniversalArtifactsName -TemplateFilePath 'C:\modules\key-vault\vaults\main.bicep' +Get-UniversalArtifactsName -TemplateFilePath 'C:\modules\key-vault\vault\main.bicep' -Convert 'C:\modules\key-vault\vaults\main.bicep' to e.g. 'microsoft.keyvault.vaults' +Convert 'C:\modules\key-vault\vault\main.bicep' to e.g. 'microsoft.key-vault.vault' #> function Get-UniversalArtifactsName { diff --git a/utilities/pipelines/resourcePublish/Publish-ModuleToPrivateBicepRegistry.ps1 b/utilities/pipelines/resourcePublish/Publish-ModuleToPrivateBicepRegistry.ps1 index d4ec9284f5..cc5b29b846 100644 --- a/utilities/pipelines/resourcePublish/Publish-ModuleToPrivateBicepRegistry.ps1 +++ b/utilities/pipelines/resourcePublish/Publish-ModuleToPrivateBicepRegistry.ps1 @@ -7,7 +7,7 @@ Publish a new version of a given module to a private bicep registry .PARAMETER TemplateFilePath Mandatory. Path to the module deployment file from root. -Example: 'C:\modules\key-vault\vaults\main.bicep' +Example: 'C:\modules\key-vault\vault\main.bicep' .PARAMETER ModuleVersion Mandatory. Version of the module to publish, following SemVer convention. @@ -26,7 +26,7 @@ Optional. The location of the resourceGroup the private bicep registry is deploy Example: 'West Europe' .EXAMPLE -Publish-ModuleToPrivateBicepRegistry -TemplateFilePath 'C:\modules\key-vault\vaults\main.bicep' -ModuleVersion '3.0.0-alpha' -BicepRegistryName 'adpsxxazacrx001' -BicepRegistryRgName 'artifacts-rg' +Publish-ModuleToPrivateBicepRegistry -TemplateFilePath 'C:\modules\key-vault\vault\main.bicep' -ModuleVersion '3.0.0-alpha' -BicepRegistryName 'adpsxxazacrx001' -BicepRegistryRgName 'artifacts-rg' Try to publish the KeyVault module with version 3.0.0-alpha to a private bicep registry called 'adpsxxazacrx001' in resource group 'artifacts-rg'. #> diff --git a/utilities/pipelines/resourcePublish/Publish-ModuleToTemplateSpecsRG.ps1 b/utilities/pipelines/resourcePublish/Publish-ModuleToTemplateSpecsRG.ps1 index 555a024331..f3a2c1191d 100644 --- a/utilities/pipelines/resourcePublish/Publish-ModuleToTemplateSpecsRG.ps1 +++ b/utilities/pipelines/resourcePublish/Publish-ModuleToTemplateSpecsRG.ps1 @@ -8,7 +8,7 @@ The template spec is set up if not already existing. .PARAMETER TemplateFilePath Mandatory. Path to the module deployment file from root. -Example: 'C:\modules\key-vault\vaults\main.bicep' +Example: 'C:\modules\key-vault\vault\main.bicep' .PARAMETER ModuleVersion Mandatory. Version of the module to publish, following SemVer convention. @@ -27,7 +27,7 @@ Mandatory. The description of the parent template spec. Example: 'iacs key vault' .EXAMPLE -Publish-ModuleToTemplateSpecsRG -TemplateFilePath 'C:\modules\key-vault\vaults\main.bicep' -ModuleVersion '3.0.0-alpha' -TemplateSpecsRgName 'artifacts-rg' -TemplateSpecsRgLocation 'West Europe' -TemplateSpecsDescription 'iacs key vault' +Publish-ModuleToTemplateSpecsRG -TemplateFilePath 'C:\modules\key-vault\vault\main.bicep' -ModuleVersion '3.0.0-alpha' -TemplateSpecsRgName 'artifacts-rg' -TemplateSpecsRgLocation 'West Europe' -TemplateSpecsDescription 'iacs key vault' Try to publish the KeyVault module with version 3.0.0-alpha to a template spec in resource group 'artifacts-rg'. #> diff --git a/utilities/pipelines/resourcePublish/Publish-ModuleToUniversalArtifactsFeed.ps1 b/utilities/pipelines/resourcePublish/Publish-ModuleToUniversalArtifactsFeed.ps1 index 82fd368788..a2e79cf3b7 100644 --- a/utilities/pipelines/resourcePublish/Publish-ModuleToUniversalArtifactsFeed.ps1 +++ b/utilities/pipelines/resourcePublish/Publish-ModuleToUniversalArtifactsFeed.ps1 @@ -38,7 +38,7 @@ Publish a new version of a given module to an Azure DevOps artifact feed as a un .PARAMETER TemplateFilePath Mandatory. Path to the module deployment file from root. -Example: 'C:\modules\key-vault\vaults\main.bicep' +Example: 'C:\modules\key-vault\vault\main.bicep' .PARAMETER ModuleVersion Mandatory. Version of the module to publish, following SemVer convention. @@ -60,7 +60,7 @@ Example: 'Artifacts'. Optional. The bearer token to use to authenticate the request. If not provided it MUST be existing in your environment as `$env:TOKEN` .EXAMPLE -Publish-ModuleToUniversalArtifactsFeed -TemplateFilePath 'C:\modules\key-vault\vaults\main.bicep' -ModuleVersion '3.0.0-alpha' -vstsOrganizationUri 'https://dev.azure.com/fabrikam' -VstsProject 'IaC' -VstsFeedName 'Artifacts' +Publish-ModuleToUniversalArtifactsFeed -TemplateFilePath 'C:\modules\key-vault\vault\main.bicep' -ModuleVersion '3.0.0-alpha' -vstsOrganizationUri 'https://dev.azure.com/fabrikam' -VstsProject 'IaC' -VstsFeedName 'Artifacts' Try to publish the KeyVault module with version 3.0.0-alpha to a Universal Package Feed called 'Artifacts' under the project 'IaC'. #> diff --git a/utilities/pipelines/sharedScripts/Get-ModuleTestFileList.ps1 b/utilities/pipelines/sharedScripts/Get-ModuleTestFileList.ps1 index 2e7c96903f..e0cbac542b 100644 --- a/utilities/pipelines/sharedScripts/Get-ModuleTestFileList.ps1 +++ b/utilities/pipelines/sharedScripts/Get-ModuleTestFileList.ps1 @@ -16,14 +16,14 @@ Optional. The folder to search for files in Optional. The pattern of test files to search for. For example '*.json' .EXAMPLE -Get-ModuleTestFileList -ModulePath 'C:\ResourceModules\modules\compute\virtual-machines' +Get-ModuleTestFileList -ModulePath 'C:\ResourceModules\modules\compute\virtual-machine' -Returns the relative file paths of all test files of the virtual machines module in the default test folder ('.test'). +Returns the relative file paths of all test files of the virtual-machine module in the default test folder ('.test'). .EXAMPLE -Get-ModuleTestFileList -ModulePath 'C:\ResourceModules\modules\compute\virtual-machines' -SearchFolder 'parameters' +Get-ModuleTestFileList -ModulePath 'C:\ResourceModules\modules\compute\virtual-machine' -SearchFolder 'parameters' -Returns the relative file paths of all test files of the virtual machines module in folder 'parameters'. +Returns the relative file paths of all test files of the virtual-machine module in folder 'parameters'. #> function Get-ModuleTestFileList { @@ -43,7 +43,7 @@ function Get-ModuleTestFileList { if (Test-Path (Join-Path $ModulePath $SearchFolder)) { $deploymentTests += (Get-ChildItem -Path (Join-Path $ModulePath $SearchFolder) -Recurse -Include $TestFilePattern -File).FullName | Where-Object { $_ -ne (Join-Path (Join-Path $ModulePath $SearchFolder) 'main.test.bicep') # Excluding PBR test file - } + } } if (-not $deploymentTests) { diff --git a/utilities/pipelines/sharedScripts/Get-NestedResourceList.ps1 b/utilities/pipelines/sharedScripts/Get-NestedResourceList.ps1 index e02ebc87bc..6d4eefd0f3 100644 --- a/utilities/pipelines/sharedScripts/Get-NestedResourceList.ps1 +++ b/utilities/pipelines/sharedScripts/Get-NestedResourceList.ps1 @@ -1,5 +1,4 @@ -#region Helper functions -<# +<# .SYNOPSIS Get a list of all resources (provider + service) in the given template content From d2ee9f8209a22e617f292384c4564290f6a324ce Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Sun, 30 Jul 2023 17:20:22 +0200 Subject: [PATCH 04/13] Update to latest --- utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 index 3c880a5eaf..92a2266faa 100644 --- a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 @@ -36,7 +36,7 @@ function Get-TemplateSpecsName { $stringToCheck = $nameElems[($index + 1)] # If a name is replicated in a path, it is usually plural in the parent, and singular in the child path. - # For example: /virtual-networks/ (plural) & /virtual-networks/virtualNetwork-peering/ (singular) + # For example: /virtual-networks/ (plural) & /virtual-network/virtualNetwork-peering/ (singular) # In this case we want to remove the singular version from the subsequent string & format it accordingly if ($stringToRemove.EndsWith('s') -and $stringToCheck.StartsWith($stringToRemove.Substring(0, $stringToRemove.length - 1))) { $singularString = $stringToRemove.Substring(0, $stringToRemove.length - 1) From 01dde37eb17cf816cecde829faa7c58dc9b57752 Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Mon, 31 Jul 2023 08:47:40 +0200 Subject: [PATCH 05/13] Update utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com> --- .../pipelines/resourceDeployment/New-TemplateDeployment.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 b/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 index 39305b0e85..2b38661165 100644 --- a/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 +++ b/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 @@ -362,7 +362,7 @@ Optional. ID of the subscription to deploy into. Mandatory if deploying into a s Optional. Name of the management group to deploy into. Mandatory if deploying into a management group (management group level) .PARAMETER additionalTags -Optional. Provde a Key Value Pair (Object) that will be appended to the Parameter file tags. Example: @{myKey = 'myValue', myKey2 = 'myValue2'}. +Optional. Provide a Key Value Pair (Object) that will be appended to the Parameter file tags. Example: @{myKey = 'myValue', myKey2 = 'myValue2'}. .PARAMETER additionalParameters Optional. Additional parameters you can provide with the deployment. E.g. @{ resourceGroupName = 'myResourceGroup' } From 44e9dca276c7ae014a50a4d68f298b943b172815 Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Mon, 31 Jul 2023 08:48:47 +0200 Subject: [PATCH 06/13] Update utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com> --- utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 b/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 index 9ac9320207..cde4894745 100644 --- a/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 +++ b/utilities/pipelines/resourcePublish/Get-ModulesToPublish.ps1 @@ -181,7 +181,7 @@ Optional. If true, the function will recurse up the folder structure to find the .EXAMPLE Get-ParentModuleTemplateFile -TemplateFilePath 'C:\Repos\Azure\ResourceModules\modules\storage\storage-account\table-service\table\main.bicep' -Recurse - Directory: C:\Repos\Azure\ResourceModules\modules\storage\storage-account\tableService + Directory: C:\Repos\Azure\ResourceModules\modules\storage\storage-account\table-service Mode LastWriteTime Length Name ---- ------------- ------ ---- From 3ff003c4e4f54a9c7e035b7347ba4a23dc9fbe82 Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Mon, 31 Jul 2023 09:23:39 +0200 Subject: [PATCH 07/13] Update utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com> --- utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 index 92a2266faa..3189095a02 100644 --- a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 @@ -26,7 +26,7 @@ function Get-TemplateSpecsName { $templateSpecIdentifier = $templateSpecIdentifier -replace 'microsoft', 'ms' # Shorten the name - # This is requried as certain modules generate names such as `ms.recovery-services.vault.replication-fabric.replication-protection-container.replication-protection-container-mapping` which are longer than the allowed 90 characters for template specs + # This is required as certain modules generate names such as `ms.recovery-services.vault.replication-fabric.replication-protection-container.replication-protection-container-mapping` which are longer than the allowed 90 characters for template specs # Using the logic below, the name is shortened to `ms.recovery-services.vault.replication-fabric.replication-protection-container.mapping` which has 'only' 86 characters $nameElems = $templateSpecIdentifier -split '\.' # Starting at index 2 to skip the resource provider From 05eaacf2cfec4bb4faed066c9cb8af98f6638a0c Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Mon, 31 Jul 2023 09:23:50 +0200 Subject: [PATCH 08/13] Update utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com> --- utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 index 3189095a02..ed0b14cd30 100644 --- a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 @@ -36,7 +36,7 @@ function Get-TemplateSpecsName { $stringToCheck = $nameElems[($index + 1)] # If a name is replicated in a path, it is usually plural in the parent, and singular in the child path. - # For example: /virtual-networks/ (plural) & /virtual-network/virtualNetwork-peering/ (singular) + # For example: /virtual-networks/ (plural) & /virtual-network/virtual-network-peering/ (singular) # In this case we want to remove the singular version from the subsequent string & format it accordingly if ($stringToRemove.EndsWith('s') -and $stringToCheck.StartsWith($stringToRemove.Substring(0, $stringToRemove.length - 1))) { $singularString = $stringToRemove.Substring(0, $stringToRemove.length - 1) From 7127d9bcfbfaba2c2349791b3c77fff15b7179eb Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Mon, 31 Jul 2023 09:24:03 +0200 Subject: [PATCH 09/13] Update utilities/tools/Update-RoleAssignmentList.ps1 Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com> --- utilities/tools/Update-RoleAssignmentList.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/tools/Update-RoleAssignmentList.ps1 b/utilities/tools/Update-RoleAssignmentList.ps1 index e66d8e5028..5760ed9415 100644 --- a/utilities/tools/Update-RoleAssignmentList.ps1 +++ b/utilities/tools/Update-RoleAssignmentList.ps1 @@ -167,7 +167,7 @@ function Update-RoleAssignmentList { # which needs to be triggered separately, as the roles are not stored in the nested_roleAssignments.bicep # and therefore it's not detected by the search if ($PSCmdlet.ShouldProcess('Role Assignments for module [authorization/role-assignments]', 'Update')) { - $null = Update-RoleAssignmentListInner -ProviderNamespace 'authorization' -ResourceType 'role-assignments' -Verbose + $null = Update-RoleAssignmentListInner -ProviderNamespace 'authorization' -ResourceType 'role-assignment' -Verbose } } } From bac628450629614bd50c03b58babbf1c93839188 Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Mon, 31 Jul 2023 09:24:30 +0200 Subject: [PATCH 10/13] Update utilities/tools/Update-RoleAssignmentList.ps1 Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com> --- utilities/tools/Update-RoleAssignmentList.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/tools/Update-RoleAssignmentList.ps1 b/utilities/tools/Update-RoleAssignmentList.ps1 index 5760ed9415..a89eb43058 100644 --- a/utilities/tools/Update-RoleAssignmentList.ps1 +++ b/utilities/tools/Update-RoleAssignmentList.ps1 @@ -166,7 +166,7 @@ function Update-RoleAssignmentList { # also updating the roles in the [authorization/role-assignments] module, # which needs to be triggered separately, as the roles are not stored in the nested_roleAssignments.bicep # and therefore it's not detected by the search - if ($PSCmdlet.ShouldProcess('Role Assignments for module [authorization/role-assignments]', 'Update')) { + if ($PSCmdlet.ShouldProcess('Role Assignments for module [authorization/role-assignment]', 'Update')) { $null = Update-RoleAssignmentListInner -ProviderNamespace 'authorization' -ResourceType 'role-assignment' -Verbose } } From c9de1259e45d7a2b2b95603a1f99e8c96eeeedef Mon Sep 17 00:00:00 2001 From: Alexander Sehr Date: Mon, 31 Jul 2023 09:24:37 +0200 Subject: [PATCH 11/13] Update utilities/tools/Update-RoleAssignmentList.ps1 Co-authored-by: Erika Gressi <56914614+eriqua@users.noreply.github.com> --- utilities/tools/Update-RoleAssignmentList.ps1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utilities/tools/Update-RoleAssignmentList.ps1 b/utilities/tools/Update-RoleAssignmentList.ps1 index a89eb43058..d103e98080 100644 --- a/utilities/tools/Update-RoleAssignmentList.ps1 +++ b/utilities/tools/Update-RoleAssignmentList.ps1 @@ -163,7 +163,7 @@ function Update-RoleAssignmentList { $null = Update-RoleAssignmentListInner -ProviderNamespace $provider -ResourceType $type -Verbose } } - # also updating the roles in the [authorization/role-assignments] module, + # also updating the roles in the [authorization/role-assignment] module, # which needs to be triggered separately, as the roles are not stored in the nested_roleAssignments.bicep # and therefore it's not detected by the search if ($PSCmdlet.ShouldProcess('Role Assignments for module [authorization/role-assignment]', 'Update')) { From ff639d0b85ada58a41bd0054ad714455eabb6d53 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Tue, 1 Aug 2023 13:55:07 +0200 Subject: [PATCH 12/13] Updated deployment name gen & examples --- .../resourceDeployment/New-TemplateDeployment.ps1 | 14 ++++++++------ .../Initialize-DeploymentRemoval.ps1 | 4 ++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 b/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 index 2b38661165..f2f8a9ff68 100644 --- a/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 +++ b/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 @@ -163,14 +163,16 @@ function New-TemplateDeploymentInner { if ([String]::IsNullOrEmpty($deploymentNamePrefix)) { $deploymentNamePrefix = 'templateDeployment-{0}' -f (Split-Path $templateFilePath -LeafBase) } - if ($templateFilePath -match '.*(\\|\/)Microsoft.+') { + + $modulesRegex = '.+[\\|\/]modules[\\|\/]' + if ($templateFilePath -match $modulesRegex) { # If we can assume we're operating in a module structure, we can further fetch the provider namespace & resource type - $shortPathElem = (($templateFilePath -split 'Microsoft\.')[1] -replace '\\', '/') -split '/' # e.g., AppConfiguration, configurationStores, .test, common, main.test.bicep - $providerNamespace = $shortPathElem[0] # e.g., AppConfiguration - $providerNamespaceShort = ($providerNamespace -creplace '[^A-Z]').ToLower() # e.g., ac + $shortPathElem = (($templateFilePath -split $modulesRegex)[1] -replace '\\', '/') -split '/' # e.g., app-configuration, configuration-store, .test, common, main.test.bicep + $providerNamespace = $shortPathElem[0] # e.g., app-configuration + $providerNamespaceShort = ($providerNamespace -split '-' | ForEach-Object { $_[0] }) -join '' # e.g., ac - $resourceType = $shortPathElem[1] # e.g., configurationStores - $resourceTypeShort = ('{0}{1}' -f ($resourceType.ToLower())[0], ($resourceType -creplace '[^A-Z]')).ToLower() # e.g. cs + $resourceType = $shortPathElem[1] # e.g., configuration-store + $resourceTypeShort = ($resourceType -split '-' | ForEach-Object { $_[0] }) -join '' # e.g. cs $testFolderShort = Split-Path (Split-Path $templateFilePath -Parent) -Leaf # e.g., common diff --git a/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 b/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 index 4462fffdcb..3c2b11eeec 100644 --- a/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 +++ b/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 @@ -18,9 +18,9 @@ Optional. The name of the resource group the deployment was happening in. Releva Optional. The ID of the management group to fetch deployments from. Relevant for management-group level deployments. .EXAMPLE -Initialize-DeploymentRemoval -DeploymentName 'virtualWans-20211204T1812029146Z' -TemplateFilePath "$home/ResourceModules/modules/network/virtual-wan/main.bicep" -resourceGroupName 'test-virtualWan-rg' +Initialize-DeploymentRemoval -DeploymentName 'n-vw-t1-20211204T1812029146Z' -TemplateFilePath "$home/ResourceModules/modules/network/virtual-wan/main.bicep" -resourceGroupName 'test-virtualWan-rg' -Remove the deployment 'virtualWans-20211204T1812029146Z' from resource group 'test-virtualWan-rg' that was executed using template in path "$home/ResourceModules/modules/network/virtual-wan/main.bicep" +Remove the deployment 'n-vw-t1-20211204T1812029146Z' from resource group 'test-virtualWan-rg' that was executed using template in path "$home/ResourceModules/modules/network/virtual-wan/main.bicep" #> function Initialize-DeploymentRemoval { From e52d5f1f67a3221097e1ddad56e102c1618b06f6 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Tue, 1 Aug 2023 14:25:24 +0200 Subject: [PATCH 13/13] Fixed name shortening --- .../resourcePublish/Get-TemplateSpecsName.ps1 | 24 +++++++------------ 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 index ed0b14cd30..e69d30cd3e 100644 --- a/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 +++ b/utilities/pipelines/resourcePublish/Get-TemplateSpecsName.ps1 @@ -11,7 +11,7 @@ Mandatory. The template file path to convert .EXAMPLE Get-TemplateSpecsName -TemplateFilePath 'C:\modules\key-vault\vault\main.bicep' -Convert 'C:\modules\key-vault\vault\main.bicep' to e.g. 'microsoft.key-vault.vault' +Convert 'C:\modules\key-vault\vault\main.bicep' to e.g. 'key-vault.vault' #> function Get-TemplateSpecsName { @@ -23,29 +23,21 @@ function Get-TemplateSpecsName { $moduleIdentifier = (Split-Path $TemplateFilePath -Parent).Replace('\', '/').Split('/modules/')[1] $templateSpecIdentifier = $moduleIdentifier.Replace('\', '/').Replace('/', '.').ToLower() - $templateSpecIdentifier = $templateSpecIdentifier -replace 'microsoft', 'ms' # Shorten the name - # This is required as certain modules generate names such as `ms.recovery-services.vault.replication-fabric.replication-protection-container.replication-protection-container-mapping` which are longer than the allowed 90 characters for template specs - # Using the logic below, the name is shortened to `ms.recovery-services.vault.replication-fabric.replication-protection-container.mapping` which has 'only' 86 characters + # This is required as certain modules generate names such as `recovery-services.vault.replication-fabric.replication-protection-container.replication-protection-container-mapping` which are longer than the allowed 90 characters for template specs + # Using the logic below, the name is shortened to `recovery-services.vault.replication-fabric.replication-protection-container.mapping` which has 'only' 86 characters $nameElems = $templateSpecIdentifier -split '\.' - # Starting at index 2 to skip the resource provider - for ($index = 2; $index -lt $nameElems.Count; $index++) { + # Starting at index 1 to skip the resource provider + for ($index = 1; $index -lt $nameElems.Count; $index++) { + # Only run as long as we're not already at last element of the array if ($index -lt ($nameElems.count - 1)) { $stringToRemove = $nameElems[($index)] $stringToCheck = $nameElems[($index + 1)] # If a name is replicated in a path, it is usually plural in the parent, and singular in the child path. - # For example: /virtual-networks/ (plural) & /virtual-network/virtual-network-peering/ (singular) - # In this case we want to remove the singular version from the subsequent string & format it accordingly - if ($stringToRemove.EndsWith('s') -and $stringToCheck.StartsWith($stringToRemove.Substring(0, $stringToRemove.length - 1))) { - $singularString = $stringToRemove.Substring(0, $stringToRemove.length - 1) - $rest = $stringToCheck.length - $singularString.Length - $shortenedString = $stringToCheck.Substring($singularString.length, $rest) - $camelCaseString = [Regex]::Replace($shortenedString , '\b.', { $args[0].Value.Tolower() }) - $nameElems[($index + 1)] = $camelCaseString - } elseif ($stringToCheck.StartsWith($stringToRemove)) { - $nameElems[($index + 1)] = $stringToCheck.Substring($stringToRemove.length, $stringToCheck.length) + if ($stringToCheck.StartsWith($stringToRemove)) { + $nameElems[($index + 1)] = $stringToCheck -replace "$stringToRemove-" } } }