File tree Expand file tree Collapse file tree 1 file changed +10
-5
lines changed
src/ResourceManager/Profile/Commands.Profile/Models Expand file tree Collapse file tree 1 file changed +10
-5
lines changed Original file line number Diff line number Diff line change @@ -483,19 +483,24 @@ private bool TryGetTenantSubscription(IAccessToken accessToken,
483
483
}
484
484
else
485
485
{
486
- var subscriptions = subscriptionClient . Subscriptions . List ( ) . Subscriptions ;
487
- if ( subscriptions != null && subscriptions . Any ( ) )
486
+ var subscriptions = ( subscriptionClient . Subscriptions . List ( ) . Subscriptions ??
487
+ new List < Microsoft . Azure . Subscriptions . Models . Subscription > ( ) )
488
+ . Where ( s => s . State . Equals ( "enabled" , StringComparison . OrdinalIgnoreCase ) ||
489
+ s . State . Equals ( "warned" , StringComparison . OrdinalIgnoreCase ) ) ;
490
+
491
+ if ( subscriptions . Any ( ) )
488
492
{
489
493
if ( subscriptionName != null )
490
494
{
491
- subscriptionFromServer = subscriptions . FirstOrDefault ( s => s . DisplayName . Equals ( subscriptionName , StringComparison . OrdinalIgnoreCase ) ) ;
495
+ subscriptionFromServer = subscriptions . FirstOrDefault (
496
+ s => s . DisplayName . Equals ( subscriptionName , StringComparison . OrdinalIgnoreCase ) ) ;
492
497
}
493
498
else
494
499
{
495
- if ( subscriptions . Count > 1 )
500
+ if ( subscriptions . Count ( ) > 1 )
496
501
{
497
502
WriteWarningMessage ( string . Format (
498
- "TenantId '{0}' contains more than one subscription. First one will be selected for further use. " +
503
+ "TenantId '{0}' contains more than one active subscription. First one will be selected for further use. " +
499
504
"To select another subscription, use Set-AzureRmContext." ,
500
505
tenantId ) ) ;
501
506
}
You can’t perform that action at this time.
0 commit comments