public static async generateConnectionString()

in packages/quick_start/src/Utils.ts [48:86]


    public static async generateConnectionString(
        clusterUri: string,
        authenticationMode: AuthenticationModeOptions,
        certificatePath: string | undefined,
        certificatePassword: string | undefined,
        applicationId: string | undefined,
        tenantId: string | undefined,
    ): Promise<KustoConnectionStringBuilder> {
        // Learn More: For additional information on how to authorize users and apps in Kusto see:
        // https://docs.microsoft.com/azure/data-explorer/manage-database-permissions
        switch (authenticationMode) {
            case AuthenticationModeOptions.UserPrompt: {
                // Prompt user for credentials
                return KustoConnectionStringBuilder.withUserPrompt(clusterUri);
            }
            case AuthenticationModeOptions.ManagedIdentity: {
                // Authenticate using a System-Assigned managed identity provided to an azure service, or using a User-Assigned managed identity.
                // For more information, see https://docs.microsoft.com/en-us/azure/active-directory/managed-identities-azure-resources/overview
                // Connect using the system - or user-assigned managed identity (Azure service only)
                // TODO (config - optional): Managed identity client ID if you are using a user-assigned managed identity
                return process.env.MANAGED_IDENTITY_CLIENT_ID
                    ? KustoConnectionStringBuilder.withUserManagedIdentity(clusterUri, process?.env?.MANAGED_IDENTITY_CLIENT_ID)
                    : KustoConnectionStringBuilder.withSystemManagedIdentity(clusterUri);
            }
            case AuthenticationModeOptions.AppKey: {
                // Learn More: For information about how to procure an AAD Application,
                // see: https://docs.microsoft.com/azure/data-explorer/provision-azure-ad-app
                // TODO (config - optional): App ID & tenant, and App Key to authenticate with
                return this.createAppKeyConnectionString(clusterUri);
            }
            case AuthenticationModeOptions.AppCertificate: {
                // Authenticate using a certificate file.
                return await this.createAppCertificateConnectionString(clusterUri, certificatePath, certificatePassword, applicationId, tenantId);
            }
            default: {
                this.errorHandler(`Authentication mode '${authenticationMode}' is not supported`);
            }
        }
    }