public static async createAppCertificateConnectionString()

in packages/quick_start/src/Utils.ts [115:141]


    public static async createAppCertificateConnectionString(
        clusterUri: string,
        certificatePath: string | undefined,
        certificatePassword: string | undefined,
        applicationId: string | undefined,
        tenantId: string | undefined,
        sendX5c?: boolean,
    ): Promise<KustoConnectionStringBuilder> {
        const appId: string | undefined = process?.env?.APP_ID;
        const appTenant: string | undefined = process?.env?.APP_TENANT;
        const privateKeyPemFilePath: string | undefined = process?.env?.PRIVATE_KEY_PEM_FILE_PATH;
        const publicCertFilePath: string | undefined = process?.env?.PUBLIC_CERT_FILE_PATH;

        if (!certificatePath || !certificatePassword || !applicationId || !tenantId || !appId) {
            this.errorHandler(`"Missing some required field/s in environment in order to authenticate using a certificate."`);
        } else {
            if (!privateKeyPemFilePath) {
                this.errorHandler(`"Failed to load PEM file from ${privateKeyPemFilePath}"`);
            } else {
                const pemCertificate: string = await fs.promises.readFile(privateKeyPemFilePath, "utf8");
                if (publicCertFilePath) {
                    return KustoConnectionStringBuilder.withAadApplicationCertificateAuthentication(clusterUri, appId, pemCertificate, appTenant, sendX5c);
                }
                return KustoConnectionStringBuilder.withAadApplicationCertificateAuthentication(clusterUri, appId, pemCertificate, appTenant);
            }
        }
    }