@@ -32,7 +32,7 @@ namespace Microsoft.WindowsAzure.Commands.Profile
32
32
/// the AzureProfile layer.
33
33
/// </summary>
34
34
[ Cmdlet ( VerbsCommon . Get , "AzureSubscription" , DefaultParameterSetName = "ByName" ) ]
35
- [ OutputType ( typeof ( AzureSubscription ) ) ]
35
+ [ OutputType ( typeof ( PSAzureSubscription ) ) ]
36
36
public class GetAzureSubscriptionCommand : SubscriptionCmdletBase
37
37
{
38
38
public GetAzureSubscriptionCommand ( )
@@ -141,29 +141,12 @@ private void WriteSubscriptions(IEnumerable<AzureSubscription> subscriptions)
141
141
}
142
142
else
143
143
{
144
- subscriptionOutput = subscriptions . Select ( ConstructPsAzureSubscription ) ;
144
+ subscriptionOutput = subscriptions . Select ( s => new PSAzureSubscription ( s , ProfileClient . Profile ) ) ;
145
145
}
146
146
147
147
WriteObject ( subscriptionOutput , true ) ;
148
148
}
149
149
150
- private PSAzureSubscription ConstructPsAzureSubscription ( AzureSubscription subscription )
151
- {
152
- PSAzureSubscription psObject = new PSAzureSubscription ( ) ;
153
-
154
- psObject . SubscriptionId = subscription . Id . ToString ( ) ;
155
- psObject . SubscriptionName = subscription . Name ;
156
- psObject . Environment = subscription . Environment ;
157
- psObject . SupportedModes = subscription . GetProperty ( AzureSubscription . Property . SupportedModes ) ;
158
- psObject . DefaultAccount = subscription . Account ;
159
- psObject . Accounts = ProfileClient . Profile . Accounts . Values . Where ( a => a . HasSubscription ( subscription . Id ) ) . ToArray ( ) ;
160
- psObject . IsDefault = subscription . IsPropertySet ( AzureSubscription . Property . Default ) ;
161
- psObject . IsCurrent = Profile . Context . Subscription != null && Profile . Context . Subscription . Id == subscription . Id ;
162
- psObject . CurrentStorageAccountName = subscription . GetProperty ( AzureSubscription . Property . StorageAccount ) ;
163
- psObject . TenantId = subscription . GetPropertyAsArray ( AzureSubscription . Property . Tenants ) . FirstOrDefault ( ) ;
164
- return psObject ;
165
- }
166
-
167
150
private PSAzureSubscriptionExtended ConstructPsAzureSubscriptionExtended ( AzureSubscription subscription , IClientFactory clientFactory )
168
151
{
169
152
using ( var client = clientFactory . CreateClient < ManagementClient > ( Profile , subscription , AzureEnvironment . Endpoint . ServiceManagement ) )
@@ -172,8 +155,8 @@ private PSAzureSubscriptionExtended ConstructPsAzureSubscriptionExtended(AzureSu
172
155
var environment = ProfileClient . GetEnvironmentOrDefault ( subscription . Environment ) ;
173
156
var account = ProfileClient . Profile . Accounts [ subscription . Account ] ;
174
157
bool isCert = account . Type == AzureAccount . AccountType . Certificate ;
175
-
176
- PSAzureSubscriptionExtended result = new PSAzureSubscriptionExtended ( ConstructPsAzureSubscription ( subscription ) )
158
+ var psAzureSubscription = new PSAzureSubscription ( subscription , ProfileClient . Profile ) ;
159
+ PSAzureSubscriptionExtended result = new PSAzureSubscriptionExtended ( psAzureSubscription )
177
160
{
178
161
AccountAdminLiveEmailId = response . AccountAdminLiveEmailId ,
179
162
ActiveDirectoryUserId = subscription . Account ,
0 commit comments