From 5675df351323ac52a3256a19e09e755a647db541 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Sun, 4 Dec 2022 20:31:13 +0100 Subject: [PATCH 01/20] First few changes --- .../Initialize-DeploymentRemoval.ps1 | 56 +++++++++---------- .../helper/Remove-Deployment.ps1 | 36 +++++++----- 2 files changed, 49 insertions(+), 43 deletions(-) diff --git a/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 b/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 index 493b0edc08..1d08d2b92e 100644 --- a/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 +++ b/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 @@ -85,36 +85,34 @@ function Initialize-DeploymentRemoval { Write-Verbose ('Template file path: [{0}]' -f $templateFilePath) -Verbose Write-Verbose ('Module name: [{0}]' -f $moduleName) -Verbose - foreach ($deploymentName in $deploymentNames) { - Write-Verbose ('Handling resource removal with deployment name [{0}]' -f $deploymentName) -Verbose - - ### CODE LOCATION: Add custom removal sequence here - ## Add custom module-specific removal sequence following the example below - # switch ($moduleName) { - # '' { # For example: 'virtualWans', 'automationAccounts' - # $removalSequence += @( - # '', # For example: 'Microsoft.Network/vpnSites', 'Microsoft.OperationalInsights/workspaces/linkedServices' - # '', - # '' - # ) - # break - # } - # } - - # Invoke removal - $inputObject = @{ - DeploymentName = $deploymentName - TemplateFilePath = $templateFilePath - RemovalSequence = $removalSequence - } - if (-not [String]::IsNullOrEmpty($resourceGroupName)) { - $inputObject['resourceGroupName'] = $resourceGroupName - } - if (-not [String]::IsNullOrEmpty($ManagementGroupId)) { - $inputObject['ManagementGroupId'] = $ManagementGroupId - } - Remove-Deployment @inputObject -Verbose + Write-Verbose ('Handling resource removal with deployment names [{0}]' -f ($deploymentNames -join ', ')) -Verbose + + ### CODE LOCATION: Add custom removal sequence here + ## Add custom module-specific removal sequence following the example below + # switch ($moduleName) { + # '' { # For example: 'virtualWans', 'automationAccounts' + # $removalSequence += @( + # '', # For example: 'Microsoft.Network/vpnSites', 'Microsoft.OperationalInsights/workspaces/linkedServices' + # '', + # '' + # ) + # break + # } + # } + + # Invoke removal + $inputObject = @{ + DeploymentNames = $DeploymentNames + TemplateFilePath = $templateFilePath + RemovalSequence = $removalSequence } + if (-not [String]::IsNullOrEmpty($resourceGroupName)) { + $inputObject['resourceGroupName'] = $resourceGroupName + } + if (-not [String]::IsNullOrEmpty($ManagementGroupId)) { + $inputObject['ManagementGroupId'] = $ManagementGroupId + } + Remove-Deployment @inputObject -Verbose } end { diff --git a/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 b/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 index 6204561b12..dedec5be23 100644 --- a/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 +++ b/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 @@ -21,8 +21,8 @@ Optional. The maximum times to retry the search for resources via their removal .PARAMETER SearchRetryInterval Optional. The time to wait in between the search for resources via their remove tags -.PARAMETER DeploymentName -Optional. The deployment name to use for the removal +.PARAMETER DeploymentNames +Optional. The deployment names to use for the removal .PARAMETER TemplateFilePath Mandatory. The path to the deployment file @@ -31,7 +31,7 @@ Mandatory. The path to the deployment file Optional. The order of resource types to apply for deletion .EXAMPLE -Remove-Deployment -DeploymentName 'KeyVault' -ResourceGroupName 'validation-rg' -TemplateFilePath 'C:/deploy.json' +Remove-Deployment =DeploymentNames @('KeyVault-t1') -ResourceGroupName 'validation-rg' -TemplateFilePath 'C:/deploy.json' Remove a virtual WAN with deployment name 'keyvault-12345' from resource group 'validation-rg' #> @@ -46,7 +46,7 @@ function Remove-Deployment { [string] $ManagementGroupId, [Parameter(Mandatory = $true)] - [string] $DeploymentName, + [string[]] $DeploymentNames, [Parameter(Mandatory = $true)] [string] $TemplateFilePath, @@ -67,6 +67,7 @@ function Remove-Deployment { # Load helper . (Join-Path (Get-Item -Path $PSScriptRoot).parent.parent.FullName 'sharedScripts' 'Get-ScopeOfTemplateFile.ps1') . (Join-Path (Split-Path $PSScriptRoot -Parent) 'helper' 'Get-DeploymentTargetResourceList.ps1') + . (Join-Path (Split-Path $PSScriptRoot -Parent) 'helper' 'Get-MatchingDeploymentNameList.ps1') . (Join-Path (Split-Path $PSScriptRoot -Parent) 'helper' 'Get-ResourceIdsAsFormattedObjectList.ps1') . (Join-Path (Split-Path $PSScriptRoot -Parent) 'helper' 'Get-OrderedResourcesList.ps1') . (Join-Path (Split-Path $PSScriptRoot -Parent) 'helper' 'Remove-ResourceList.ps1') @@ -87,17 +88,24 @@ function Remove-Deployment { # Fetch deployments # ================= - $deploymentsInputObject = @{ - Name = $deploymentName - Scope = $deploymentScope - } - if (-not [String]::IsNullOrEmpty($resourceGroupName)) { - $deploymentsInputObject['resourceGroupName'] = $resourceGroupName - } - if (-not [String]::IsNullOrEmpty($ManagementGroupId)) { - $deploymentsInputObject['ManagementGroupId'] = $ManagementGroupId + $deployedTargetResources = @() + + foreach ($deploymentName in $DeploymentNames) { + $deploymentsInputObject = @{ + Name = $deploymentName + Scope = $deploymentScope + } + if (-not [String]::IsNullOrEmpty($resourceGroupName)) { + $deploymentsInputObject['resourceGroupName'] = $resourceGroupName + } + if (-not [String]::IsNullOrEmpty($ManagementGroupId)) { + $deploymentsInputObject['ManagementGroupId'] = $ManagementGroupId + } + $deployedTargetResources += Get-DeploymentTargetResourceList @deploymentsInputObject -Verbose } - [array] $deployedTargetResources = Get-DeploymentTargetResourceList @deploymentsInputObject -Verbose + + [array] $deployedTargetResources = $deployedTargetResources | Select-Object -Unique + Write-Verbose ('Total number of deployment target resources after fetching deployments [{0}]' -f $deployedTargetResources.Count) -Verbose # Pre-Filter & order items From 0137e050db182a27213341af08332b415be15e42 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Sun, 4 Dec 2022 20:50:53 +0100 Subject: [PATCH 02/20] Updated deployment script & pipeline tempaltes --- .../jobs.validateModuleDeployment.yml | 12 ++++++------ .../templates/validateModuleDeployment/action.yml | 6 +++--- .../resourceDeployment/New-TemplateDeployment.ps1 | 10 ++++++---- 3 files changed, 15 insertions(+), 13 deletions(-) diff --git a/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml b/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml index 61187f1c00..e96bc745a7 100644 --- a/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml +++ b/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml @@ -293,10 +293,10 @@ jobs: $res = New-TemplateDeployment @functionInput -Verbose # Get deployment name - $deploymentName = $res.deploymentName - Write-Verbose "Deployment name: $deploymentName" -Verbose - Write-Host "##vso[task.setvariable variable=deploymentName]$deploymentName" - Write-Host "##vso[task.setvariable variable=deploymentName;isOutput=true]$deploymentName" + $deploymentNames = $res.DeploymentNames | ConvertTo-Json -Compress + Write-Verbose "Deployment name(s) [$deploymentNames]" -Verbose + Write-Host "##vso[task.setvariable variable=deploymentNames]$deploymentNames" + Write-Host "##vso[task.setvariable variable=deploymentNames;isOutput=true]$deploymentNames" # Populate further outputs $deploymentOutputHash=@{} @@ -318,7 +318,7 @@ jobs: #------------------ - task: AzurePowerShell@5 displayName: 'Remove deployed resources via [${{ parameters.serviceConnection }}]' - condition: and(succeededOrFailed(), eq('${{ parameters.removeDeployment }}', 'True'), not(eq(variables['deploymentName'],'')), not(startsWith(variables['deploymentName'], 'variables[' ))) + condition: and(succeededOrFailed(), eq('${{ parameters.removeDeployment }}', 'True'), not(eq(variables['deploymentNames'],'')), not(startsWith(variables['deploymentNames'], 'variables[' ))) inputs: azureSubscription: ${{ parameters.serviceConnection }} azurePowerShellVersion: ${{ parameters.azurePowerShellVersion }} @@ -334,7 +334,7 @@ jobs: TemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '$(modulePath)' '$(moduleTestFilePath)' SubscriptionId = '${{ parameters.subscriptionId }}' ManagementGroupId = '${{ parameters.managementGroupId }}' - deploymentName = '$(deploymentName)' + DeploymentNames = '$(deploymentNames)' Verbose = $true } diff --git a/.github/actions/templates/validateModuleDeployment/action.yml b/.github/actions/templates/validateModuleDeployment/action.yml index 2d0fefbb9a..4e829a9378 100644 --- a/.github/actions/templates/validateModuleDeployment/action.yml +++ b/.github/actions/templates/validateModuleDeployment/action.yml @@ -271,7 +271,7 @@ runs: $res = New-TemplateDeployment @functionInput -Verbose # Get deployment name - Write-Output ('{0}={1}' -f 'deploymentName', $res.deploymentName) >> $env:GITHUB_OUTPUT + Write-Output ('{0}={1}' -f 'deploymentNames', ($res.deploymentNames | ConvertTo-Json -Compress)) >> $env:GITHUB_OUTPUT # Populate further outputs $deploymentOutputHash = @{} @@ -294,7 +294,7 @@ runs: # [Deployment removal] task(s) # ---------------------------- - name: 'Remove deployed resources' - if: ${{ always() && inputs.removeDeployment == 'true' && steps.deploy_step.outputs.deploymentName != '' }} + if: ${{ always() && inputs.removeDeployment == 'true' && steps.deploy_step.outputs.deploymentNames != '' }} uses: azure/powershell@v1 with: azPSVersion: 'latest' @@ -307,7 +307,7 @@ runs: $functionInput = @{ TemplateFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}' - DeploymentName = '${{ steps.deploy_step.outputs.deploymentName }}' + DeploymentNames = '${{ steps.deploy_step.outputs.deploymentNames }}' | ConvertFrom-Json ManagementGroupId = '${{ inputs.managementGroupId }}' Verbose = $true } diff --git a/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 b/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 index 501dfbaf51..df74dd682a 100644 --- a/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 +++ b/utilities/pipelines/resourceDeployment/New-TemplateDeployment.ps1 @@ -217,6 +217,7 @@ function New-TemplateDeploymentInner { $deploymentScope = Get-ScopeOfTemplateFile -TemplateFilePath $templateFilePath [bool]$Stoploop = $false [int]$retryCount = 1 + $usedDeploymentNames = @() do { # Generate a valid deployment name. Must match ^[-\w\._\(\)]+$ @@ -225,6 +226,7 @@ function New-TemplateDeploymentInner { } while ($deploymentName -notmatch '^[-\w\._\(\)]+$') Write-Verbose "Deploying with deployment name [$deploymentName]" -Verbose + $usedDeploymentNames += $deploymentName $DeploymentInputs['DeploymentName'] = $deploymentName try { @@ -301,8 +303,8 @@ function New-TemplateDeploymentInner { } return @{ - DeploymentName = $deploymentName - Exception = $exceptionMessage + DeploymentNames = $usedDeploymentNames + Exception = $exceptionMessage } } else { throw $PSitem.Exception.Message @@ -322,8 +324,8 @@ function New-TemplateDeploymentInner { Write-Verbose '------' -Verbose Write-Verbose ($res | Out-String) -Verbose return @{ - deploymentName = $deploymentName - deploymentOutput = $res.Outputs + DeploymentNames = $usedDeploymentNames + DeploymentOutput = $res.Outputs } } From 6bc116cf47aed7ee6f6234dc0a4bfd6190954fb4 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Sun, 4 Dec 2022 20:56:27 +0100 Subject: [PATCH 03/20] Update to latest --- .../pipelineTemplates/jobs.validateModuleDeployment.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml b/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml index e96bc745a7..89f6e4b0bf 100644 --- a/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml +++ b/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml @@ -334,7 +334,7 @@ jobs: TemplateFilePath = Join-Path '$(System.DefaultWorkingDirectory)' '$(modulePath)' '$(moduleTestFilePath)' SubscriptionId = '${{ parameters.subscriptionId }}' ManagementGroupId = '${{ parameters.managementGroupId }}' - DeploymentNames = '$(deploymentNames)' + DeploymentNames = '$(deploymentNames)' | ConvertFrom-Json Verbose = $true } From 4559e3609cf84540b2d94f818dc520c9aaf9a8f3 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Sun, 4 Dec 2022 21:01:09 +0100 Subject: [PATCH 04/20] Cleanup --- utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 | 1 - 1 file changed, 1 deletion(-) diff --git a/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 b/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 index dedec5be23..98a5dee0ee 100644 --- a/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 +++ b/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 @@ -67,7 +67,6 @@ function Remove-Deployment { # Load helper . (Join-Path (Get-Item -Path $PSScriptRoot).parent.parent.FullName 'sharedScripts' 'Get-ScopeOfTemplateFile.ps1') . (Join-Path (Split-Path $PSScriptRoot -Parent) 'helper' 'Get-DeploymentTargetResourceList.ps1') - . (Join-Path (Split-Path $PSScriptRoot -Parent) 'helper' 'Get-MatchingDeploymentNameList.ps1') . (Join-Path (Split-Path $PSScriptRoot -Parent) 'helper' 'Get-ResourceIdsAsFormattedObjectList.ps1') . (Join-Path (Split-Path $PSScriptRoot -Parent) 'helper' 'Get-OrderedResourcesList.ps1') . (Join-Path (Split-Path $PSScriptRoot -Parent) 'helper' 'Remove-ResourceList.ps1') From cd8639345f7f149cb85f6445e88f779b7f7f407b Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Sun, 4 Dec 2022 21:05:09 +0100 Subject: [PATCH 05/20] Broke com test on purpose for validation --- .../servers/.test/common/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep b/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep index 8ec7a2c827..73a1cae780 100644 --- a/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep +++ b/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep @@ -41,7 +41,7 @@ module diagnosticDependencies '../../../../.shared/dependencyConstructs/diagnost scope: resourceGroup name: '${uniqueString(deployment().name, location)}-diagnosticDependencies' params: { - storageAccountName: 'dep<>azsa${serviceShort}01' + storageAccountName: 'dep<>-azsa${serviceShort}01' logAnalyticsWorkspaceName: 'dep-<>-law-${serviceShort}' eventHubNamespaceEventHubName: 'dep-<>-evh-${serviceShort}' eventHubNamespaceName: 'dep-<>-evhns-${serviceShort}' From 6bace93f144c97a993e33ad76d8d8feaf03a8ea5 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Sun, 4 Dec 2022 23:26:11 +0100 Subject: [PATCH 06/20] Broke com test on purpose for validation --- .../servers/.test/common/deploy.test.bicep | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep b/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep index 73a1cae780..80fc88c71c 100644 --- a/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep +++ b/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep @@ -41,7 +41,7 @@ module diagnosticDependencies '../../../../.shared/dependencyConstructs/diagnost scope: resourceGroup name: '${uniqueString(deployment().name, location)}-diagnosticDependencies' params: { - storageAccountName: 'dep<>-azsa${serviceShort}01' + storageAccountName: 'dep<>azsa${serviceShort}01' logAnalyticsWorkspaceName: 'dep-<>-law-${serviceShort}' eventHubNamespaceEventHubName: 'dep-<>-evh-${serviceShort}' eventHubNamespaceName: 'dep-<>-evhns-${serviceShort}' @@ -63,7 +63,7 @@ module testDeployment '../../deploy.bicep' = { skuName: 'S0' roleAssignments: [ { - roleDefinitionIdOrName: 'Reader' + roleDefinitionIdOrName: 'Readerrrr' principalIds: [ resourceGroupResources.outputs.managedIdentityPrincipalId ] From 7127d2de7383b1e91007470270a16be87a39ed8a Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Sun, 4 Dec 2022 23:27:18 +0100 Subject: [PATCH 07/20] Broke com test on purpose for validation --- modules/Microsoft.AnalysisServices/servers/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/Microsoft.AnalysisServices/servers/readme.md b/modules/Microsoft.AnalysisServices/servers/readme.md index 425e5fe6f2..3ca5f8b17e 100644 --- a/modules/Microsoft.AnalysisServices/servers/readme.md +++ b/modules/Microsoft.AnalysisServices/servers/readme.md @@ -195,7 +195,7 @@ module servers './Microsoft.AnalysisServices/servers/deploy.bicep' = { '' ] principalType: 'ServicePrincipal' - roleDefinitionIdOrName: 'Reader' + roleDefinitionIdOrName: 'Readerrrr' } ] skuName: 'S0' @@ -248,7 +248,7 @@ module servers './Microsoft.AnalysisServices/servers/deploy.bicep' = { "" ], "principalType": "ServicePrincipal", - "roleDefinitionIdOrName": "Reader" + "roleDefinitionIdOrName": "Readerrrr" } ] }, From 4a4969d58dc2d3616704c2e56921165ecafc55e4 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Mon, 5 Dec 2022 00:03:21 +0100 Subject: [PATCH 08/20] Adjusted output --- .../helper/Get-DeploymentTargetResourceList.ps1 | 2 +- .../pipelines/resourceRemoval/helper/Remove-Deployment.ps1 | 4 ++-- .../resourceRemoval/helper/Remove-ResourceList.ps1 | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/utilities/pipelines/resourceRemoval/helper/Get-DeploymentTargetResourceList.ps1 b/utilities/pipelines/resourceRemoval/helper/Get-DeploymentTargetResourceList.ps1 index 1e9df42972..f70ee40204 100644 --- a/utilities/pipelines/resourceRemoval/helper/Get-DeploymentTargetResourceList.ps1 +++ b/utilities/pipelines/resourceRemoval/helper/Get-DeploymentTargetResourceList.ps1 @@ -91,7 +91,7 @@ function Get-DeploymentTargetResourceListInner { # Manage nested resources # ########################### foreach ($deployment in ($deploymentTargets | Where-Object { $_ -notmatch '/deployments/' } )) { - Write-Verbose ('Found deployed resource [{0}]' -f $deployment) -Verbose + Write-Verbose ('Found deployed resource [{0}]' -f $deployment) [array]$resultSet += $deployment } diff --git a/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 b/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 index 98a5dee0ee..c432489855 100644 --- a/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 +++ b/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 @@ -100,7 +100,7 @@ function Remove-Deployment { if (-not [String]::IsNullOrEmpty($ManagementGroupId)) { $deploymentsInputObject['ManagementGroupId'] = $ManagementGroupId } - $deployedTargetResources += Get-DeploymentTargetResourceList @deploymentsInputObject -Verbose + $deployedTargetResources += Get-DeploymentTargetResourceList @deploymentsInputObject } [array] $deployedTargetResources = $deployedTargetResources | Select-Object -Unique @@ -158,7 +158,7 @@ function Remove-Deployment { # ================ if ($resourcesToRemove.Count -gt 0) { if ($PSCmdlet.ShouldProcess(('[{0}] resources' -f (($resourcesToRemove -is [array]) ? $resourcesToRemove.Count : 1)), 'Remove')) { - Remove-ResourceList -ResourcesToRemove $resourcesToRemove -Verbose + Remove-ResourceList -ResourcesToRemove $resourcesToRemove } } else { Write-Verbose 'Found [0] resources to remove' diff --git a/utilities/pipelines/resourceRemoval/helper/Remove-ResourceList.ps1 b/utilities/pipelines/resourceRemoval/helper/Remove-ResourceList.ps1 index ff7dce093c..924c308db6 100644 --- a/utilities/pipelines/resourceRemoval/helper/Remove-ResourceList.ps1 +++ b/utilities/pipelines/resourceRemoval/helper/Remove-ResourceList.ps1 @@ -40,11 +40,11 @@ function Remove-ResourceListInner { if ($alreadyProcessed) { # Skipping - Write-Verbose ('Skipping resource [{0}] of type [{1}] as a parent resource was already processed' -f $resourceName, $resource.type) -Verbose + Write-Verbose ('[/] Skipping resource [{0}] of type [{1}] as a parent resource was already processed' -f $resourceName, $resource.type) -Verbose [array]$processedResources += $resource.resourceId [array]$resourcesToRetry = $resourcesToRetry | Where-Object { $_.resourceId -notmatch $resource.resourceId } } else { - Write-Verbose ('Removing resource [{0}] of type [{1}]' -f $resourceName, $resource.type) -Verbose + Write-Verbose ('[-] Removing resource [{0}] of type [{1}]' -f $resourceName, $resource.type) -Verbose try { if ($PSCmdlet.ShouldProcess(('Resource [{0}]' -f $resource.resourceId), 'Remove')) { Invoke-ResourceRemoval -Type $resource.type -ResourceId $resource.resourceId @@ -107,7 +107,7 @@ function Remove-ResourceList { do { if ($PSCmdlet.ShouldProcess(("[{0}] Resource(s) with a maximum of [$removalRetryLimit] attempts." -f (($resourcesToRetry -is [array]) ? $resourcesToRetry.Count : 1)), 'Remove')) { - $resourcesToRetry = Remove-ResourceListInner -ResourcesToRemove $resourcesToRetry -Verbose + $resourcesToRetry = Remove-ResourceListInner -ResourcesToRemove $resourcesToRetry } else { Remove-ResourceListInner -ResourcesToRemove $resourcesToRemove -WhatIf } From 961549631563a620beb515511bd6c9383fd46a94 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Mon, 5 Dec 2022 00:21:10 +0100 Subject: [PATCH 09/20] Adjusted output --- .../pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 | 2 +- .../pipelines/resourceRemoval/helper/Invoke-ResourceRemoval.ps1 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 b/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 index 1d08d2b92e..e5313ca5b0 100644 --- a/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 +++ b/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 @@ -112,7 +112,7 @@ function Initialize-DeploymentRemoval { if (-not [String]::IsNullOrEmpty($ManagementGroupId)) { $inputObject['ManagementGroupId'] = $ManagementGroupId } - Remove-Deployment @inputObject -Verbose + Remove-Deployment @inputObject } end { diff --git a/utilities/pipelines/resourceRemoval/helper/Invoke-ResourceRemoval.ps1 b/utilities/pipelines/resourceRemoval/helper/Invoke-ResourceRemoval.ps1 index 75a9f9e179..72ab5d17ce 100644 --- a/utilities/pipelines/resourceRemoval/helper/Invoke-ResourceRemoval.ps1 +++ b/utilities/pipelines/resourceRemoval/helper/Invoke-ResourceRemoval.ps1 @@ -27,7 +27,7 @@ function Invoke-ResourceRemoval { [string] $Type ) - Write-Verbose ('Removing resource [{0}]' -f $resourceId) -Verbose + Write-Verbose ('Removing resource [{0}]' -f $resourceId) switch ($type) { 'Microsoft.Insights/diagnosticSettings' { From 3e47accd276197c28f89ed3accd17eb395ebaeb9 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Mon, 5 Dec 2022 08:52:46 +0100 Subject: [PATCH 10/20] Fruther cleanup --- .../helper/Get-DeploymentTargetResourceList.ps1 | 8 ++++---- .../resourceRemoval/helper/Invoke-ResourceRemoval.ps1 | 2 -- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/utilities/pipelines/resourceRemoval/helper/Get-DeploymentTargetResourceList.ps1 b/utilities/pipelines/resourceRemoval/helper/Get-DeploymentTargetResourceList.ps1 index f70ee40204..c455fe3669 100644 --- a/utilities/pipelines/resourceRemoval/helper/Get-DeploymentTargetResourceList.ps1 +++ b/utilities/pipelines/resourceRemoval/helper/Get-DeploymentTargetResourceList.ps1 @@ -103,23 +103,23 @@ function Get-DeploymentTargetResourceListInner { if ($deployment -match '/resourceGroups/') { # Resource Group Level Child Deployments # ########################################## - Write-Verbose ('Found [resource group] deployment [{0}]' -f $deployment) -Verbose + Write-Verbose ('Found [resource group] deployment [{0}]' -f $deployment) $resourceGroupName = $deployment.split('/resourceGroups/')[1].Split('/')[0] [array]$resultSet += Get-DeploymentTargetResourceListInner -Name $name -Scope 'resourcegroup' -ResourceGroupName $ResourceGroupName } elseif ($deployment -match '/subscriptions/') { # Subscription Level Child Deployments # ######################################## - Write-Verbose ('Found [subscription] deployment [{0}]' -f $deployment) -Verbose + Write-Verbose ('Found [subscription] deployment [{0}]' -f $deployment) [array]$resultSet += Get-DeploymentTargetResourceListInner -Name $name -Scope 'subscription' } elseif ($deployment -match '/managementgroups/') { # Management Group Level Child Deployments # ############################################ - Write-Verbose ('Found [management group] deployment [{0}]' -f $deployment) -Verbose + Write-Verbose ('Found [management group] deployment [{0}]' -f $deployment) [array]$resultSet += Get-DeploymentTargetResourceListInner -Name $name -Scope 'managementgroup' -ManagementGroupId $ManagementGroupId } else { # Tenant Level Child Deployments # ################################## - Write-Verbose ('Found [tenant] deployment [{0}]' -f $deployment) -Verbose + Write-Verbose ('Found [tenant] deployment [{0}]' -f $deployment) [array]$resultSet += Get-DeploymentTargetResourceListInner -Name $name -Scope 'tenant' } } diff --git a/utilities/pipelines/resourceRemoval/helper/Invoke-ResourceRemoval.ps1 b/utilities/pipelines/resourceRemoval/helper/Invoke-ResourceRemoval.ps1 index 72ab5d17ce..a6325482c3 100644 --- a/utilities/pipelines/resourceRemoval/helper/Invoke-ResourceRemoval.ps1 +++ b/utilities/pipelines/resourceRemoval/helper/Invoke-ResourceRemoval.ps1 @@ -27,8 +27,6 @@ function Invoke-ResourceRemoval { [string] $Type ) - Write-Verbose ('Removing resource [{0}]' -f $resourceId) - switch ($type) { 'Microsoft.Insights/diagnosticSettings' { $parentResourceId = $resourceId.Split('/providers/{0}' -f $type)[0] From 7af848572b348970dd6fa564d2fb11bf7f9a5f6e Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Mon, 5 Dec 2022 10:38:25 +0100 Subject: [PATCH 11/20] Fruther cleanup --- .../jobs.validateModuleDeployment.yml | 1 - .../templates/validateModuleDeployment/action.yml | 1 - .../resourceRemoval/Initialize-DeploymentRemoval.ps1 | 10 +--------- 3 files changed, 1 insertion(+), 11 deletions(-) diff --git a/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml b/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml index 89f6e4b0bf..6c7718370a 100644 --- a/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml +++ b/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml @@ -335,7 +335,6 @@ jobs: SubscriptionId = '${{ parameters.subscriptionId }}' ManagementGroupId = '${{ parameters.managementGroupId }}' DeploymentNames = '$(deploymentNames)' | ConvertFrom-Json - Verbose = $true } Write-Verbose 'Invoke task with' -Verbose diff --git a/.github/actions/templates/validateModuleDeployment/action.yml b/.github/actions/templates/validateModuleDeployment/action.yml index 4e829a9378..32d956a491 100644 --- a/.github/actions/templates/validateModuleDeployment/action.yml +++ b/.github/actions/templates/validateModuleDeployment/action.yml @@ -309,7 +309,6 @@ runs: TemplateFilePath = Join-Path $env:GITHUB_WORKSPACE '${{ inputs.templateFilePath }}' DeploymentNames = '${{ steps.deploy_step.outputs.deploymentNames }}' | ConvertFrom-Json ManagementGroupId = '${{ inputs.managementGroupId }}' - Verbose = $true } Write-Verbose 'Invoke task with' -Verbose diff --git a/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 b/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 index e5313ca5b0..c138aeddce 100644 --- a/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 +++ b/utilities/pipelines/resourceRemoval/Initialize-DeploymentRemoval.ps1 @@ -56,13 +56,6 @@ function Initialize-DeploymentRemoval { $null = Set-AzContext -Subscription $subscriptionId } - if (-not (Split-Path (Split-Path $templateFilePath -Parent) -LeafBase)) { - # In case of new dependency approach (template is in subfolder) - $moduleName = Split-Path (Split-Path (Split-Path $templateFilePath -Parent) -Parent) -LeafBase - } else { - $moduleName = Split-Path (Split-Path $templateFilePath -Parent) -LeafBase - } - # The initial sequence is a general order-recommendation $removalSequence = @( 'Microsoft.Authorization/locks', @@ -82,13 +75,12 @@ function Initialize-DeploymentRemoval { 'Microsoft.Resources/resourceGroups', 'Microsoft.Compute/virtualMachines' ) - Write-Verbose ('Template file path: [{0}]' -f $templateFilePath) -Verbose - Write-Verbose ('Module name: [{0}]' -f $moduleName) -Verbose Write-Verbose ('Handling resource removal with deployment names [{0}]' -f ($deploymentNames -join ', ')) -Verbose ### CODE LOCATION: Add custom removal sequence here ## Add custom module-specific removal sequence following the example below + # $moduleName = Split-Path (Split-Path (Split-Path $templateFilePath -Parent) -Parent) -LeafBase # switch ($moduleName) { # '' { # For example: 'virtualWans', 'automationAccounts' # $removalSequence += @( From a90aa1828ab8dc865360487f8e3854225ba77087 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Mon, 5 Dec 2022 13:03:57 +0100 Subject: [PATCH 12/20] Small renaming --- .../pipelineTemplates/jobs.validateModuleDeployment.yml | 6 +++--- .../actions/templates/validateModuleDeployment/action.yml | 6 +++--- .../servers/.test/common/deploy.test.bicep | 2 +- modules/Microsoft.AnalysisServices/servers/readme.md | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml b/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml index 6c7718370a..b390a35b44 100644 --- a/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml +++ b/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml @@ -299,14 +299,14 @@ jobs: Write-Host "##vso[task.setvariable variable=deploymentNames;isOutput=true]$deploymentNames" # Populate further outputs - $deploymentOutputHash=@{} + $deploymentOutputHashTable = @{} foreach ($outputKey in $res.deploymentOutput.Keys) { Write-Output ('##vso[task.setvariable variable={0}]{1}' -f $outputKey, $res.deploymentOutput[$outputKey].Value) - $deploymentOutputHash.add($outputKey,$res.deploymentOutput[$outputKey].Value) + $deploymentOutputHashTable.add($outputKey,$res.deploymentOutput[$outputKey].Value) } - $deploymentOutput = $deploymentOutputHash | ConvertTo-Json -Compress -Depth 100 + $deploymentOutput = $deploymentOutputHashTable | ConvertTo-Json -Compress -Depth 100 Write-Verbose "Deployment output: $deploymentOutput" -Verbose if ($res.ContainsKey('exception')) { diff --git a/.github/actions/templates/validateModuleDeployment/action.yml b/.github/actions/templates/validateModuleDeployment/action.yml index 32d956a491..8edd8d20a2 100644 --- a/.github/actions/templates/validateModuleDeployment/action.yml +++ b/.github/actions/templates/validateModuleDeployment/action.yml @@ -274,14 +274,14 @@ runs: Write-Output ('{0}={1}' -f 'deploymentNames', ($res.deploymentNames | ConvertTo-Json -Compress)) >> $env:GITHUB_OUTPUT # Populate further outputs - $deploymentOutputHash = @{} + $deploymentOutputHashTable = @{} foreach ($outputKey in $res.deploymentOutput.Keys) { Write-Output ('{0}={1}' -f 'outputKey', $res.deploymentOutput[$outputKey].Value) >> $env:GITHUB_OUTPUT - $deploymentOutputHash.add($outputKey, $res.deploymentOutput[$outputKey].Value) + $deploymentOutputHashTable.add($outputKey, $res.deploymentOutput[$outputKey].Value) } - $deploymentOutput = $deploymentOutputHash | ConvertTo-Json -Compress -Depth 100 + $deploymentOutput = $deploymentOutputHashTable | ConvertTo-Json -Compress -Depth 100 Write-Verbose "Deployment output: $deploymentOutput" -Verbose if ($res.ContainsKey('exception')) { diff --git a/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep b/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep index 80fc88c71c..8ec7a2c827 100644 --- a/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep +++ b/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep @@ -63,7 +63,7 @@ module testDeployment '../../deploy.bicep' = { skuName: 'S0' roleAssignments: [ { - roleDefinitionIdOrName: 'Readerrrr' + roleDefinitionIdOrName: 'Reader' principalIds: [ resourceGroupResources.outputs.managedIdentityPrincipalId ] diff --git a/modules/Microsoft.AnalysisServices/servers/readme.md b/modules/Microsoft.AnalysisServices/servers/readme.md index 3ca5f8b17e..425e5fe6f2 100644 --- a/modules/Microsoft.AnalysisServices/servers/readme.md +++ b/modules/Microsoft.AnalysisServices/servers/readme.md @@ -195,7 +195,7 @@ module servers './Microsoft.AnalysisServices/servers/deploy.bicep' = { '' ] principalType: 'ServicePrincipal' - roleDefinitionIdOrName: 'Readerrrr' + roleDefinitionIdOrName: 'Reader' } ] skuName: 'S0' @@ -248,7 +248,7 @@ module servers './Microsoft.AnalysisServices/servers/deploy.bicep' = { "" ], "principalType": "ServicePrincipal", - "roleDefinitionIdOrName": "Readerrrr" + "roleDefinitionIdOrName": "Reader" } ] }, From 5ddafb5ee5aae023c1742e26336f7af8278581f8 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Mon, 5 Dec 2022 14:23:23 +0100 Subject: [PATCH 13/20] Added check --- .../jobs.validateModuleDeployment.yml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml b/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml index b390a35b44..10fe3e1ffc 100644 --- a/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml +++ b/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml @@ -294,20 +294,24 @@ jobs: # Get deployment name $deploymentNames = $res.DeploymentNames | ConvertTo-Json -Compress - Write-Verbose "Deployment name(s) [$deploymentNames]" -Verbose + Write-Verbose "Deployment name(s): $deploymentNames" -Verbose Write-Host "##vso[task.setvariable variable=deploymentNames]$deploymentNames" Write-Host "##vso[task.setvariable variable=deploymentNames;isOutput=true]$deploymentNames" # Populate further outputs $deploymentOutputHashTable = @{} - foreach ($outputKey in $res.deploymentOutput.Keys) { - Write-Output ('##vso[task.setvariable variable={0}]{1}' -f $outputKey, $res.deploymentOutput[$outputKey].Value) - $deploymentOutputHashTable.add($outputKey,$res.deploymentOutput[$outputKey].Value) - } + if($res.deploymentOutput.Keys) { + foreach ($outputKey in $res.deploymentOutput.Keys) { + Write-Output ('##vso[task.setvariable variable={0}]{1}' -f $outputKey, $res.deploymentOutput[$outputKey].Value) + $deploymentOutputHashTable.add($outputKey,$res.deploymentOutput[$outputKey].Value) + } - $deploymentOutput = $deploymentOutputHashTable | ConvertTo-Json -Compress -Depth 100 - Write-Verbose "Deployment output: $deploymentOutput" -Verbose + $deploymentOutput = $deploymentOutputHashTable | ConvertTo-Json -Compress -Depth 100 + Write-Verbose "Deployment output: $deploymentOutput" -Verbose + } else { + Write-Verbose "No deployment output" -Verbose + } if ($res.ContainsKey('exception')) { # Happens only if there is an exception From 60e56480625e4921692cd8f5e61755445972b922 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Mon, 5 Dec 2022 14:49:52 +0100 Subject: [PATCH 14/20] Added test error --- .../servers/.test/common/deploy.test.bicep | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep b/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep index 8ec7a2c827..97d7eea044 100644 --- a/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep +++ b/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep @@ -63,7 +63,7 @@ module testDeployment '../../deploy.bicep' = { skuName: 'S0' roleAssignments: [ { - roleDefinitionIdOrName: 'Reader' + roleDefinitionIdOrName: 'Readerr' principalIds: [ resourceGroupResources.outputs.managedIdentityPrincipalId ] From e05343e5709745e1ccf8535dcf43d4c81bc7636c Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Mon, 5 Dec 2022 14:50:29 +0100 Subject: [PATCH 15/20] Update to latest --- modules/Microsoft.AnalysisServices/servers/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/Microsoft.AnalysisServices/servers/readme.md b/modules/Microsoft.AnalysisServices/servers/readme.md index 425e5fe6f2..7acd921839 100644 --- a/modules/Microsoft.AnalysisServices/servers/readme.md +++ b/modules/Microsoft.AnalysisServices/servers/readme.md @@ -195,7 +195,7 @@ module servers './Microsoft.AnalysisServices/servers/deploy.bicep' = { '' ] principalType: 'ServicePrincipal' - roleDefinitionIdOrName: 'Reader' + roleDefinitionIdOrName: 'Readerr' } ] skuName: 'S0' @@ -248,7 +248,7 @@ module servers './Microsoft.AnalysisServices/servers/deploy.bicep' = { "" ], "principalType": "ServicePrincipal", - "roleDefinitionIdOrName": "Reader" + "roleDefinitionIdOrName": "Readerr" } ] }, From 6ebbd618c145194bbe7cfaa3582a6a918477df09 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Mon, 5 Dec 2022 14:54:13 +0100 Subject: [PATCH 16/20] Update to latest --- docs/wiki/The CI environment - Deployment validation.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/wiki/The CI environment - Deployment validation.md b/docs/wiki/The CI environment - Deployment validation.md index a70994cfb9..05b1c3cd61 100644 --- a/docs/wiki/The CI environment - Deployment validation.md +++ b/docs/wiki/The CI environment - Deployment validation.md @@ -54,6 +54,8 @@ The removal step is triggered after the deployment completes. It removes all res However, the removal step can be skipped in case further investigation on the deployed resource is needed. This can be controlled when running the module pipeline leveraging [Module pipeline inputs](./The%20CI%20environment%20-%20Pipeline%20design#module-pipeline-inputs). +> Note: The logic will consider all deployment names used during the deployment step - even those of retries. + ### How it works The removal process will delete all resources created by the deployment. The list of resources is identified by: From 3e6c6c6dae49826814f3bdb536184d15ec20afd7 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Mon, 5 Dec 2022 14:54:40 +0100 Subject: [PATCH 17/20] Update to latest --- docs/wiki/The CI environment - Deployment validation.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/wiki/The CI environment - Deployment validation.md b/docs/wiki/The CI environment - Deployment validation.md index 05b1c3cd61..48839a792e 100644 --- a/docs/wiki/The CI environment - Deployment validation.md +++ b/docs/wiki/The CI environment - Deployment validation.md @@ -60,7 +60,7 @@ However, the removal step can be skipped in case further investigation on the de The removal process will delete all resources created by the deployment. The list of resources is identified by: -1. Recursively fetching the list of resource IDs created in the deployment (identified via the deployment name used). +1. Recursively fetching the list of resource IDs created in the deployment(s) (identified via the deployment names(s) used). 1. Ordering the list based on resource IDs segment count (ensures child resources are removed first. E.g., `storageAccount/blobServices` comes before `storageAccount` as it has one more segments delimited by `/`). 1. Filtering out resources must remain even after the test concluded from the list. This contains, but is not limited to: 1. Resources that are autogenerated by Azure and can cause issues if not controlled (e.g., the Network Watcher resource group that is autogenerated and shared by multiple module tests) From 3a2b3a5b2e247278558817f3238e07ff160ee66e Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Mon, 5 Dec 2022 15:06:46 +0100 Subject: [PATCH 18/20] Update to latest --- .../jobs.validateModuleDeployment.yml | 20 ++++++++----------- 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml b/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml index 10fe3e1ffc..753617f7ee 100644 --- a/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml +++ b/.azuredevops/pipelineTemplates/jobs.validateModuleDeployment.yml @@ -294,25 +294,21 @@ jobs: # Get deployment name $deploymentNames = $res.DeploymentNames | ConvertTo-Json -Compress - Write-Verbose "Deployment name(s): $deploymentNames" -Verbose + Write-Verbose "Deployment name(s) [$deploymentNames]" -Verbose Write-Host "##vso[task.setvariable variable=deploymentNames]$deploymentNames" Write-Host "##vso[task.setvariable variable=deploymentNames;isOutput=true]$deploymentNames" # Populate further outputs - $deploymentOutputHashTable = @{} + $deploymentOutputHashTable=@{} - if($res.deploymentOutput.Keys) { - foreach ($outputKey in $res.deploymentOutput.Keys) { - Write-Output ('##vso[task.setvariable variable={0}]{1}' -f $outputKey, $res.deploymentOutput[$outputKey].Value) - $deploymentOutputHashTable.add($outputKey,$res.deploymentOutput[$outputKey].Value) - } - - $deploymentOutput = $deploymentOutputHashTable | ConvertTo-Json -Compress -Depth 100 - Write-Verbose "Deployment output: $deploymentOutput" -Verbose - } else { - Write-Verbose "No deployment output" -Verbose + foreach ($outputKey in $res.deploymentOutput.Keys) { + Write-Output ('##vso[task.setvariable variable={0}]{1}' -f $outputKey, $res.deploymentOutput[$outputKey].Value) + $deploymentOutputHashTable.add($outputKey,$res.deploymentOutput[$outputKey].Value) } + $deploymentOutput = $deploymentOutputHashTable | ConvertTo-Json -Compress -Depth 100 + Write-Verbose "Deployment output: $deploymentOutput" -Verbose + if ($res.ContainsKey('exception')) { # Happens only if there is an exception throw $res.exception From b6bcb3a99b1412b1aace18127e6798152a41d023 Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Mon, 5 Dec 2022 15:07:28 +0100 Subject: [PATCH 19/20] Update to latest --- .../servers/.test/common/deploy.test.bicep | 2 +- modules/Microsoft.AnalysisServices/servers/readme.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep b/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep index 97d7eea044..8ec7a2c827 100644 --- a/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep +++ b/modules/Microsoft.AnalysisServices/servers/.test/common/deploy.test.bicep @@ -63,7 +63,7 @@ module testDeployment '../../deploy.bicep' = { skuName: 'S0' roleAssignments: [ { - roleDefinitionIdOrName: 'Readerr' + roleDefinitionIdOrName: 'Reader' principalIds: [ resourceGroupResources.outputs.managedIdentityPrincipalId ] diff --git a/modules/Microsoft.AnalysisServices/servers/readme.md b/modules/Microsoft.AnalysisServices/servers/readme.md index 7acd921839..425e5fe6f2 100644 --- a/modules/Microsoft.AnalysisServices/servers/readme.md +++ b/modules/Microsoft.AnalysisServices/servers/readme.md @@ -195,7 +195,7 @@ module servers './Microsoft.AnalysisServices/servers/deploy.bicep' = { '' ] principalType: 'ServicePrincipal' - roleDefinitionIdOrName: 'Readerr' + roleDefinitionIdOrName: 'Reader' } ] skuName: 'S0' @@ -248,7 +248,7 @@ module servers './Microsoft.AnalysisServices/servers/deploy.bicep' = { "" ], "principalType": "ServicePrincipal", - "roleDefinitionIdOrName": "Readerr" + "roleDefinitionIdOrName": "Reader" } ] }, From 8e436745b2d7c6a22fb6595cb6d67e0656d3ca4f Mon Sep 17 00:00:00 2001 From: AlexanderSehr Date: Tue, 6 Dec 2022 17:36:19 +0100 Subject: [PATCH 20/20] Updated examples --- .../pipelines/resourceRemoval/helper/Remove-Deployment.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 b/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 index c432489855..ea7117c714 100644 --- a/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 +++ b/utilities/pipelines/resourceRemoval/helper/Remove-Deployment.ps1 @@ -31,9 +31,9 @@ Mandatory. The path to the deployment file Optional. The order of resource types to apply for deletion .EXAMPLE -Remove-Deployment =DeploymentNames @('KeyVault-t1') -ResourceGroupName 'validation-rg' -TemplateFilePath 'C:/deploy.json' +Remove-Deployment -DeploymentNames @('KeyVault-t1','KeyVault-t2') -TemplateFilePath 'C:/deploy.json' -Remove a virtual WAN with deployment name 'keyvault-12345' from resource group 'validation-rg' +Remove all resources deployed via the with deployment names 'KeyVault-t1' & 'KeyVault-t2' #> function Remove-Deployment {