We can't authenticate to every subscription (#9826)

* We can't authenticate to every subscription

* Refresh tenants and subs when the application starts
This commit is contained in:
Amir Omidi
2020-04-02 09:02:04 -07:00
committed by GitHub
parent 41d21d799c
commit 223aa3fe0e
2 changed files with 37 additions and 12 deletions

View File

@@ -79,6 +79,16 @@ export class AzureResourceAccountTreeNode extends AzureResourceContainerTreeNode
if (subscriptions.length === 0) {
return [AzureResourceMessageTreeNode.create(AzureResourceAccountTreeNode.noSubscriptionsLabel, this)];
} else {
// Filter out everything that we can't authenticate to.
subscriptions = subscriptions.filter(s => {
const token = tokens[s.id];
if (!token) {
console.info(`Account does not have permissions to view subscription ${JSON.stringify(s)}.`);
return false;
}
return true;
});
let subTreeNodes = await Promise.all(subscriptions.map(async (subscription) => {
const token = tokens[subscription.id];
const tenantId = await this._tenantService.getTenantId(subscription, this.account, new TokenCredentials(token.token, token.tokenType));