Skip to content

Commit b3d641d

Browse files
author
Hovsep Mkrtchyan
committed
Fixed minor issue.
1 parent e973642 commit b3d641d

File tree

4 files changed

+19
-3
lines changed

4 files changed

+19
-3
lines changed

src/ResourceManager/Profile/Commands.Profile/Context/SetAzureRMContext.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ protected override void ProcessRecord()
105105
{
106106
// authenticate with just tenant id
107107
AzureTenant tenant;
108-
profileClient.TryGetSubscription(tenantId, null, out subscription, out tenant);
108+
if(!profileClient.TryGetTenantAndSubscription(tenantId, null, out subscription, out tenant))
109+
{
110+
throw new ItemNotFoundException(
111+
string.Format(Resources.TenantIdNotFound, tenantId));
112+
}
109113
if (subscription == null)
110114
{
111115
profileClient.SetCurrentContext(tenant.Id.ToString());

src/ResourceManager/Profile/Commands.Profile/Models/RMProfileClient.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,10 +198,10 @@ public List<AzureTenant> ListTenants(string tenant)
198198
public bool TryGetSubscription(string tenantId, string subscriptionId, out AzureSubscription subscription)
199199
{
200200
AzureTenant tenant;
201-
return TryGetSubscription(tenantId, subscriptionId, out subscription, out tenant);
201+
return TryGetTenantAndSubscription(tenantId, subscriptionId, out subscription, out tenant);
202202
}
203203

204-
public bool TryGetSubscription(string tenantId, string subscriptionId, out AzureSubscription subscription, out AzureTenant tenant)
204+
public bool TryGetTenantAndSubscription(string tenantId, string subscriptionId, out AzureSubscription subscription, out AzureTenant tenant)
205205
{
206206
if (string.IsNullOrWhiteSpace(tenantId))
207207
{

src/ResourceManager/Profile/Commands.Profile/Properties/Resources.Designer.cs

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

src/ResourceManager/Profile/Commands.Profile/Properties/Resources.resx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@
156156
<data name="TenantAuthFailed" xml:space="preserve">
157157
<value>Could not authenticate with tenant {0}. Please ensure that your account has access to this tenant and log in with Login-AzureRmAccount</value>
158158
</data>
159+
<data name="TenantIdNotFound" xml:space="preserve">
160+
<value>Unable to find tenant '{0}'.</value>
161+
</data>
159162
<data name="TypeNotAccessToken" xml:space="preserve">
160163
<value>To create an access token credential, you must provide an access token account.</value>
161164
</data>

0 commit comments

Comments
 (0)