Skip to content

Commit

Permalink
Account value was never set in the this context (microsoft#10965)
Browse files Browse the repository at this point in the history
  • Loading branch information
Amir Omidi authored Jun 17, 2020
1 parent 11e4627 commit 8b68d52
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions extensions/azurecore/src/azureResource/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ export function registerAzureResourceCommands(appContext: AppContext, tree: Azur
return;
}

const account = node.account;
if (!account) {
return;
}

const subscriptionService = appContext.getService<IAzureResourceSubscriptionService>(AzureResourceServiceNames.subscriptionService);
const subscriptionFilterService = appContext.getService<IAzureResourceSubscriptionFilterService>(AzureResourceServiceNames.subscriptionFilterService);

Expand All @@ -87,17 +92,17 @@ export function registerAzureResourceCommands(appContext: AppContext, tree: Azur
const subscriptions = (await accountNode.getCachedSubscriptions()) || <azureResource.AzureResourceSubscription[]>[];
if (subscriptions.length === 0) {
try {
const tokens = await this.servicePool.apiWrapper.getSecurityToken(this.account, azdata.AzureResource.ResourceManagement);
const tokens = await this.servicePool.apiWrapper.getSecurityToken(account, azdata.AzureResource.ResourceManagement);

for (const tenant of this.account.properties.tenants) {
for (const tenant of account.properties.tenants) {
const token = tokens[tenant.id].token;
const tokenType = tokens[tenant.id].tokenType;

subscriptions.push(...await subscriptionService.getSubscriptions(accountNode.account, new TokenCredentials(token, tokenType)));
subscriptions.push(...await subscriptionService.getSubscriptions(account, new TokenCredentials(token, tokenType)));
}
} catch (error) {
this.account.isStale = true;
throw new AzureResourceCredentialError(localize('azure.resource.selectsubscriptions.credentialError', "Failed to get credential for account {0}. Please refresh the account.", this.account.key.accountId), error);
account.isStale = true;
throw new AzureResourceCredentialError(localize('azure.resource.selectsubscriptions.credentialError', "Failed to get credential for account {0}. Please refresh the account.", account.key.accountId), error);
}
}

Expand Down

0 comments on commit 8b68d52

Please sign in to comment.