async tryRefresh()

in packages/azure-kusto-ingest/src/resourceManager.ts [201:222]


    async tryRefresh(isAuthContextFetch: boolean): Promise<Error | null> {
        const resource = isAuthContextFetch ? this.authorizationContext?.trim() : this.ingestClientResources;
        const lastRefresh = isAuthContextFetch ? this.authorizationContextLastUpdate : this.ingestClientResourcesLastUpdate;
        const now = Date.now();
        let error: Error | null = null;
        if (!resource || !lastRefresh || lastRefresh + this.refreshPeriod <= now) {
            try {
                if (isAuthContextFetch) {
                    this.authorizationContext = await this.getAuthorizationContextFromService();
                    this.authorizationContextLastUpdate = now;
                } else {
                    this.ingestClientResources = await this.getIngestClientResourcesFromService();
                    this.ingestClientResourcesLastUpdate = now;
                    this.pupulateStorageAccounts();
                }
            } catch (e) {
                error = e as Error;
            }
        }

        return error;
    }