Skip to content

Commit eff8df2

Browse files
authored
Minor changes for interactive subscription selection (#24873)
* Minor changes for interactive subscription selection * remove extra line
1 parent d987ad5 commit eff8df2

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
lines changed

src/Accounts/Accounts/Account/ConnectAzureRmAccount.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -591,8 +591,8 @@ public override void ExecuteCmdlet()
591591
}
592592
});
593593

594-
WriteInformation($"[Announcements]{System.Environment.NewLine}Share your feedback regarding your experience with `Connect-AzAccount` at: https://aka.ms/azloginfeedback{System.Environment.NewLine}");
595-
WriteInformation($"If you encounter any problem, please open an issue at: https://aka.ms/azpsissue{System.Environment.NewLine}");
594+
WriteInformation($"{Resources.AnnouncementsHeader}{System.Environment.NewLine}{Resources.AnnouncementsMessage}{System.Environment.NewLine}");
595+
WriteInformation($"{Resources.ReportIssue}{System.Environment.NewLine}");
596596
}
597597
}
598598

src/Accounts/Accounts/Models/RMProfileClient.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -148,8 +148,8 @@ public AzureRmProfile Login(
148148
List<AzureSubscription> tempSubscriptions = null;
149149
string tenantName = null;
150150

151-
var lastUsedSubscription = isInteractiveAuthenticationFlow && string.IsNullOrEmpty(subscriptionId) && string.IsNullOrEmpty(subscriptionName) ? _profile?.DefaultContext?.Subscription : null;
152-
bool selectSubscriptionFromList = isInteractiveAuthenticationFlow && IsInteractiveContextSelectionEnabled;
151+
bool selectSubscriptionFromList = isInteractiveAuthenticationFlow && IsInteractiveContextSelectionEnabled && string.IsNullOrEmpty(subscriptionId) && string.IsNullOrEmpty(subscriptionName);
152+
var lastUsedSubscription = selectSubscriptionFromList ? _profile?.DefaultContext?.Subscription : null;
153153

154154
string promptBehavior =
155155
(password == null &&
@@ -402,7 +402,7 @@ public AzureRmProfile Login(
402402
if (shouldPopulateContextList && maxContextPopulation != 0)
403403
{
404404
var defaultContext = _profile.DefaultContext;
405-
var populatedSubscriptions = maxContextPopulation > 0 && !isInteractiveAuthenticationFlow ? ListSubscriptions(tenantIdOrName).Take(maxContextPopulation) : ListSubscriptions(tenantIdOrName);
405+
var populatedSubscriptions = (maxContextPopulation < 0 || selectSubscriptionFromList) ? ListSubscriptions(tenantIdOrName) : ListSubscriptions(tenantIdOrName).Take(maxContextPopulation);
406406

407407
foreach (var subscription in populatedSubscriptions)
408408
{

src/Accounts/Accounts/Properties/Resources.Designer.cs

Lines changed: 27 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Accounts/Accounts/Properties/Resources.resx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -622,4 +622,13 @@
622622
<data name="TypedSubscriptionNotNumber" xml:space="preserve">
623623
<value>Typed subscription is not a number.</value>
624624
</data>
625+
<data name="AnnouncementsHeader" xml:space="preserve">
626+
<value>[Announcements]</value>
627+
</data>
628+
<data name="AnnouncementsMessage" xml:space="preserve">
629+
<value>With the new Azure PowerShell login experience, you can select the subscription you want to use more easily. Learn more about it and its configuration at https://go.microsoft.com/fwlink/?linkid=2271236. Share your feedback regarding your experience with `Connect-AzAccount` at: https://aka.ms/azloginfeedback</value>
630+
</data>
631+
<data name="ReportIssue" xml:space="preserve">
632+
<value>If you encounter any problem, please open an issue at: https://aka.ms/azpsissue</value>
633+
</data>
625634
</root>

0 commit comments

Comments
 (0)