mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-14 01:25:37 -05:00
apply unique filter to getLocations api's (#17454)
* apply unique filter to getLocations api's * filter resource locations to distinct list * simplify location filter
This commit is contained in:
@@ -153,27 +153,27 @@ export async function getLocations(appContext: AppContext, account?: AzureAccoun
|
||||
result.errors.push(error);
|
||||
return result;
|
||||
}
|
||||
await Promise.all(account.properties.tenants.map(async (tenant: { id: string; }) => {
|
||||
try {
|
||||
const path = `/subscriptions/${subscription.id}/locations?api-version=2020-01-01`;
|
||||
const response = await makeHttpRequest(account, subscription, path, HttpRequestMethod.GET, undefined, ignoreErrors);
|
||||
result.locations.push(...response.response.data.value);
|
||||
result.errors.push(...response.errors);
|
||||
} catch (err) {
|
||||
const error = new Error(localize('azure.accounts.getLocations.queryError', "Error fetching locations for account {0} ({1}) subscription {2} ({3}) tenant {4} : {5}",
|
||||
account.displayInfo.displayName,
|
||||
account.displayInfo.userId,
|
||||
subscription.id,
|
||||
subscription.name,
|
||||
tenant.id,
|
||||
err instanceof Error ? err.message : err));
|
||||
console.warn(error);
|
||||
if (!ignoreErrors) {
|
||||
throw error;
|
||||
}
|
||||
result.errors.push(error);
|
||||
|
||||
try {
|
||||
const path = `/subscriptions/${subscription.id}/locations?api-version=2020-01-01`;
|
||||
const response = await makeHttpRequest(account, subscription, path, HttpRequestMethod.GET, undefined, ignoreErrors);
|
||||
result.locations.push(...response.response.data.value);
|
||||
result.errors.push(...response.errors);
|
||||
} catch (err) {
|
||||
const error = new Error(localize('azure.accounts.getLocations.queryError', "Error fetching locations for account {0} ({1}) subscription {2} ({3}) tenant {4} : {5}",
|
||||
account.displayInfo.displayName,
|
||||
account.displayInfo.userId,
|
||||
subscription.id,
|
||||
subscription.name,
|
||||
account.properties.tenants[0].id,
|
||||
err instanceof Error ? err.message : err));
|
||||
console.warn(error);
|
||||
if (!ignoreErrors) {
|
||||
throw error;
|
||||
}
|
||||
}));
|
||||
result.errors.push(error);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,11 +38,11 @@ export async function getLocations(account: azdata.Account, subscription: Subscr
|
||||
if (response.errors.length > 0) {
|
||||
throw new Error(response.errors.toString());
|
||||
}
|
||||
sortResourceArrayByName(response.locations);
|
||||
|
||||
const filteredLocations = response.locations.filter(loc => {
|
||||
return sqlMigrationResourceLocations.includes(loc.displayName);
|
||||
});
|
||||
const filteredLocations = response.locations
|
||||
.filter(loc => sqlMigrationResourceLocations.includes(loc.displayName));
|
||||
|
||||
sortResourceArrayByName(filteredLocations);
|
||||
|
||||
return filteredLocations;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user