azure-powershell icon indicating copy to clipboard operation
azure-powershell copied to clipboard

Get-AzureAccount Parameters vs. Properties consistency

Open SherifTalaat opened this issue 11 years ago • 2 comments

Get-AzureAccount cmdlet returns a property Id which has the name of the account "[email protected]". However, Get-AzureAccount has -Name parameter used to retrieve the account "[email protected]" which is totally confusing and inconsistent. The same parameter -Name with Remove-AzureAccount which trigger an error when to pipe Get-AzureAccount to Remove-AzureAccount dd What I suggest here is to either change the property name returned from Get-AzureAccount from Id to Name, or change the Parameter -Name to -Id

SherifTalaat avatar Feb 17 '15 15:02 SherifTalaat

I think what might be an appropriate solution would be:

  1. Add a new parameter set called something like PipelineInput that has a parameter called -InputObject to the Remove-AzureAccount command
  2. Strongly type the -InputObject parameter as a Microsoft.Azure.Common.Extensions.Models.PSAzureAccount
  3. Ensure that the -InputObject parameter has ValueFromPipeline set to True
  4. Inside the cmdlet / function body, under the PROCESS block, if the parameter set name is PipelineInput, then remove the account with the Id property on each object that was piped in.

This way, when a PSAzureAccount object is piped into the Remove-AzureAccount command, the account will be removed with the correct property. Users should not have to specify that the Id property of the PSAzureAccount object maps to the -Name parameter of the Remove-AzureAccount command.

Cheers, Trevor Sullivan Microsoft MVP: PowerShell http://trevorsullivan.net http://twitter.com/pcgeek86

pcgeek86 avatar Feb 18 '15 21:02 pcgeek86

@SherifTalaat We didn't see any scenarios for piping accounts between the cmdlets, which is why there is this mismatch. Meanwhile Get-AzureSubscription | Remove-AzureSubscription is the right way to do this - subscription is still the primary key into the profile.

Meanwhile we will consider allowing piping for a future release

markcowl avatar Mar 16 '15 20:03 markcowl