in src/login/environments.ts [112:149]
async function getCustomCloudEnvironment(config: WorkspaceConfiguration, includePartial: boolean): Promise<Environment | undefined> {
const armUrl: string | undefined = config.get(customCloudArmUrlSetting);
if (armUrl) {
try {
const endpointsUrl: string = getMetadataEndpoints(armUrl);
const endpointsResponse: Response = await fetch(endpointsUrl);
if (endpointsResponse.ok) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const endpoints: IResourceManagerMetadata = await endpointsResponse.json();
return <Environment>{
name: azureCustomCloud,
resourceManagerEndpointUrl: armUrl,
activeDirectoryEndpointUrl: endpoints.authentication.loginEndpoint.endsWith('/') ? endpoints.authentication.loginEndpoint : endpoints.authentication.loginEndpoint.concat('/'),
activeDirectoryGraphResourceId: endpoints.graphEndpoint,
activeDirectoryResourceId: endpoints.authentication.audiences[0],
portalUrl: endpoints.portalEndpoint,
galleryEndpointUrl: endpoints.galleryEndpoint,
storageEndpointSuffix: armUrl.substring(armUrl.indexOf('.')),
keyVaultDnsSuffix: '.vault'.concat(armUrl.substring(armUrl.indexOf('.'))),
managementEndpointUrl: endpoints.authentication.audiences[0],
validateAuthority: getValidateAuthority(endpoints.authentication.loginEndpoint)
};
}
} catch {
const openSettings: string = localize('openSettings', 'Open Settings');
void window.showErrorMessage(
localize("azure-account.armUrlFetchFailed", "Fetching custom cloud environment data failed. Please check your custom cloud settings."),
openSettings
).then(result => {
if(result === openSettings){
void commands.executeCommand('workbench.action.openSettings', '@ext:ms-vscode.azure-account customCloud');
}
})
}
}
return includePartial ? <Environment>{ name: azureCustomCloud } : undefined;
}