Skip to content

Commit

Permalink
feat: Added subscription cleanup option & resourceId list input to re…
Browse files Browse the repository at this point in the history
…moval function (#1607)

## Description

- Added ResourceId list input to removal function
- Added option to fetch any resource & resourceGroup with `dep-` in its
name to be removed using the default removal logic

<details>
<summary>Initial execution</summary>

```
PS C:\dev\bicep-registry-modules> Initialize-DeploymentRemoval -RemoveAllDepResources
VERBOSE: Total number of deployment target resources after fetching deployments [79]
VERBOSE: Total number of deployment target resources after pre-filtering (duplicates) & ordering items [79]
VERBOSE: Total number of deployment target resources after formatting items [79]
VERBOSE: Total number of deployments after filtering all dependency resources [79]
VERBOSE: Total number of deployments after final ordering of resources [79]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.expressRouteGateway-nergmin-rg/providers/Microsoft.Network/virtualWans/dep-<namePrefix>-vwan-nergmin]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsForwardingRuleset-ndfrswaf-rg/providers/Microsoft.Network/dnsResolvers/dep-<namePrefix>-ndr-ndfrswaf/outboundEndpoints/pdnsout]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-keyvault.vaults-kvvwaf-rg/providers/Microsoft.Network/privateDnsZones/privatelink.vaultcore.azure.net/virtualNetworkLinks/dep-<namePrefix>-vnet-kvvwaf-vnetlink]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsResolvers-ndrwaf-rg/providers/Microsoft.Network/dnsResolvers/<namePrefix>ndrwaf001/inboundEndpoints/<namePrefix>ndrwaf-az-pdnsin-x-001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-sql.servers-sqlspe-rg/providers/Microsoft.Sql/servers/<namePrefix>-sqlspe/databases/master]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsResolvers-ndrwaf-rg/providers/Microsoft.Network/dnsResolvers/<namePrefix>ndrwaf001/outboundEndpoints/<namePrefix>ndrwaf-az-pdnsout-x-001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg/providers/Microsoft.ContainerInstance/containerGroups/<namePrefix>cicgenc001] 
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnwaf-rg/providers/Microsoft.Storage/storageAccounts/dep<namePrefix>diasanvnwaf01]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnwaf-rg/providers/Microsoft.Network/virtualNetworks/<namePrefix>nvnwaf001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnwaf-rg/providers/Microsoft.Network/routeTables/dep-<namePrefix>-rt-nvnwaf]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnwaf-rg/providers/Microsoft.Network/networkSecurityGroups/dep-<namePrefix>-nsg-nvnwaf]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnwaf-rg/providers/Microsoft.Network/networkSecurityGroups/dep-<namePrefix>-nsg-bastion-nvnwaf]   
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnwaf-rg/providers/Microsoft.EventHub/namespaces/dep-<namePrefix>-evhns-nvnwaf]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnpeer-rg/providers/Microsoft.Network/virtualNetworks/dep-<namePrefix>-vnet-nvnpeer]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnpeer-rg/providers/Microsoft.Network/virtualNetworks/<namePrefix>nvnpeer001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnpeer-rg/providers/Microsoft.Network/networkSecurityGroups/dep-<namePrefix>-nsg-bastion-nvnpeer] 
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnmax-rg/providers/Microsoft.Storage/storageAccounts/dep<namePrefix>diasanvnmax01]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnmax-rg/providers/Microsoft.Network/virtualNetworks/<namePrefix>nvnmax001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnmax-rg/providers/Microsoft.Network/routeTables/dep-<namePrefix>-rt-nvnmax]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnmax-rg/providers/Microsoft.Network/networkSecurityGroups/dep-<namePrefix>-nsg-nvnmax]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-operationalinsights.workspaces-oiwadv-rg/providers/Microsoft.Automation/automationAccounts/dep-<namePrefix>-auto-oiwadv]   
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-operationalinsights.workspaces-oiwadv-rg/providers/Microsoft.EventHub/namespaces/dep-<namePrefix>-ehn-oiwadv]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-operationalinsights.workspaces-oiwadv-rg/providers/Microsoft.EventHub/namespaces/dep-<namePrefix>-evhns-oiwadv]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-operationalinsights.workspaces-oiwadv-rg/providers/Microsoft.Storage/storageAccounts/dep<namePrefix>diasaoiwadv01]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/rg-dep-avmx-databricks.workspaces-dwmax-rg-managed/providers/Microsoft.Storage/storageAccounts/saavmxdwmax001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/rg-dep-avmx-databricks.workspaces-dwmax-rg-managed/providers/Microsoft.Databricks/accessConnectors/unity-catalog-access-connector]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/IT_dep-<namePrefix>-compute.images-cimin-rg_dep-<namePrefix>-_0cde4fa3-334a-4ea8-be55-f9ca6584e6e1/providers/Microsoft.Storage/storageAccounts/q3qok4o2xgwxwvuvs86hucv0]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmin-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmin001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmax-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmax001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-synapse.workspaces-swenua-rg/providers/Microsoft.Synapse/workspaces/<namePrefix>swenua001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-synapse.workspaces-swenua-rg/providers/Microsoft.Storage/storageAccounts/dep<namePrefix>saswenua01]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnmax-rg/providers/Microsoft.Network/networkSecurityGroups/dep-<namePrefix>-nsg-bastion-nvnmax]   
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-servicebus.namespaces-sbnmin-rg/providers/Microsoft.ServiceBus/namespaces/<namePrefix>sbnmin001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-search.searchservices-sssmax-rg/providers/Microsoft.Search/searchServices/<namePrefix>sssmax001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-search.searchservices-sssmax-rg/providers/Microsoft.EventHub/namespaces/dep-<namePrefix>-evhns-sssmax01]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-operationalinsights.workspaces-oiwwaf-rg/providers/Microsoft.Storage/storageAccounts/dep<namePrefix>saoiwwaf]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-operationalinsights.workspaces-oiwwaf-rg/providers/Microsoft.Storage/storageAccounts/dep<namePrefix>diasaoiwwaf01]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-operationalinsights.workspaces-oiwwaf-rg/providers/Microsoft.EventHub/namespaces/dep-<namePrefix>-evhns-oiwwaf]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-operationalinsights.workspaces-oiwwaf-rg/providers/Microsoft.Automation/automationAccounts/dep-<namePrefix>-auto-oiwwaf]   
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-operationalinsights.workspaces-oiwadv-rg/providers/Microsoft.Storage/storageAccounts/dep<namePrefix>saoiwadv]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-search.searchservices-sssmax-rg/providers/Microsoft.Storage/storageAccounts/dep<namePrefix>diasasssmax03]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnmax-rg/providers/Microsoft.EventHub/namespaces/dep-<namePrefix>-evhns-nvnmax]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.publicipprefixes-npipmin-rg/providers/Microsoft.Network/publicIPPrefixes/<namePrefix>npipmin001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/rg-dep-avmx-databricks.workspaces-dwwaf-rg-managed/providers/Microsoft.Databricks/accessConnectors/unity-catalog-access-connector]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-keyvault.vaults-kvvwaf-rg/providers/Microsoft.Storage/storageAccounts/dep<namePrefix>diasakvvwaf03]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-keyvault.vaults-kvvwaf-rg/providers/Microsoft.Network/virtualNetworks/dep-<namePrefix>-vnet-kvvwaf]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-keyvault.vaults-kvvwaf-rg/providers/Microsoft.Network/privateDnsZones/privatelink.vaultcore.azure.net]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-keyvault.vaults-kvvwaf-rg/providers/Microsoft.EventHub/namespaces/dep-<namePrefix>-evhns-kvvwaf01]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-insights.dataCollectionEndpoints-idcemin-rg/providers/Microsoft.Insights/dataCollectionEndpoints/<namePrefix>idcemin001]   
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-insights.components-icmax-rg/providers/Microsoft.Storage/storageAccounts/dep<namePrefix>saicmax]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-insights.components-icmax-rg/providers/Microsoft.Storage/storageAccounts/dep<namePrefix>diasaicmax01]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-insights.components-icmax-rg/providers/Microsoft.Insights/components/<namePrefix>icmax001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-insights.components-icmax-rg/providers/Microsoft.EventHub/namespaces/dep-<namePrefix>-evhns-icmax]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-insights.components-icmax-rg/providers/microsoft.alertsmanagement/smartDetectorAlertRules/Failure Anomalies - <namePrefix>icmax001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-eventhub.namespaces-ehnenc-rg/providers/Microsoft.EventHub/namespaces/<namePrefix>ehnenc001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-digitaltwins.digitaltwinsinstances-dtdiwaf-rg/providers/Microsoft.Storage/storageAccounts/dep<namePrefix>diasadtdiwaf03]   
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-digitaltwins.digitaltwinsinstances-dtdiwaf-rg/providers/Microsoft.EventHub/namespaces/dep-<namePrefix>-evhns-dtdiwaf01]    
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-digitaltwins.digitaltwinsinstances-dtdiwaf-rg/providers/Microsoft.DigitalTwins/digitalTwinsInstances/<namePrefix>dtdiwaf001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-logic.workflows-lwwaf-rg/providers/Microsoft.EventHub/namespaces/dep-<namePrefix>-evhns-lwwaf01]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.publicipprefixes-npipwaf-rg/providers/Microsoft.Network/publicIPPrefixes/<namePrefix>npipwaf001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-logic.workflows-lwwaf-rg/providers/Microsoft.Logic/workflows/<namePrefix>lwwaf001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.applicationGatewayWebApplicationFirewallPolicies-nagwafpmax-rg/providers/Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies/<namePrefix>nagwafpmax001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.privateendpoints-npemin-rg/providers/Microsoft.Network/virtualNetworks/dep-<namePrefix>-vnet-npemin]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.networkmanagers-nnmmin-rg/providers/Microsoft.Network/networkManagers/<namePrefix>nnmmin001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.firewallpolicies-nfpmin-rg/providers/Microsoft.Network/firewallPolicies/<namePrefix>nfpmin001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.expressroutecircuits-nercmin-rg/providers/Microsoft.Network/expressRouteCircuits/<namePrefix>nercmin001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.expressroutecircuits-nercmax-rg/providers/Microsoft.Storage/storageAccounts/dep<namePrefix>diasanercmax01]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.expressroutecircuits-nercmax-rg/providers/Microsoft.Network/expressRouteCircuits/<namePrefix>nercmax001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.expressroutecircuits-nercmax-rg/providers/Microsoft.EventHub/namespaces/dep-<namePrefix>-evhns-nercmax]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsResolvers-ndrwaf-rg/providers/Microsoft.Network/virtualNetworks/dep-<namePrefix>-vnet-ndrwaf]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsResolvers-ndrwaf-rg/providers/Microsoft.Network/dnsResolvers/<namePrefix>ndrwaf001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsResolvers-ndrmin-rg/providers/Microsoft.Network/virtualNetworks/dep-<namePrefix>-vnet-ndrmin]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsResolvers-ndrmin-rg/providers/Microsoft.Network/dnsResolvers/<namePrefix>ndrmin001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsForwardingRuleset-ndfrswaf-rg/providers/Microsoft.Network/virtualNetworks/dep-<namePrefix>-vnet-ndfrswaf]       
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsForwardingRuleset-ndfrswaf-rg/providers/Microsoft.Network/dnsResolvers/dep-<namePrefix>-ndr-ndfrswaf]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsForwardingRuleset-ndfrswaf-rg/providers/Microsoft.Network/dnsForwardingRulesets/<namePrefix>ndfrswaf001]        
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-logic.workflows-lwwaf-rg/providers/Microsoft.Storage/storageAccounts/dep<namePrefix>diasalwwaf01]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/rg-dep-avmx-databricks.workspaces-dwwaf-rg-managed/providers/Microsoft.Storage/storageAccounts/saavmxdwwaf001]
VERBOSE: ----------------------------------
VERBOSE: [-] Removing resource [dep-<namePrefix>-vwan-nergmin] of type [Microsoft.Network/virtualWans]
VERBOSE: [-] Removing resource [pdnsout] of type [Microsoft.Network/dnsResolvers/outboundEndpoints]
WARNING: [!] Removal moved back for retry. Reason: [BadRequest : Existing outbound endpoint has DNS forwarding ruleset links that have to be deleted first before outbound endpoint can be deleted. outboundEndpointResourceId=/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsForwardingRuleset-ndfrswaf-rg/dnsResolvers/dep-<namePrefix>-ndr-ndfrswaf/outboundEndpoints/pdnsout, numberOfDnsForwardingRulesetLinks=1
CorrelationId: 5bca8494-6de9-4c01-be0d-5988811d0d9b]
VERBOSE: [-] Removing resource [dep-<namePrefix>-vnet-kvvwaf-vnetlink] of type [Microsoft.Network/privateDnsZones/virtualNetworkLinks]
DELETE /subscriptions/<subscriptionId>/r. [Starting - 0,00 % completed.                          ]
DELETE /subscriptions/<subscriptionId>/r. [Starting - 0,00 % completed.                          ]

                                                                                                                        VERBOSE: [-] Removing resource [<namePrefix>ndrwaf-az-pdnsin-x-001] of type [Microsoft.Network/dnsResolvers/inboundEndpoints]
VERBOSE: [-] Removing resource [master] of type [Microsoft.Sql/servers/databases]
WARNING: [!] Removal moved back for retry. Reason: [ResourceGroupNotFound : Resource group 'dep-<namePrefix>-sql.servers-sqlspe-rg' could not be found.
CorrelationId: 856b562e-9cc7-416a-9a00-797667b04ecb]
VERBOSE: [-] Removing resource [<namePrefix>ndrwaf-az-pdnsout-x-001] of type [Microsoft.Network/dnsResolvers/outboundEndpoints]  
VERBOSE: [-] Removing resource [<namePrefix>cicgenc001] of type [Microsoft.ContainerInstance/containerGroups]
WARNING: [!] Removal moved back for retry. Reason: [InternalServerError : Encountered an internal server error. The tracking activity id is '31388eb2-15b6-40fc-91d8-c4e9e92cba59', correlation id is 'f97aa916-0644-41b1-976b-8cc1f800bc3a'.
CorrelationId: f97aa916-0644-41b1-976b-8cc1f800bc3a]
VERBOSE: [-] Removing resource [dep<namePrefix>diasanvnwaf01] of type [Microsoft.Storage/storageAccounts]                        
VERBOSE: [-] Removing resource [<namePrefix>nvnwaf001] of type [Microsoft.Network/virtualNetworks]
VERBOSE: [-] Removing resource [dep-<namePrefix>-rt-nvnwaf] of type [Microsoft.Network/routeTables]
VERBOSE: [-] Removing resource [dep-<namePrefix>-nsg-nvnwaf] of type [Microsoft.Network/networkSecurityGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-nsg-bastion-nvnwaf] of type [Microsoft.Network/networkSecurityGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-evhns-nvnwaf] of type [Microsoft.EventHub/namespaces]
VERBOSE: [-] Removing resource [dep-<namePrefix>-vnet-nvnpeer] of type [Microsoft.Network/virtualNetworks]
VERBOSE: [-] Removing resource [<namePrefix>nvnpeer001] of type [Microsoft.Network/virtualNetworks]
VERBOSE: [-] Removing resource [dep-<namePrefix>-nsg-bastion-nvnpeer] of type [Microsoft.Network/networkSecurityGroups]
VERBOSE: [-] Removing resource [dep<namePrefix>diasanvnmax01] of type [Microsoft.Storage/storageAccounts]
VERBOSE: [-] Removing resource [<namePrefix>nvnmax001] of type [Microsoft.Network/virtualNetworks]
VERBOSE: [-] Removing resource [dep-<namePrefix>-rt-nvnmax] of type [Microsoft.Network/routeTables]
VERBOSE: [-] Removing resource [dep-<namePrefix>-nsg-nvnmax] of type [Microsoft.Network/networkSecurityGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-auto-oiwadv] of type [Microsoft.Automation/automationAccounts]
VERBOSE: [-] Removing resource [dep-<namePrefix>-ehn-oiwadv] of type [Microsoft.EventHub/namespaces]
VERBOSE: [-] Removing resource [dep-<namePrefix>-evhns-oiwadv] of type [Microsoft.EventHub/namespaces]
VERBOSE: [-] Removing resource [dep<namePrefix>diasaoiwadv01] of type [Microsoft.Storage/storageAccounts]
VERBOSE: [-] Removing resource [saavmxdwmax001] of type [Microsoft.Storage/storageAccounts]
VERBOSE: [-] Removing resource [unity-catalog-access-connector] of type [Microsoft.Databricks/accessConnectors]
VERBOSE: [-] Removing resource [q3qok4o2xgwxwvuvs86hucv0] of type [Microsoft.Storage/storageAccounts]
VERBOSE: [-] Removing resource [avmrhbhbmin001] of type [Microsoft.HealthBot/healthBots]
WARNING: [!] Removal moved back for retry. Reason: [400 : Resource not in terminal state. Wait until resource is in terminal provisioningState and try again
CorrelationId: ffb58929-b5db-48bb-aaa0-45285bf31114]
VERBOSE: [-] Removing resource [avmrhbhbmax001] of type [Microsoft.HealthBot/healthBots]
WARNING: [!] Removal moved back for retry. Reason: [400 : Resource not in terminal state. Wait until resource is in terminal provisioningState and try again
CorrelationId: 9bc0f1d4-e469-4569-83da-9bd95df04feb]
VERBOSE: [-] Removing resource [<namePrefix>swenua001] of type [Microsoft.Synapse/workspaces]                                    
VERBOSE: [-] Removing resource [dep<namePrefix>saswenua01] of type [Microsoft.Storage/storageAccounts]
VERBOSE: [-] Removing resource [dep-<namePrefix>-nsg-bastion-nvnmax] of type [Microsoft.Network/networkSecurityGroups]
VERBOSE: [-] Removing resource [<namePrefix>sbnmin001] of type [Microsoft.ServiceBus/namespaces]
VERBOSE: [-] Removing resource [<namePrefix>sssmax001] of type [Microsoft.Search/searchServices]
VERBOSE: [-] Removing resource [dep-<namePrefix>-evhns-sssmax01] of type [Microsoft.EventHub/namespaces]
VERBOSE: [-] Removing resource [dep<namePrefix>saoiwwaf] of type [Microsoft.Storage/storageAccounts]
VERBOSE: [-] Removing resource [dep<namePrefix>diasaoiwwaf01] of type [Microsoft.Storage/storageAccounts]
VERBOSE: [-] Removing resource [dep-<namePrefix>-evhns-oiwwaf] of type [Microsoft.EventHub/namespaces]
VERBOSE: [-] Removing resource [dep-<namePrefix>-auto-oiwwaf] of type [Microsoft.Automation/automationAccounts]
VERBOSE: [-] Removing resource [dep<namePrefix>saoiwadv] of type [Microsoft.Storage/storageAccounts]
VERBOSE: [-] Removing resource [dep<namePrefix>diasasssmax03] of type [Microsoft.Storage/storageAccounts]
VERBOSE: [-] Removing resource [dep-<namePrefix>-evhns-nvnmax] of type [Microsoft.EventHub/namespaces]
VERBOSE: [-] Removing resource [<namePrefix>npipmin001] of type [Microsoft.Network/publicIPPrefixes]
VERBOSE: [-] Removing resource [unity-catalog-access-connector] of type [Microsoft.Databricks/accessConnectors]
VERBOSE: [-] Removing resource [dep<namePrefix>diasakvvwaf03] of type [Microsoft.Storage/storageAccounts]
VERBOSE: [-] Removing resource [dep-<namePrefix>-vnet-kvvwaf] of type [Microsoft.Network/virtualNetworks]
VERBOSE: [-] Removing resource [privatelink.vaultcore.azure.net] of type [Microsoft.Network/privateDnsZones]
VERBOSE: [-] Removing resource [dep-<namePrefix>-evhns-kvvwaf01] of type [Microsoft.EventHub/namespaces]
VERBOSE: [-] Removing resource [<namePrefix>idcemin001] of type [Microsoft.Insights/dataCollectionEndpoints]
VERBOSE: [-] Removing resource [dep<namePrefix>saicmax] of type [Microsoft.Storage/storageAccounts]
VERBOSE: [-] Removing resource [dep<namePrefix>diasaicmax01] of type [Microsoft.Storage/storageAccounts]
VERBOSE: [-] Removing resource [<namePrefix>icmax001] of type [Microsoft.Insights/components]
VERBOSE: [-] Removing resource [dep-<namePrefix>-evhns-icmax] of type [Microsoft.EventHub/namespaces]
VERBOSE: [-] Removing resource [Failure Anomalies - <namePrefix>icmax001] of type [microsoft.alertsmanagement/smartDetectorAlertRules]
VERBOSE: [-] Removing resource [dep-<namePrefix>-vnet-ehnenc] of type [Microsoft.Network/virtualNetworks]
VERBOSE: [-] Removing resource [<namePrefix>ehnenc001] of type [Microsoft.EventHub/namespaces]
VERBOSE: [-] Removing resource [dep<namePrefix>diasadtdiwaf03] of type [Microsoft.Storage/storageAccounts]
VERBOSE: [-] Removing resource [dep-<namePrefix>-evhns-dtdiwaf01] of type [Microsoft.EventHub/namespaces]
VERBOSE: [-] Removing resource [<namePrefix>dtdiwaf001] of type [Microsoft.DigitalTwins/digitalTwinsInstances]
VERBOSE: [-] Removing resource [dep-<namePrefix>-evhns-lwwaf01] of type [Microsoft.EventHub/namespaces]
VERBOSE: [-] Removing resource [<namePrefix>npipwaf001] of type [Microsoft.Network/publicIPPrefixes]
VERBOSE: [-] Removing resource [<namePrefix>lwwaf001] of type [Microsoft.Logic/workflows]
VERBOSE: [-] Removing resource [<namePrefix>nagwafpmax001] of type [Microsoft.Network/applicationGatewayWebApplicationFirewallPolicies]
VERBOSE: [-] Removing resource [dep-<namePrefix>-vnet-npemin] of type [Microsoft.Network/virtualNetworks]
VERBOSE: [-] Removing resource [<namePrefix>nnmmin001] of type [Microsoft.Network/networkManagers]
VERBOSE: [-] Removing resource [<namePrefix>nfpmin001] of type [Microsoft.Network/firewallPolicies]
VERBOSE: [-] Removing resource [<namePrefix>nercmin001] of type [Microsoft.Network/expressRouteCircuits]
VERBOSE: [-] Removing resource [dep<namePrefix>diasanercmax01] of type [Microsoft.Storage/storageAccounts]
VERBOSE: [-] Removing resource [<namePrefix>nercmax001] of type [Microsoft.Network/expressRouteCircuits]
VERBOSE: [-] Removing resource [dep-<namePrefix>-evhns-nercmax] of type [Microsoft.EventHub/namespaces]
VERBOSE: [-] Removing resource [dep-<namePrefix>-vnet-ndrwaf] of type [Microsoft.Network/virtualNetworks]
VERBOSE: [-] Removing resource [<namePrefix>ndrwaf001] of type [Microsoft.Network/dnsResolvers]
VERBOSE: [-] Removing resource [dep-<namePrefix>-vnet-ndrmin] of type [Microsoft.Network/virtualNetworks]
VERBOSE: [-] Removing resource [<namePrefix>ndrmin001] of type [Microsoft.Network/dnsResolvers]
VERBOSE: [-] Removing resource [dep-<namePrefix>-vnet-ndfrswaf] of type [Microsoft.Network/virtualNetworks]
WARNING: [!] Removal moved back for retry. Reason: [InUseSubnetCannotBeDeleted : Subnet subnet-1 is in use by /subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsForwardingRuleset-ndfrswaf-rg/providers/Microsoft.Network/virtualNetworks/dep-<namePrefix>-vnet-ndfrswaf/subnets/subnet-1/serviceAssociationLinks/dnsResolverLink and cannot be deleted. In order to delete the subnet, delete all the resources within the subnet. See aka.ms/deletesubnet.
CorrelationId: 636498cc-a349-4dbd-8c67-c9d2e020db3e]
VERBOSE: [-] Removing resource [dep-<namePrefix>-ndr-ndfrswaf] of type [Microsoft.Network/dnsResolvers]                          
WARNING: [!] Removal moved back for retry. Reason: [CannotDeleteResource : Cannot delete resource while nested resources exist. Some existing nested resource IDs include: 'Microsoft.Network/dnsResolvers/dep-<namePrefix>-ndr-ndfrswaf/outboundEndpoints/pdnsout'. Please delete all nested resources before deleting this resource.
CorrelationId: 5a56e4c8-d626-46bb-bd81-783138352cae]
VERBOSE: [-] Removing resource [<namePrefix>ndfrswaf001] of type [Microsoft.Network/dnsForwardingRulesets]                       
VERBOSE: [-] Removing resource [dep<namePrefix>diasalwwaf01] of type [Microsoft.Storage/storageAccounts]
VERBOSE: [-] Removing resource [saavmxdwwaf001] of type [Microsoft.Storage/storageAccounts]
VERBOSE: ----------------------------------
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsForwardingRuleset-ndfrswaf-rg/providers/Microsoft.Network/dnsResolvers/dep-<namePrefix>-ndr-ndfrswaf/outboundEndpoints/pdnsout]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-sql.servers-sqlspe-rg/providers/Microsoft.Sql/servers/<namePrefix>-sqlspe/databases/master]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg/providers/Microsoft.ContainerInstance/containerGroups/<namePrefix>cicgenc001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmin-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmin001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmax-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmax001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsForwardingRuleset-ndfrswaf-rg/providers/Microsoft.Network/virtualNetworks/dep-<namePrefix>-vnet-ndfrswaf]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsForwardingRuleset-ndfrswaf-rg/providers/Microsoft.Network/dnsResolvers/dep-<namePrefix>-ndr-ndfrswaf]
VERBOSE: ----------------------------------                                                                             
VERBOSE: [-] Removing resource [pdnsout] of type [Microsoft.Network/dnsResolvers/outboundEndpoints]                     
VERBOSE: [-] Removing resource [master] of type [Microsoft.Sql/servers/databases]
WARNING: [!] Removal moved back for retry. Reason: [ResourceGroupNotFound : Resource group 'dep-<namePrefix>-sql.servers-sqlspe-rg' could not be found.
CorrelationId: 15c85c04-aaa5-41a8-a012-5db2d08b2f88]
VERBOSE: [-] Removing resource [<namePrefix>cicgenc001] of type [Microsoft.ContainerInstance/containerGroups]                    
WARNING: [!] Removal moved back for retry. Reason: [InternalServerError : Encountered an internal server error. The tracking activity id is '3220689c-83cf-45f8-a4a1-5c12150cf1bb', correlation id is '577dd566-cd51-487e-9c98-cc0e4486ce02'.
CorrelationId: 577dd566-cd51-487e-9c98-cc0e4486ce02]
VERBOSE: [-] Removing resource [avmrhbhbmin001] of type [Microsoft.HealthBot/healthBots]                                
WARNING: [!] Removal moved back for retry. Reason: [400 : Resource not in terminal state. Wait until resource is in terminal provisioningState and try again
CorrelationId: 81d5f560-b89c-4159-ad4c-b3aba2dd5f12]
VERBOSE: [-] Removing resource [avmrhbhbmax001] of type [Microsoft.HealthBot/healthBots]                                
WARNING: [!] Removal moved back for retry. Reason: [400 : Resource not in terminal state. Wait until resource is in terminal provisioningState and try again
CorrelationId: 1dd1305e-d7e2-4166-8193-78a6e053759c]
VERBOSE: [-] Removing resource [dep-<namePrefix>-vnet-ndfrswaf] of type [Microsoft.Network/virtualNetworks]                      
VERBOSE: [-] Removing resource [dep-<namePrefix>-ndr-ndfrswaf] of type [Microsoft.Network/dnsResolvers]
VERBOSE: ----------------------------------
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-sql.servers-sqlspe-rg/providers/Microsoft.Sql/servers/<namePrefix>-sqlspe/databases/master]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg/providers/Microsoft.ContainerInstance/containerGroups/<namePrefix>cicgenc001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmin-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmin001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmax-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmax001]
VERBOSE: ----------------------------------                                                                             
VERBOSE: [-] Removing resource [master] of type [Microsoft.Sql/servers/databases]                                       
WARNING: [!] Removal moved back for retry. Reason: [ResourceGroupNotFound : Resource group 'dep-<namePrefix>-sql.servers-sqlspe-rg' could not be found.
CorrelationId: 632be08b-bc75-461e-988c-5269717cb199]
VERBOSE: [-] Removing resource [<namePrefix>cicgenc001] of type [Microsoft.ContainerInstance/containerGroups]                    
WARNING: [!] Removal moved back for retry. Reason: [InternalServerError : Encountered an internal server error. The tracking activity id is 'be6e61ad-ec39-4c10-86c8-ed36817db00a', correlation id is '696735a0-485f-44e6-9ecf-92915f9db5b4'.
CorrelationId: 696735a0-485f-44e6-9ecf-92915f9db5b4]
VERBOSE: [-] Removing resource [avmrhbhbmin001] of type [Microsoft.HealthBot/healthBots]                                
WARNING: [!] Removal moved back for retry. Reason: [400 : Resource not in terminal state. Wait until resource is in terminal provisioningState and try again
CorrelationId: 39e58329-ed01-43c2-868c-0dfc710198db]
VERBOSE: [-] Removing resource [avmrhbhbmax001] of type [Microsoft.HealthBot/healthBots]                                
WARNING: [!] Removal moved back for retry. Reason: [400 : Resource not in terminal state. Wait until resource is in terminal provisioningState and try again
CorrelationId: 5f7a64b8-2d6e-4ea8-a8b9-03face113b0b]
VERBOSE: ----------------------------------                                                                             
Exception: C:\dev\bicep-registry-modules\avm\utilities\pipelines\e2eValidation\resourceRemoval\helper\Remove-ResourceList.ps1:124:9
Line |                                                                                                                  
 124 |          throw ('The removal failed for resources [{0}]' -f ((Split-Pa …                                         
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                           
     | The removal failed for resources [master, <namePrefix>cicgenc001, avmrhbhbmin001, avmrhbhbmax001]   
``` 

</details>

<details>
<summary>Execution after adding RG support</summary>

``` 
PS C:\dev\bicep-registry-modules> Initialize-DeploymentRemoval -RemoveAllDepResources
VERBOSE: Total number of deployment target resources after fetching deployments [36]
VERBOSE: Total number of deployment target resources after pre-filtering (duplicates) & ordering items [36]
VERBOSE: Total number of deployment target resources after formatting items [36]
VERBOSE: Total number of deployments after filtering all dependency resources [36]
VERBOSE: Total number of deployments after final ordering of resources [36]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.publicipprefixes-npipmin-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.publicipprefixes-npipwaf-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnmax-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnpeer-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.virtualnetworks-nvnwaf-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-operationalinsights.workspaces-oiwadv-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-search.searchservices-sssmax-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.privateendpoints-npemin-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-servicebus.namespaces-sbnmin-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-synapse.workspaces-swenua-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmax-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmin-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/IT_dep-<namePrefix>-compute.images-cimin-rg_dep-<namePrefix>-_0cde4fa3-334a-4ea8-be55-f9ca6584e6e1]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-operationalinsights.workspaces-oiwwaf-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.networkmanagers-nnmmin-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.expressRouteGateway-nergmin-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/rg-dep-avmx-databricks.workspaces-dwmax-rg-managed]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.expressroutecircuits-nercmin-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.expressroutecircuits-nercmax-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsResolvers-ndrwaf-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsResolvers-ndrmin-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.dnsForwardingRuleset-ndfrswaf-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.applicationGatewayWebApplicationFirewallPolicies-nagwafpmax-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-logic.workflows-lwwaf-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-keyvault.vaults-kvvwaf-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-insights.dataCollectionEndpoints-idcemin-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-insights.components-icmax-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-eventhub.namespaces-ehnenc-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-digitaltwins.digitaltwinsinstances-dtdiwaf-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-network.firewallpolicies-nfpmin-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/rg-dep-avmx-databricks.workspaces-dwwaf-rg-managed]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-sql.servers-sqlspe-rg/providers/Microsoft.Sql/servers/<namePrefix>-sqlspe/databases/master]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg/providers/Microsoft.ContainerInstance/containerGroups/<namePrefix>cicgenc001] 
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmax-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmax001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmin-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmin001]
VERBOSE: ----------------------------------
VERBOSE: [-] Removing resource [dep-<namePrefix>-network.publicipprefixes-npipmin-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-network.publicipprefixes-npipwaf-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-network.virtualnetworks-nvnmax-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-network.virtualnetworks-nvnpeer-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-network.virtualnetworks-nvnwaf-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-operationalinsights.workspaces-oiwadv-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-search.searchservices-sssmax-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-network.privateendpoints-npemin-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-servicebus.namespaces-sbnmin-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-synapse.workspaces-swenua-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-avmr-healthbot.healthbots-hbhbmax-rg] of type [Microsoft.Resources/resourceGroups]
WARNING: [!] Removal moved back for retry. Reason: [{"error":{"code":"ResourceGroupDeletionBlocked","message":"Deletion of resource group 'dep-avmr-healthbot.healthbots-hbhbmax-rg' failed as resources with identifiers 'Microsoft.HealthBot/healthBots/avmrhbhbmax001' could not be deleted. The provisioning state of the resource group will be rolled back. The tracking Id is '270ed8ad-68a0-476a-942c-6d22377c36a9'. Please check audit logs for more details.","details":[{"target":"/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmax-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmax001","message":"{\"error\":{\"code\":\"400\",\"message\":\"Resource not in terminal state. Wait until resource is in terminal provisioningState and try again\"}}"}]}}
CorrelationId: b90bb002-14f7-4032-832b-69ae37e3b30a]
VERBOSE: [-] Removing resource [dep-avmr-healthbot.healthbots-hbhbmin-rg] of type [Microsoft.Resources/resourceGroups]  
WARNING: [!] Removal moved back for retry. Reason: [{"error":{"code":"ResourceGroupDeletionBlocked","message":"Deletion of resource group 'dep-avmr-healthbot.healthbots-hbhbmin-rg' failed as resources with identifiers 'Microsoft.HealthBot/healthBots/avmrhbhbmin001' could not be deleted. The provisioning state of the resource group will be rolled back. The tracking Id is '701812e8-5059-4a92-97d6-c0d35fc92d44'. Please check audit logs for more details.","details":[{"target":"/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmin-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmin001","message":"{\"error\":{\"code\":\"400\",\"message\":\"Resource not in terminal state. Wait until resource is in terminal provisioningState and try again\"}}"}]}}
CorrelationId: 3ca89140-4603-49e7-93e3-0c959fb97014]
VERBOSE: [-] Removing resource [IT_dep-<namePrefix>-compute.images-cimin-rg_dep-<namePrefix>-_0cde4fa3-334a-4ea8-be55-f9ca6584e6e1] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-operationalinsights.workspaces-oiwwaf-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-network.networkmanagers-nnmmin-rg] of type [Microsoft.Resources/resourceGroups] 
VERBOSE: [-] Removing resource [dep-<namePrefix>-network.expressRouteGateway-nergmin-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [rg-dep-avmx-databricks.workspaces-dwmax-rg-managed] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-network.expressroutecircuits-nercmin-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-network.expressroutecircuits-nercmax-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-network.dnsResolvers-ndrwaf-rg] of type [Microsoft.Resources/resourceGroups]    
VERBOSE: [-] Removing resource [dep-<namePrefix>-network.dnsResolvers-ndrmin-rg] of type [Microsoft.Resources/resourceGroups]    
VERBOSE: [-] Removing resource [dep-<namePrefix>-network.dnsForwardingRuleset-ndfrswaf-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-network.applicationGatewayWebApplicationFirewallPolicies-nagwafpmax-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-logic.workflows-lwwaf-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-keyvault.vaults-kvvwaf-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-insights.dataCollectionEndpoints-idcemin-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-insights.components-icmax-rg] of type [Microsoft.Resources/resourceGroups]      
VERBOSE: [-] Removing resource [dep-<namePrefix>-eventhub.namespaces-ehnenc-rg] of type [Microsoft.Resources/resourceGroups]     
VERBOSE: [-] Removing resource [dep-<namePrefix>-digitaltwins.digitaltwinsinstances-dtdiwaf-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg] of type [Microsoft.Resources/resourceGroups]
WARNING: [!] Removal moved back for retry. Reason: [{"error":{"code":"ResourceGroupDeletionTimeout","message":"Deletion of resource group 'dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg' did not finish within the allowed time as resources with identifiers 'Microsoft.ContainerInstance/containerGroups/<namePrefix>cicgenc001' could not be deleted. The provisioning state of the resource group will be rolled back. The tracking Id is '3ab01252-3168-4ef2-8491-5317dae1db41'. Please check audit logs for more details.","details":[{"target":"/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg/providers/Microsoft.ContainerInstance/containerGroups/<namePrefix>cicgenc001","message":"{\"error\":{\"code\":\"InternalServerError\",\"message\":\"Encountered an internal server error. The tracking activity id is 'c0cd7e57-12ec-4d56-a001-c03780eef578', correlation id is '3ab01252-3168-4ef2-8491-5317dae1db41'.\"}}"}]}}
CorrelationId: 873c04ae-e730-4e41-adb1-e85f7b8f9fef]
VERBOSE: [-] Removing resource [dep-<namePrefix>-network.firewallpolicies-nfpmin-rg] of type [Microsoft.Resources/resourceGroups]
VERBOSE: [-] Removing resource [rg-dep-avmx-databricks.workspaces-dwwaf-rg-managed] of type [Microsoft.Resources/resourceGroups]
WARNING: [!] Removal moved back for retry. Reason: [ResourceGroupNotFound : Resource group 'rg-dep-avmx-databricks.workspaces-dwwaf-rg-managed' could not be found.
CorrelationId: 6c61fe5d-7233-4ad6-b33a-c4ef906bd270]
VERBOSE: [-] Removing resource [master] of type [Microsoft.Sql/servers/databases]                                       
WARNING: [!] Removal moved back for retry. Reason: [ResourceGroupNotFound : Resource group 'dep-<namePrefix>-sql.servers-sqlspe-rg' could not be found.
CorrelationId: 2c130ff7-ca6b-462d-a722-fbf18fbd86e8]
VERBOSE: [-] Removing resource [<namePrefix>cicgenc001] of type [Microsoft.ContainerInstance/containerGroups]                    
WARNING: [!] Removal moved back for retry. Reason: [InternalServerError : Encountered an internal server error. The tracking activity id is '609139de-e745-49a7-922c-d40caf735f18', correlation id is 'b913c064-03dd-4e7a-ab30-4e39155d12ef'.
CorrelationId: b913c064-03dd-4e7a-ab30-4e39155d12ef]
VERBOSE: [-] Removing resource [avmrhbhbmax001] of type [Microsoft.HealthBot/healthBots]                                
WARNING: [!] Removal moved back for retry. Reason: [400 : Resource not in terminal state. Wait until resource is in terminal provisioningState and try again
CorrelationId: c00fbfc3-307d-4129-a24b-0957c01d453a]
VERBOSE: [-] Removing resource [avmrhbhbmin001] of type [Microsoft.HealthBot/healthBots]
WARNING: [!] Removal moved back for retry. Reason: [400 : Resource not in terminal state. Wait until resource is in terminal provisioningState and try again
CorrelationId: e73374cb-84e0-40af-adbd-f09607d63879]
VERBOSE: ----------------------------------                                                                             
VERBOSE: Retry removal of remaining [8] resources. Waiting [15] seconds. Round [1|3]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmax-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmin-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/rg-dep-avmx-databricks.workspaces-dwwaf-rg-managed]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-sql.servers-sqlspe-rg/providers/Microsoft.Sql/servers/<namePrefix>-sqlspe/databases/master]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg/providers/Microsoft.ContainerInstance/containerGroups/<namePrefix>cicgenc001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmax-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmax001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmin-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmin001]
VERBOSE: ----------------------------------                                                                             
VERBOSE: [-] Removing resource [dep-avmr-healthbot.healthbots-hbhbmax-rg] of type [Microsoft.Resources/resourceGroups]  
WARNING: [!] Removal moved back for retry. Reason: [{"error":{"code":"ResourceGroupDeletionBlocked","message":"Deletion of resource group 'dep-avmr-healthbot.healthbots-hbhbmax-rg' failed as resources with identifiers 'Microsoft.HealthBot/healthBots/avmrhbhbmax001' could not be deleted. The provisioning state of the resource group will be rolled back. The tracking Id is '4b5a669c-71fa-4872-a74e-f7dc9e42fdcd'. Please check audit logs for more details.","details":[{"target":"/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmax-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmax001","message":"{\"error\":{\"code\":\"400\",\"message\":\"Resource not in terminal state. Wait until resource is in terminal provisioningState and try again\"}}"}]}}
CorrelationId: f027db06-7884-44cd-bbd5-503b9f853401]
VERBOSE: [-] Removing resource [dep-avmr-healthbot.healthbots-hbhbmin-rg] of type [Microsoft.Resources/resourceGroups]  
WARNING: [!] Removal moved back for retry. Reason: [{"error":{"code":"ResourceGroupDeletionBlocked","message":"Deletion of resource group 'dep-avmr-healthbot.healthbots-hbhbmin-rg' failed as resources with identifiers 'Microsoft.HealthBot/healthBots/avmrhbhbmin001' could not be deleted. The provisioning state of the resource group will be rolled back. The tracking Id is '895a795f-d6fb-4df0-90ad-05d5e5767bc8'. Please check audit logs for more details.","details":[{"target":"/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmin-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmin001","message":"{\"error\":{\"code\":\"400\",\"message\":\"Resource not in terminal state. Wait until resource is in terminal provisioningState and try again\"}}"}]}}
CorrelationId: 290f9cb4-27d9-49e8-8e5c-89aeb1b24548]
VERBOSE: [-] Removing resource [dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg] of type [Microsoft.Resources/resourceGroups]
WARNING: [!] Removal moved back for retry. Reason: [{"error":{"code":"ResourceGroupDeletionTimeout","message":"Deletion of resource group 'dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg' did not finish within the allowed time as resources with identifiers 'Microsoft.ContainerInstance/containerGroups/<namePrefix>cicgenc001' could not be deleted. The provisioning state of the resource group will be rolled back. The tracking Id is '9068dc6f-57ad-4b54-a0b9-0a97223e8eae'. Please check audit logs for more details.","details":[{"target":"/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg/providers/Microsoft.ContainerInstance/containerGroups/<namePrefix>cicgenc001","message":"{\"error\":{\"code\":\"InternalServerError\",\"message\":\"Encountered an internal server error. The tracking activity id is '5119291c-288d-48ab-b1e1-dfa90c29cad6', correlation id is '9068dc6f-57ad-4b54-a0b9-0a97223e8eae'.\"}}"}]}}
CorrelationId: 68196e76-7bdd-4e47-ab29-ad51b6eddcd4]
VERBOSE: [-] Removing resource [rg-dep-avmx-databricks.workspaces-dwwaf-rg-managed] of type [Microsoft.Resources/resourceGroups]
WARNING: [!] Removal moved back for retry. Reason: [ResourceGroupNotFound : Resource group 'rg-dep-avmx-databricks.workspaces-dwwaf-rg-managed' could not be found.
CorrelationId: 1b17ec09-6039-4785-9112-e43acb7cda1f]
VERBOSE: [-] Removing resource [master] of type [Microsoft.Sql/servers/databases]                                       
WARNING: [!] Removal moved back for retry. Reason: [ResourceGroupNotFound : Resource group 'dep-<namePrefix>-sql.servers-sqlspe-rg' could not be found.
CorrelationId: 4e03c4f3-4605-4ad4-b672-f37b231fecbb]
VERBOSE: [-] Removing resource [<namePrefix>cicgenc001] of type [Microsoft.ContainerInstance/containerGroups]                    
WARNING: [!] Removal moved back for retry. Reason: [InternalServerError : Encountered an internal server error. The tracking activity id is '92c169ae-e964-4bce-a31d-f13307e729ea', correlation id is '0eec5b46-fc55-4e88-9409-95f1c9933cd4'.
CorrelationId: 0eec5b46-fc55-4e88-9409-95f1c9933cd4]
VERBOSE: [-] Removing resource [avmrhbhbmax001] of type [Microsoft.HealthBot/healthBots]                                
WARNING: [!] Removal moved back for retry. Reason: [400 : Resource not in terminal state. Wait until resource is in terminal provisioningState and try again
CorrelationId: edb388a1-6e3e-48fd-803f-4c173ffe8184]
VERBOSE: [-] Removing resource [avmrhbhbmin001] of type [Microsoft.HealthBot/healthBots]                                
WARNING: [!] Removal moved back for retry. Reason: [400 : Resource not in terminal state. Wait until resource is in terminal provisioningState and try again
CorrelationId: 3f721795-2e7f-4cb9-bf40-e41e29589f23]
VERBOSE: ----------------------------------                                                                             
VERBOSE: Retry removal of remaining [8] resources. Waiting [15] seconds. Round [2|3]                                    
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmax-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmin-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/rg-dep-avmx-databricks.workspaces-dwwaf-rg-managed]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-sql.servers-sqlspe-rg/providers/Microsoft.Sql/servers/<namePrefix>-sqlspe/databases/master]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg/providers/Microsoft.ContainerInstance/containerGroups/<namePrefix>cicgenc001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmax-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmax001]
VERBOSE: - Remove [/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmin-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmin001]
VERBOSE: ----------------------------------                                                                             
VERBOSE: [-] Removing resource [dep-avmr-healthbot.healthbots-hbhbmax-rg] of type [Microsoft.Resources/resourceGroups]  
WARNING: [!] Removal moved back for retry. Reason: [{"error":{"code":"ResourceGroupDeletionBlocked","message":"Deletion of resource group 'dep-avmr-healthbot.healthbots-hbhbmax-rg' failed as resources with identifiers 'Microsoft.HealthBot/healthBots/avmrhbhbmax001' could not be deleted. The provisioning state of the resource group will be rolled back. The tracking Id is '672f3094-43a1-4eb6-859b-f9e2fe7d086f'. Please check audit logs for more details.","details":[{"target":"/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmax-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmax001","message":"{\"error\":{\"code\":\"400\",\"message\":\"Resource not in terminal state. Wait until resource is in terminal provisioningState and try again\"}}"}]}}
CorrelationId: 3ad140d1-9d60-47fc-83ae-4cbdc0ce33e3]
VERBOSE: [-] Removing resource [dep-avmr-healthbot.healthbots-hbhbmin-rg] of type [Microsoft.Resources/resourceGroups]  
WARNING: [!] Removal moved back for retry. Reason: [{"error":{"code":"ResourceGroupDeletionBlocked","message":"Deletion of resource group 'dep-avmr-healthbot.healthbots-hbhbmin-rg' failed as resources with identifiers 'Microsoft.HealthBot/healthBots/avmrhbhbmin001' could not be deleted. The provisioning state of the resource group will be rolled back. The tracking Id is '721645e9-ac6b-450a-a08a-e05e57dee3a3'. Please check audit logs for more details.","details":[{"target":"/subscriptions/<subscriptionId>/resourceGroups/dep-avmr-healthbot.healthbots-hbhbmin-rg/providers/Microsoft.HealthBot/healthBots/avmrhbhbmin001","message":"{\"error\":{\"code\":\"400\",\"message\":\"Resource not in terminal state. Wait until resource is in terminal provisioningState and try again\"}}"}]}}
CorrelationId: de39ed72-ca70-43be-950f-0177cfdfc54a]
VERBOSE: [-] Removing resource [dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg] of type [Microsoft.Resources/resourceGroups]
WARNING: [!] Removal moved back for retry. Reason: [No such host is known. (management.azure.com:443)]
VERBOSE: [-] Removing resource [rg-dep-avmx-databricks.workspaces-dwwaf-rg-managed] of type [Microsoft.Resources/resourceGroups]
WARNING: [!] Removal moved back for retry. Reason: [ResourceGroupNotFound : Resource group 'rg-dep-avmx-databricks.workspaces-dwwaf-rg-managed' could not be found.
CorrelationId: e8f0a716-c316-4179-9f18-5f364c6df5bf]
VERBOSE: [-] Removing resource [master] of type [Microsoft.Sql/servers/databases]                                       
WARNING: [!] Removal moved back for retry. Reason: [ResourceGroupNotFound : Resource group 'dep-<namePrefix>-sql.servers-sqlspe-rg' could not be found.
CorrelationId: 62edcdde-c886-4638-9f33-1c8c96f3dc12]
VERBOSE: [-] Removing resource [<namePrefix>cicgenc001] of type [Microsoft.ContainerInstance/containerGroups]                    
WARNING: [!] Removal moved back for retry. Reason: [InternalServerError : Encountered an internal server error. The tracking activity id is '819de35f-9f5b-4782-801b-833fb84309e2', correlation id is '37ca6aaa-87f3-48ff-bcc9-6acf23fa80bc'.
CorrelationId: 37ca6aaa-87f3-48ff-bcc9-6acf23fa80bc]
VERBOSE: [-] Removing resource [avmrhbhbmax001] of type [Microsoft.HealthBot/healthBots]                                
WARNING: [!] Removal moved back for retry. Reason: [400 : Resource not in terminal state. Wait until resource is in terminal provisioningState and try again
CorrelationId: fb86ed27-6d42-4393-b04d-08e43b07904d]
VERBOSE: [-] Removing resource [avmrhbhbmin001] of type [Microsoft.HealthBot/healthBots]                                
WARNING: [!] Removal moved back for retry. Reason: [400 : Resource not in terminal state. Wait until resource is in terminal provisioningState and try again
CorrelationId: 7cbb2e66-2269-4372-9ce6-d3a2163b76d2]
VERBOSE: ----------------------------------                                                                             
VERBOSE: Retry removal of remaining [8] resources. Waiting [15] seconds. Round [3|3]                                    
Exception: C:\dev\bicep-registry-modules\avm\utilities\pipelines\e2eValidation\resourceRemoval\helper\Remove-ResourceList.ps1:124:9
Line |                                                                                                                  
 124 |          throw ('The removal failed for resources [{0}]' -f ((Split-Pa …                                         
     |          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~                                           
     | The removal failed for resources [dep-avmr-healthbot.healthbots-hbhbmax-rg, dep-avmr-healthbot.healthbots-hbhbmin-rg, dep-<namePrefix>-containerinstance.containergroups-cicgenc-rg,
     | rg-dep-avmx-databricks.workspaces-dwwaf-rg-managed, master, <namePrefix>cicgenc001, avmrhbhbmax001, avmrhbhbmin001]       
```

</details>

## Pipeline Reference

<!-- Insert your Pipeline Status Badge below -->

| Pipeline |
| -------- |
|
[![avm.res.analysis-services.server](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.analysis-services.server.yml/badge.svg?branch=users%2Falsehr%2FresourceRemoval&event=workflow_dispatch)](https://github.com/AlexanderSehr/bicep-registry-modules/actions/workflows/avm.res.analysis-services.server.yml)
|

## Type of Change

<!-- Use the check-boxes [x] on the options that are relevant. -->

- [x] Update to CI Environment or utlities (Non-module effecting
changes)
- [ ] Azure Verified Module updates:
- [ ] Bugfix containing backwards compatible bug fixes, and I have NOT
bumped the MAJOR or MINOR version in `version.json`:
- [ ] Someone has opened a bug report issue, and I have included "Closes
#{bug_report_issue_number}" in the PR description.
- [ ] The bug was found by the module author, and no one has opened an
issue to report it yet.
- [ ] Feature update backwards compatible feature updates, and I have
bumped the MINOR version in `version.json`.
- [ ] Breaking changes and I have bumped the MAJOR version in
`version.json`.
  - [ ] Update to documentation

---------

Co-authored-by: Erika Gressi <[email protected]>
Co-authored-by: ChrisSidebotham-MSFT <[email protected]>
  • Loading branch information
3 people authored Apr 8, 2024
1 parent 9047955 commit 5d8c00a
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,23 @@ Remove deployed resources based on their deploymentName(s)
Remove deployed resources based on their deploymentName(s)
.PARAMETER DeploymentName(s)
Mandatory. The name(s) of the deployment(s)
Optional. The name(s) of the deployment(s). Combined with resources provide via the resource Id(s).
.PARAMETER ResourceId(s)
Optional. The resource Id(s) of the resources to remove. Combined with resources found via the deployment name(s).
.PARAMETER TemplateFilePath
Mandatory. The path to the template used for the deployment. Used to determine the level/scope (e.g. subscription)
Optional. The path to the template used for the deployment(s). Used to determine the level/scope (e.g. subscription). Required if deploymentName(s) are provided.
.PARAMETER ResourceGroupName
Optional. The name of the resource group the deployment was happening in. Relevant for resource-group level deployments.
.PARAMETER ManagementGroupId
Optional. The ID of the management group to fetch deployments from. Relevant for management-group level deployments.
.PARAMETER PurgeTestResources
Optional. Specify to fetch and remove all resources in the current context that match the 'dep-' pattern
.EXAMPLE
Initialize-DeploymentRemoval -DeploymentName 'n-vw-t1-20211204T1812029146Z' -TemplateFilePath "$home/ResourceModules/modules/network/virtual-wan/main.bicep" -resourceGroupName 'test-virtualWan-rg'
Expand All @@ -26,21 +32,28 @@ function Initialize-DeploymentRemoval {

[CmdletBinding()]
param (
[Parameter(Mandatory = $true)]
[Parameter(Mandatory = $false)]
[Alias('DeploymentName')]
[string[]] $DeploymentNames,
[string[]] $DeploymentNames = @(),

[Parameter(Mandatory = $true)]
[Parameter(Mandatory = $false)]
[Alias('ResourceId')]
[string[]] $ResourceIds = @(),

[Parameter(Mandatory = $false)]
[string] $TemplateFilePath,

[Parameter(Mandatory = $false)]
[string] $ResourceGroupName,

[Parameter(Mandatory = $false)]
[string] $subscriptionId,
[string] $SubscriptionId,

[Parameter(Mandatory = $false)]
[string] $ManagementGroupId,

[Parameter(Mandatory = $false)]
[string] $ManagementGroupId
[switch] $PurgeTestResources
)

begin {
Expand Down Expand Up @@ -82,7 +95,18 @@ function Initialize-DeploymentRemoval {
'Microsoft.Resources/resourceGroups'
)

Write-Verbose ('Handling resource removal with deployment names [{0}]' -f ($deploymentNames -join ', ')) -Verbose
if ($DeploymentNames.Count -gt 0) {
Write-Verbose 'Handling resource removal with deployment names' -Verbose
foreach ($DeploymentName in $DeploymentNames) {
Write-Verbose "- $DeploymentName" -Verbose
}
}
if ($ResourceIds.Count -gt 0) {
Write-Verbose 'Handling resource removal with resource Ids' -Verbose
foreach ($ResourceId in $ResourceIds) {
Write-Verbose "- $ResourceId" -Verbose
}
}

### CODE LOCATION: Add custom removal sequence here
## Add custom module-specific removal sequence following the example below
Expand All @@ -98,14 +122,28 @@ function Initialize-DeploymentRemoval {
# }
# }

if ($PurgeTestResources) {
# Resources
$filteredResourceIds = (Get-AzResource).ResourceId | Where-Object { $_ -like '*dep-*' }
$ResourceIds += ($filteredResourceIds | Sort-Object -Unique)

# Resource groups
$filteredResourceGroupIds = (Get-AzResourceGroup).ResourceId | Where-Object { $_ -like '*dep-*' }
$ResourceIds += ($filteredResourceGroupIds | Sort-Object -Unique)
}

# Invoke removal
$inputObject = @{
DeploymentNames = $DeploymentNames
TemplateFilePath = $templateFilePath
ResourceIds = $ResourceIds
TemplateFilePath = $TemplateFilePath
RemovalSequence = $removalSequence
}
if (-not [String]::IsNullOrEmpty($resourceGroupName)) {
$inputObject['resourceGroupName'] = $resourceGroupName
if (-not [String]::IsNullOrEmpty($TemplateFilePath)) {
$inputObject['TemplateFilePath'] = $TemplateFilePath
}
if (-not [String]::IsNullOrEmpty($ResourceGroupName)) {
$inputObject['ResourceGroupName'] = $ResourceGroupName
}
if (-not [String]::IsNullOrEmpty($ManagementGroupId)) {
$inputObject['ManagementGroupId'] = $ManagementGroupId
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@ Optional. The resource group of the resource to remove
.PARAMETER ManagementGroupId
Optional. The ID of the management group to fetch deployments from. Relevant for management-group level deployments.
.PARAMETER DeploymentNames
Optional. The deployment names to use for the removal
.PARAMETER DeploymentName(s)
Optional. The name(s) of the deployment(s). Combined with resources provide via the resource Id(s).
.PARAMETER ResourceId(s)
Optional. The resource Id(s) of the resources to remove. Combined with resources found via the deployment name(s).
.PARAMETER TemplateFilePath
Mandatory. The path to the deployment file
Optional. The path to the template used for the deployment(s). Used to determine the level/scope (e.g. subscription). Required if deploymentName(s) are provided.
.PARAMETER RemovalSequence
Optional. The order of resource types to apply for deletion
Expand All @@ -39,10 +42,13 @@ function Remove-Deployment {
[Parameter(Mandatory = $false)]
[string] $ManagementGroupId,

[Parameter(Mandatory = $true)]
[string[]] $DeploymentNames,
[Parameter(Mandatory = $false)]
[string[]] $DeploymentNames = @(),

[Parameter(Mandatory = $false)]
[string[]] $ResourceIds = @(),

[Parameter(Mandatory = $true)]
[Parameter(Mandatory = $false)]
[string] $TemplateFilePath,

[Parameter(Mandatory = $false)]
Expand All @@ -63,36 +69,39 @@ function Remove-Deployment {
process {
$azContext = Get-AzContext

# Prepare data
# ============
$deploymentScope = Get-ScopeOfTemplateFile -TemplateFilePath $TemplateFilePath
$deployedTargetResources = $ResourceIds

# Fundamental checks
if ($deploymentScope -eq 'resourcegroup' -and -not (Get-AzResourceGroup -Name $ResourceGroupName -ErrorAction 'SilentlyContinue')) {
Write-Verbose "Resource group [$ResourceGroupName] does not exist (anymore). Skipping removal of its contained resources" -Verbose
return
}

# Fetch deployments
# =================
$deployedTargetResources = @()
if ($DeploymentNames.Count -gt 0) {
# Prepare data
# ============
$deploymentScope = Get-ScopeOfTemplateFile -TemplateFilePath $TemplateFilePath

foreach ($deploymentName in $DeploymentNames) {
$deploymentsInputObject = @{
Name = $deploymentName
Scope = $deploymentScope
}
if (-not [String]::IsNullOrEmpty($ResourceGroupName)) {
$deploymentsInputObject['resourceGroupName'] = $ResourceGroupName
# Fundamental checks
if ($deploymentScope -eq 'resourcegroup' -and -not (Get-AzResourceGroup -Name $ResourceGroupName -ErrorAction 'SilentlyContinue')) {
Write-Verbose "Resource group [$ResourceGroupName] does not exist (anymore). Skipping removal of its contained resources" -Verbose
return
}
if (-not [String]::IsNullOrEmpty($ManagementGroupId)) {
$deploymentsInputObject['ManagementGroupId'] = $ManagementGroupId

# Fetch deployments
# =================

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
}
$deployedTargetResources += Get-DeploymentTargetResourceList @deploymentsInputObject
}

if ($deployedTargetResources.Count -eq 0) {
throw 'No deployment target resources found.'
if ($deployedTargetResources.Count -eq 0) {
throw 'No deployment target resources found.'
}
}

[array] $deployedTargetResources = $deployedTargetResources | Select-Object -Unique
Expand Down

0 comments on commit 5d8c00a

Please sign in to comment.