Skip to content

Get-AzureSubscription vs. Select-AzureSubscription -PassThru #335

Closed
@pcgeek86

Description

@pcgeek86
  • The Get-AzureSubscription command returns objects of type: Microsoft.WindowsAzure.Commands.Profile.Models.PSAzureSubscription.
  • The Select-AzureSubscription -PassThru command returns objects of type: Microsoft.Azure.Common.Authentication.Models.AzureSubscription.
  • The AzureSubscription object model lacks some of the properties that the PSAzureSubscription object has.
  • The property names for AzureSubscription and PSAzureSubscription objects are inconsistent with each other.
    • One has a Name property, while the other has a SubscriptionName property.
    • One has an Account property, while the other has an Accounts property.
  • Both the AzureSubscription and PSAzureSubscription objects represent the same entity (an Azure subscription).

Question: Why are there two different object models that represent the same entity?

Action Item: Please change the Select-AzureSubscription command such that it emits the same object type as the Get-AzureSubscription command.

PS C:\Users\Trevor> Get-AzureSubscription | Get-Member;


   TypeName: Microsoft.WindowsAzure.Commands.Profile.Models.PSAzureSubscription

Name                      MemberType Definition
----                      ---------- ----------
Equals                    Method     bool Equals(System.Object obj)
GetHashCode               Method     int GetHashCode()
GetType                   Method     type GetType()
ToString                  Method     string ToString()
Accounts                  Property   Microsoft.Azure.Common.Authentication.Models.AzureAccount[] Accounts {get;set;}
CurrentStorageAccountName Property   string CurrentStorageAccountName {get;set;}
DefaultAccount            Property   string DefaultAccount {get;set;}
Environment               Property   string Environment {get;set;}
IsCurrent                 Property   bool IsCurrent {get;set;}
IsDefault                 Property   bool IsDefault {get;set;}
SubscriptionId            Property   string SubscriptionId {get;set;}
SubscriptionName          Property   string SubscriptionName {get;set;}
SupportedModes            Property   string SupportedModes {get;set;}
TenantId                  Property   string TenantId {get;set;}


PS C:\Users\Trevor> Get-AzureSubscription | Select-AzureSubscription -PassThru | Get-Member;


   TypeName: Microsoft.Azure.Common.Authentication.Models.AzureSubscription

Name                MemberType Definition
----                ---------- ----------
Equals              Method     bool Equals(System.Object obj)
GetHashCode         Method     int GetHashCode()
GetProperty         Method     string GetProperty(Microsoft.Azure.Common.Authentication.Models.AzureSubscription+Pro...
GetPropertyAsArray  Method     string[] GetPropertyAsArray(Microsoft.Azure.Common.Authentication.Models.AzureSubscri...
GetType             Method     type GetType()
IsPropertySet       Method     bool IsPropertySet(Microsoft.Azure.Common.Authentication.Models.AzureSubscription+Pro...
SetOrAppendProperty Method     void SetOrAppendProperty(Microsoft.Azure.Common.Authentication.Models.AzureSubscripti...
SetProperty         Method     void SetProperty(Microsoft.Azure.Common.Authentication.Models.AzureSubscription+Prope...
ToString            Method     string ToString()
Account             Property   string Account {get;set;}
Environment         Property   string Environment {get;set;}
Id                  Property   guid Id {get;set;}
Name                Property   string Name {get;set;}
Properties          Property   System.Collections.Generic.Dictionary[Microsoft.Azure.Common.Authentication.Models.Az...

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions