Skip to content

Commit 2dd1402

Browse files
authored
Merge pull request #5296 from microsoft/qianjin-s187-bugfix-02
bugfix: long loading time during opening resource in portal.
2 parents ff38cef + 98ae006 commit 2dd1402

File tree

4 files changed

+8
-18
lines changed

4 files changed

+8
-18
lines changed

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/helpers/azure/sdk/AzureSDKManager.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import com.microsoft.azure.management.storage.SkuName;
2929
import com.microsoft.azure.management.storage.StorageAccount;
3030
import com.microsoft.azure.management.storage.StorageAccountSkuType;
31+
import com.microsoft.azure.toolkit.lib.auth.AzureAccount;
3132
import com.microsoft.azure.toolkit.lib.common.model.Subscription;
3233
import com.microsoft.azuretools.authmanage.AuthMethodManager;
3334
import com.microsoft.azuretools.authmanage.models.SubscriptionDetail;
@@ -264,7 +265,8 @@ public static List<String> getLocationsForInsights(String subscriptionId) throws
264265
if (azureManager == null) {
265266
return Collections.emptyList();
266267
}
267-
final String accessToken = azureManager.getAccessToken(azureManager.getTenantIdBySubscription(subscriptionId));
268+
Subscription subscription = com.microsoft.azure.toolkit.lib.Azure.az(AzureAccount.class).account().getSubscription(subscriptionId);
269+
final String accessToken = azureManager.getAccessToken(subscription.getTenantId());
268270
request.setHeader("Authorization", String.format("Bearer %s", accessToken));
269271
final CloseableHttpResponse response = HttpClients.createDefault().execute(request);
270272
final InputStream responseStream = response.getEntity().getContent();

Utils/azure-explorer-common/src/com/microsoft/tooling/msservices/serviceexplorer/Node.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77

88
import com.google.common.collect.ImmutableList;
99
import com.google.common.collect.Iterators;
10+
import com.microsoft.azure.toolkit.lib.Azure;
11+
import com.microsoft.azure.toolkit.lib.auth.AzureAccount;
12+
import com.microsoft.azure.toolkit.lib.common.model.Subscription;
1013
import com.microsoft.azure.toolkit.lib.common.operation.AzureOperation;
1114
import com.microsoft.azuretools.authmanage.AuthMethodManager;
1215
import com.microsoft.azuretools.azurecommons.helpers.NotNull;
@@ -429,10 +432,10 @@ public void openResourcesInPortal(String subscriptionId, String resourceId) {
429432
return;
430433
}
431434
final String portalUrl = azureManager.getPortalUrl();
432-
final String tenantId = azureManager.getTenantIdBySubscription(subscriptionId);
435+
Subscription subscription = Azure.az(AzureAccount.class).account().getSubscription(subscriptionId);
433436
final String url = portalUrl
434437
+ REST_SEGMENT_JOB_MANAGEMENT_TENANTID
435-
+ tenantId
438+
+ subscription.getTenantId()
436439
+ REST_SEGMENT_JOB_MANAGEMENT_RESOURCE
437440
+ resourceId;
438441
DefaultLoader.getIdeHelper().openLinkInBrowser(url);

Utils/azuretools-core/src/com/microsoft/azuretools/sdkmanage/AzureManager.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,8 +52,6 @@ default List<String> getSelectedSubscriptionIds() {
5252

5353
String getStorageEndpointSuffix();
5454

55-
String getTenantIdBySubscription(String subscriptionId);
56-
5755
String getScmSuffix();
5856

5957
Environment getEnvironment();

Utils/azuretools-core/src/com/microsoft/azuretools/sdkmanage/AzureManagerBase.java

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@
2323
import com.microsoft.azuretools.authmanage.SubscriptionManager;
2424
import com.microsoft.azuretools.authmanage.interact.INotification;
2525
import com.microsoft.azuretools.azurecommons.helpers.Nullable;
26-
import com.microsoft.azuretools.enums.ErrorEnum;
27-
import com.microsoft.azuretools.exception.AzureRuntimeException;
2826
import com.microsoft.azuretools.telemetry.TelemetryInterceptor;
2927
import com.microsoft.azuretools.utils.AzureRegisterProviderNamespaces;
3028
import com.microsoft.azuretools.utils.Pair;
31-
3229
import okhttp3.internal.http2.Settings;
3330
import org.apache.commons.lang3.StringUtils;
3431

@@ -100,16 +97,6 @@ public String getScmSuffix() {
10097
}
10198
}
10299

103-
@Override
104-
@AzureOperation(name = "account|subscription.get_tenant", params = {"subscriptionId"}, type = AzureOperation.Type.TASK)
105-
public String getTenantIdBySubscription(String subscriptionId) {
106-
final Pair<Subscription, Tenant> subscriptionTenantPair = getSubscriptionsWithTenant().stream()
107-
.filter(pair -> pair != null && pair.first() != null && pair.second() != null)
108-
.filter(pair -> StringUtils.equals(pair.first().getId(), subscriptionId))
109-
.findFirst().orElseThrow(() -> new AzureRuntimeException(ErrorEnum.INVALID_SUBSCRIPTION_CACHE));
110-
return subscriptionTenantPair.second().tenantId();
111-
}
112-
113100
protected <T extends AzureConfigurable<T>> T buildAzureManager(AzureConfigurable<T> configurable) {
114101
return configurable.withInterceptor(new TelemetryInterceptor())
115102
.withUserAgent(CommonSettings.USER_AGENT);

0 commit comments

Comments
 (0)