Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PowerShell][Hubs] Remove-FinOpsHub fails when there's only one resource #554

Closed
flanakin opened this issue Jan 23, 2024 · 0 comments · Fixed by #983
Closed

[PowerShell][Hubs] Remove-FinOpsHub fails when there's only one resource #554

flanakin opened this issue Jan 23, 2024 · 0 comments · Fixed by #983
Assignees
Labels
Good first issue 🏆 Good for newcomers Tool: FinOps hubs Data pipeline solution Tool: PowerShell PowerShell scripts and automation Type: Bug 🐛 Something isn't working

Comments

@flanakin
Copy link
Collaborator

flanakin commented Jan 23, 2024

🐛 Problem

Remove-FinOpsHub fails when there's only one resource:
Screenshot of a PowerShell error

Method invocation failed because [System.Boolean] does not contain a method named 'Reduce'

👣 Repro steps

  1. Create a hub
  2. Manually delete all resources except for the Data Factory
  3. Run Remove-FinOpsHub command

🤔 Expected

Should return true when successful.

ℹ️ Additional context

Error is on line 101 of Remove-FinOpsHub.ps1:

return ($resources | Remove-AzResource -Force:$Force).Reduce({ $args[0] -and $args[1] }, $true)

The fix is to force the $resources | Remove-AzResource into an array. We should also be able to simplify and remove the Reduce() method.

return -not (@($resources | Remove-AzResource -Force:$Force) -contains $false)

🙋‍♀️ Ask for the community

We could use your help:

  1. Please vote this issue up (👍) to prioritize it.
  2. Leave comments to help us solidify the vision.
@flanakin flanakin added Type: Bug 🐛 Something isn't working Needs: Triage 🔍 Untriaged issue needs to be reviewed labels Jan 23, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the Tool: PowerShell PowerShell scripts and automation label Jan 23, 2024
@flanakin flanakin added this to the 0.2.1 milestone Jan 23, 2024
@flanakin flanakin added Tool: FinOps hubs Data pipeline solution Good first issue 🏆 Good for newcomers and removed Needs: Triage 🔍 Untriaged issue needs to be reviewed labels Jan 23, 2024
@flanakin flanakin modified the milestones: 0.2.1, 0.3, 0.4 Jan 23, 2024
@flanakin flanakin removed their assignment Jan 28, 2024
@flanakin flanakin modified the milestones: May 2024, June 2024 May 31, 2024
@jamelachahbar jamelachahbar self-assigned this Sep 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good first issue 🏆 Good for newcomers Tool: FinOps hubs Data pipeline solution Tool: PowerShell PowerShell scripts and automation Type: Bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants