Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Improved resiliency of removal logic (#3006)
## Description - Updated removal order as image templates must be removed before e.g., permissions are revoked - Updated 'alreadyProcessed' logic to not accidently exclude resources that contain a name as a substring, aber are an actual sub-resource - Updated logic to fetch deployment operations as the previous logic did also include 'existing' resources in specific situations. It's now using REST and filters those out (i.e., 'read' Operations) - Enabled the removal logic to deal with cases where no resources are deployed (e.g., later utl modules) - The logic now differentiates in between 'I can not find a deployment' and 'I can find a deployment, but it has no resources linked' (before it was only the former) - Finally, the logic was slightly altered to not give up as soon as no deployment is found, but instead try and find as many as possible and only throw an exception after the removal logic ran end to end. ## Pipeline Reference <!-- Insert your Pipeline Status Badge below --> | Pipeline | | -------- | [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.ptn.aca-lza.hosting-environment.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.ptn.ai-platform.baseline.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.ptn.authorization.policy-assignment.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.ptn.authorization.resource-role-assignment.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.ptn.authorization.role-assignment.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.ptn.deployment-script.import-image-to-acr.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.ptn.finops-toolkit.finops-hub.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.ptn.lz.sub-vending.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.ptn.network.private-link-private-dns-zones.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.ptn.policy-insights.remediation.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.ptn.security.security-center.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.aad.domain-service.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.alerts-management.action-rule.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.analysis-services.server.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.api-management.service.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.app-configuration.configuration-store.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.app.container-app.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.app.job.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.app.managed-environment.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.automation.automation-account.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.batch.batch-account.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.cache.redis.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.cdn.profile.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.cognitive-services.account.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.communication.communication-service.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.communication.email-service.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.compute.availability-set.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.compute.disk-encryption-set.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.compute.disk.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.compute.gallery.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.compute.image.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.compute.proximity-placement-group.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.compute.ssh-public-key.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.compute.virtual-machine-scale-set.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.compute.virtual-machine.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.consumption.budget.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.container-instance.container-group.yml) (unrelated) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.container-registry.registry.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.container-service.managed-cluster.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.data-factory.factory.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.data-protection.backup-vault.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.databricks.access-connector.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.databricks.workspace.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.db-for-my-sql.flexible-server.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.db-for-postgre-sql.flexible-server.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.desktop-virtualization.application-group.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.desktop-virtualization.host-pool.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.desktop-virtualization.scaling-plan.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.desktop-virtualization.workspace.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.dev-test-lab.lab.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.digital-twins.digital-twins-instance.yml) (unrelated) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.document-db.database-account.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.event-grid.domain.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.event-grid.namespace.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.event-grid.system-topic.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.event-grid.topic.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.event-hub.namespace.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.health-bot.health-bot.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.healthcare-apis.workspace.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.hybrid-compute.machine.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.insights.action-group.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.insights.activity-log-alert.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.insights.component.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.insights.data-collection-endpoint.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.insights.data-collection-rule.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.insights.diagnostic-setting.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.insights.metric-alert.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.insights.private-link-scope.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.insights.scheduled-query-rule.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.insights.webtest.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.key-vault.vault.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.kubernetes-configuration.extension.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.kubernetes-configuration.flux-configuration.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.kusto.cluster.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.load-test-service.load-test.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.logic.workflow.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.machine-learning-services.workspace.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.maintenance.maintenance-configuration.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.managed-identity.user-assigned-identity.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.managed-services.registration-definition.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.management.management-group.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.net-app.net-app-account.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.application-gateway-web-application-firewall-policy.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.application-gateway.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.application-security-group.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.azure-firewall.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.bastion-host.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.connection.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.ddos-protection-plan.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.dns-forwarding-ruleset.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.dns-resolver.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.dns-zone.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.express-route-circuit.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.express-route-gateway.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.firewall-policy.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.front-door-web-application-firewall-policy.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.front-door.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.ip-group.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.load-balancer.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.local-network-gateway.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.nat-gateway.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.network-interface.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.network-manager.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.network-security-group.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.network-watcher.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.private-dns-zone.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.private-endpoint.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.private-link-service.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.public-ip-address.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.public-ip-prefix.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.route-table.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.service-endpoint-policy.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.trafficmanagerprofile.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.virtual-hub.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.virtual-network-gateway.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.virtual-network.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.virtual-wan.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.vpn-gateway.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.network.vpn-site.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.operational-insights.workspace.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.operations-management.solution.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.portal.dashboard.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.power-bi-dedicated.capacity.yml) (unrelated) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.purview.account.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.recovery-services.vault.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.relay.namespace.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.resource-graph.query.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.resources.deployment-script.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.resources.resource-group.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.search.search-service.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.service-bus.namespace.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.service-fabric.cluster.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.signal-r-service.signal-r.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.signal-r-service.web-pub-sub.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.sql.instance-pool.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.sql.managed-instance.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.sql.server.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.storage.storage-account.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.synapse.private-link-hub.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.synapse.workspace.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.virtual-machine-images.image-template.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.web.connection.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.web.hosting-environment.yml) (unrelated) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.web.serverfarm.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.web.site.yml) [](https://github.com/Azure/bicep-registry-modules/actions/workflows/avm.res.web.static-site.yml) ## Type of Change <!-- Use the checkboxes [x] on the options that are relevant. --> - [x] Update to CI Environment or utilities (Non-module affecting 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
- Loading branch information