Skip to content

Add Remove-AdfObjects to delete chosen objects from ADF #30 - #516

Merged
NowinskiK merged 2 commits into
developfrom
issue-30-remove-adfobjects
Oct 17, 2026
Merged

NowinskiK merged 2 commits into
developfrom
issue-30-remove-adfobjects

Conversation

@NowinskiK

Copy link
Copy Markdown
Member

Closes #30

What

New public cmdlet Remove-AdfObjects, which deletes chosen objects from an ADF instance whether or not they are in the source code.

Remove-AdfObjects -ResourceGroupName 'rg' -DataFactoryName 'adf' -Pattern 'pipeline.PL_Old*', 'dataset.*'
Remove-AdfObjects -ResourceGroupName 'rg' -DataFactoryName 'adf' -Pattern 'pipeline.*@Archive*' -WhatIf   # folder Archive + subfolders
Remove-AdfObjects -ResourceGroupName 'rg' -DataFactoryName 'adf' -Option (New-AdfPublishOption -FilePath rules.csv)   # reverse deployment
  • -Pattern uses the same type.name[@folder] format as Includes/Excludes. This replaces the separate -Folder/-Recurse parameters proposed in the issue comment, so the module keeps a single pattern format.
  • -Option deletes the objects that a deployment with this option would deploy (Includes minus Excludes).
  • -WhatIf/-Confirm: all objects are confirmed before any deletion, so a cascade never removes an object that was declined.
  • Order: triggers (started ones are stopped first), pipelines, data flows, datasets, linked services, credentials, integration runtimes.
  • If a selected object is referenced by another object, that object is deleted first only when it is also selected; otherwise the cmdlet stops with ADFT0034.
  • The first failed deletion stops the cmdlet.

Refactoring of Remove-AdfObject (also used by DeleteNotInSource)

  • Takes the resource group and factory from $adfInstance instead of the caller's variables.
  • The source model is optional; $adfTargetObj (not a parameter) is replaced by $obj.
  • Throws ADFT0018 for an unsupported type, instead of a non-terminating Write-Error inside try.
  • Retries temporary API errors with Invoke-AdfWithRetry.
  • New optional Selection/Deleted parameters limit the cascade and skip objects that were already deleted.

Folders are read through the REST API (Get-AdfObjectFolder), because Az's PSPipeline has no folder property.

Tests

  • New test/Remove-AdfObjects.Tests.ps1: 18 unit tests. Az mocks Write-Error; the tests pass under both Stop and Continue. The Remove-AdfObject tests failed before the refactoring.
  • generic, Publish-AdfV2FromJson-ErrorHandling, Publish-AdfV2FromJson-DryRun, Invoke-AdfWithRetry and ApplyExclusionOptions pass locally. The delete tests that need Azure run on CI.

🤖 Generated with Claude Code

Kamil Nowinski and others added 2 commits October 17, 2026 00:49
- New public cmdlet Remove-AdfObjects: select objects by type.name[@folder]
  patterns or by publish option (reverse deployment); supports -WhatIf
- Remove-AdfObject takes the factory from adfInstance, works without a source
  model, throws for unsupported types, retries temporary errors and can limit
  the cascade to selected objects
- Get-AdfObjectFolder reads folders via REST API

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… test #30

Remove-AdfObject now takes the factory from the instance, like the real
Get-AdfFromService returns it; the mock left Name empty.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NowinskiK
NowinskiK merged commit 3e08034 into develop Oct 17, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant