Azure / azure-powershell

Microsoft Azure PowerShell
Other
4.14k stars 3.77k forks source link

Remove-AzureRmDnsRecordSet doesn't accept pipeline input #2328

Closed pcgeek86 closed 6 years ago

pcgeek86 commented 8 years ago

Issue

Remove-AzureRmDnsZone doesn't accept pipeline input

Get-AzureRmDnsRecordSet -ResourceGroupName ArtofShell -ZoneName trevorsullivan.net | Remove-AzureRmDnsRecordSet -Force

Remove-AzureRmDnsRecordSet : The input object cannot be bound to any parameters for the command either because the command does not take pipeline input or the input and its properties do not match any of the parameters that take pipeline input. At line:1 char:86

Expected Result

Remove-AzureRmDnsZone should accept pipeline input.

Cheers, Trevor Sullivan Microsoft MVP: Cloud & Data Center Management https://trevorsullivan.net https://twitter.com/pcgeek86

markcowl commented 8 years ago

@jtuliani can you take a look

jtuliani commented 8 years ago

I updated the title of the issue to refer to DNS record sets instead of zones, since that's what you gave in your description. However I see the same behaviour for both record sets and zones.

It works when you want to delete a single record set or a single zone:

PS> Get-AzurermDnsZone -ResourceGroupName rg1 -Name myzonex.com | Remove-AzureRmDnsZone
PS> Get-AzureRmDnsRecordSet -ResourceGroupName rg1 -ZoneName myzonex.com -Name test-a -RecordType A | Remove-AzureRmDnsRecordSet

However, if the 'Get' command is scope more broadly, so it returns an array of results, this doesn't work:

PS> Get-AzurermDnsZone -ResourceGroupName rg1 | Remove-AzureRmDnsZone
PS> Get-AzureRmDnsRecordSet -ResourceGroupName rg1 -ZoneName myzonex.com | Remove-AzureRmDnsRecordSet

Trevor, please can you clarify what behaviour you're looking for here?

Is the goal to delete all record sets in a zone? If so, why? If it's as a precursor to deleting the zone, note that in our GA API we will change the service behaviour to permit zone delete without deleting record sets first, you can just delete the zone. Note also that deleting all records sets in the zone in this way will fail for the auto-created NS/SOA record sets at the zone apex.

Is it useful to be able to delete all zones in a RG or subscription this way? I would have thought that's a very rare scenario.

pcgeek86 commented 8 years ago

@jtuliani Yes, it is because I needed to delete the entire zone, and first had to delete the record sets. Rare scenario or not, customers should have the flexibility to run the commands that they need to. The basic expectation here, from a typical PowerShell user, is that they can pipe objects from a Get command, into an equivalent Remove command, and it should simply do what they asked it to. There's nothing really advanced going on here, just consistency with the core PowerShell experience. :smiley:

One of the overarching problems with Azure today, that I constantly run into talking to various people, is that engineering teams are hyper-focused on very specific scenarios, instead of enabling users to leverage the platform as flexibly as possible. I'd suggest trying to see past these very specific scenarios, and understand that customers are trying to use the platform in ways that you may not even be thinking of. Instead of forcing these customers into specific adoption scenarios, the more you can focus on enabling them to achieve what they want to do, the happier they will be. :smiley:

jtuliani commented 8 years ago

Thanks Trevor for the feedback. The reason we ask about end-to-end scenarios is that otherwise it's too easy to make the mistake of delivering a basket of features that doesn't enable customers to actually complete any scenarios! We like to understand the context behind the features and how they are used.

That said, I agree completely that interoperation between features is important, as is consistency across the Azure experience. Piping from Get- to Delete- is working fine for individual zones and record sets, the only issue here is for collections.

@markcowl - is it expected that when Get- returns a collection rather than an individual result, we can pipe that collection into Delete- ? Can you give an example of another Azure service supporting this?

pcgeek86 commented 8 years ago

Here you go, @jtuliani

1..10 | % { New-AzureRmResourceGroup -Name "Tuliani${PSItem}" -Location centralus -Tag @{ Name = 'Tuliani'; } -Force; }

Find-AzureRmResourceGroup -Tag @{ Name = 'Tuliani'; } | Remove-AzureRmResourceGroup -Force

NOTE: This has very little to do with building off of Azure PowerShell design principles, but rather following PowerShell core design principles. 😄 Pipelining collections of objects is one of the most core use cases in core PowerShell (outside of any third-party modules).

jtuliani commented 8 years ago

OK, you convinced me. I'll file a bug internally to track, but I want to set a realistic expectation that it might take some time to get to this. In the meantime, Azure PowerShell is open source and open to community contributions...:)

cormacpayne commented 7 years ago

@pcgeek86 Hey Trevor, is this still an issue? It appears that Remove-AzureRmDnsRecordSet has the ValueFromPipeline property for the RecordSet parameter, so you should be able to pipe the result of Get-AzureRmDnsRecordSet thru to this cmdlet.

https://github.com/Azure/azure-powershell/blob/dev/src/ResourceManager/Dns/Commands.Dns/Records/RemoveAzureDnsRecordSet.cs#L52

cormacpayne commented 6 years ago

Closing this issue due to lack of activity. @pcgeek86 please feel free to re-open this issue if you are still seeing the above issue.