mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-02-16 10:58:30 -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);
|
result.errors.push(error);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
await Promise.all(account.properties.tenants.map(async (tenant: { id: string; }) => {
|
|
||||||
try {
|
try {
|
||||||
const path = `/subscriptions/${subscription.id}/locations?api-version=2020-01-01`;
|
const path = `/subscriptions/${subscription.id}/locations?api-version=2020-01-01`;
|
||||||
const response = await makeHttpRequest(account, subscription, path, HttpRequestMethod.GET, undefined, ignoreErrors);
|
const response = await makeHttpRequest(account, subscription, path, HttpRequestMethod.GET, undefined, ignoreErrors);
|
||||||
result.locations.push(...response.response.data.value);
|
result.locations.push(...response.response.data.value);
|
||||||
result.errors.push(...response.errors);
|
result.errors.push(...response.errors);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
const error = new Error(localize('azure.accounts.getLocations.queryError', "Error fetching locations for account {0} ({1}) subscription {2} ({3}) tenant {4} : {5}",
|
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.displayName,
|
||||||
account.displayInfo.userId,
|
account.displayInfo.userId,
|
||||||
subscription.id,
|
subscription.id,
|
||||||
subscription.name,
|
subscription.name,
|
||||||
tenant.id,
|
account.properties.tenants[0].id,
|
||||||
err instanceof Error ? err.message : err));
|
err instanceof Error ? err.message : err));
|
||||||
console.warn(error);
|
console.warn(error);
|
||||||
if (!ignoreErrors) {
|
if (!ignoreErrors) {
|
||||||
throw error;
|
throw error;
|
||||||
}
|
|
||||||
result.errors.push(error);
|
|
||||||
}
|
}
|
||||||
}));
|
result.errors.push(error);
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -38,11 +38,11 @@ export async function getLocations(account: azdata.Account, subscription: Subscr
|
|||||||
if (response.errors.length > 0) {
|
if (response.errors.length > 0) {
|
||||||
throw new Error(response.errors.toString());
|
throw new Error(response.errors.toString());
|
||||||
}
|
}
|
||||||
sortResourceArrayByName(response.locations);
|
|
||||||
|
|
||||||
const filteredLocations = response.locations.filter(loc => {
|
const filteredLocations = response.locations
|
||||||
return sqlMigrationResourceLocations.includes(loc.displayName);
|
.filter(loc => sqlMigrationResourceLocations.includes(loc.displayName));
|
||||||
});
|
|
||||||
|
sortResourceArrayByName(filteredLocations);
|
||||||
|
|
||||||
return filteredLocations;
|
return filteredLocations;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user