Add Connection String Operation
-
Use the PutConnectionStringOperation method to define a connection string in your database.
-
In this page:
Add a RavenDB connection string
The RavenDB connection string is used by RavenDB's RavenDB ETL Task.
Example:
// Define a connection string to a RavenDB database destination
// ============================================================
var ravenDBConStr = new RavenConnectionString
{
Name = "ravendb-connection-string-name",
Database = "target-database-name",
TopologyDiscoveryUrls = new[] { "https://rvn2:8080" }
};
// Deploy (send) the connection string to the server via the PutConnectionStringOperation
// ======================================================================================
var PutConnectionStringOp = new PutConnectionStringOperation<RavenConnectionString>(ravenDBConStr);
PutConnectionStringResult connectionStringResult = store.Maintenance.Send(PutConnectionStringOp);
Syntax:
public class RavenConnectionString : ConnectionString
{
public override ConnectionStringType Type => ConnectionStringType.Raven;
public string Database { get; set; } // Target database name
public string[] TopologyDiscoveryUrls; // List of server urls in the target RavenDB cluster
}
Secure servers
To connect to secure RavenDB servers
you need to:
1. Export the server certificate from the source server.
2. Install it as a client certificate on the destination server.
This can be done from the Certificates view in the Studio.
Add an SQL connection string
The SQL connection string is used by RavenDB's SQL ETL Task.
Example:
// Define a connection string to a SQL database destination
// ========================================================
var sqlConStr = new SqlConnectionString
{
Name = "sql-connection-string-name",
// Define destination factory name
FactoryName = "MySql.Data.MySqlClient",
// Define the destination database
// May also need to define authentication and encryption parameters
// By default, encrypted databases are sent over encrypted channels
ConnectionString = "host=127.0.0.1;user=root;database=Northwind"
};
// Deploy (send) the connection string to the server via the PutConnectionStringOperation
// ======================================================================================
var PutConnectionStringOp = new PutConnectionStringOperation<SqlConnectionString>(sqlConStr);
PutConnectionStringResult connectionStringResult = store.Maintenance.Send(PutConnectionStringOp);
Syntax:
public class SqlConnectionString : ConnectionString
{
public override ConnectionStringType Type => ConnectionStringType.Sql;
public string ConnectionString { get; set; }
public string FactoryName { get; set; }
}
Add an OLAP connection string
The OLAP connection string is used by RavenDB's OLAP ETL Task.
To a local machine - example:
// Define a connection string to a local OLAP destination
// ======================================================
OlapConnectionString olapConStr = new OlapConnectionString
{
Name = "olap-connection-string-name",
LocalSettings = new LocalSettings
{
FolderPath = "path-to-local-folder"
}
};
// Deploy (send) the connection string to the server via the PutConnectionStringOperation
// ======================================================================================
var PutConnectionStringOp = new PutConnectionStringOperation<OlapConnectionString>(olapConStr);
PutConnectionStringResult connectionStringResult = store.Maintenance.Send(PutConnectionStringOp);
To a cloud-based server - example:
- The following example shows a connection string to Amazon AWS.
- Adust the parameters as needed if you are using other cloud-based servers (e.g. Google, Azure, Glacier, S3, FTP).
- The available parameters are listed in ETL destination settings.
// Define a connection string to an AWS OLAP destination
// =====================================================
var olapConStr = new OlapConnectionString
{
Name = "myOlapConnectionStringName",
S3Settings = new S3Settings
{
BucketName = "myBucket",
RemoteFolderName = "my/folder/name",
AwsAccessKey = "myAccessKey",
AwsSecretKey = "myPassword",
AwsRegionName = "us-east-1"
}
};
// Deploy (send) the connection string to the server via the PutConnectionStringOperation
// ======================================================================================
var PutConnectionStringOp = new PutConnectionStringOperation<OlapConnectionString>(olapConStr);
PutConnectionStringResult connectionStringResult = store.Maintenance.Send(PutConnectionStringOp);
Syntax:
public class OlapConnectionString : ConnectionString
{
public override ConnectionStringType Type => ConnectionStringType.Olap;
public LocalSettings LocalSettings { get; set; }
public S3Settings S3Settings { get; set; }
public AzureSettings AzureSettings { get; set; }
public GlacierSettings GlacierSettings { get; set; }
public GoogleCloudSettings GoogleCloudSettings { get; set; }
public FtpSettings FtpSettings { get; set; }
}
Add an Elasticsearch connection string
The Elasticsearch connection string is used by RavenDB's Elasticsearch ETL Task.
Example:
// Define a connection string to an Elasticsearch destination
// ==========================================================
var elasticSearchConStr = new ElasticSearchConnectionString
{
Name = "elasticsearch-connection-string-name",
// Elasticsearch Nodes URLs
Nodes = new[] { "http://localhost:9200" },
// Authentication Method
Authentication = new Raven.Client.Documents.Operations.ETL.ElasticSearch.Authentication
{
Basic = new BasicAuthentication
{
Username = "John",
Password = "32n4j5kp8"
}
}
};
// Deploy (send) the connection string to the server via the PutConnectionStringOperation
// ======================================================================================
var PutConnectionStringOp =
new PutConnectionStringOperation<ElasticSearchConnectionString>(elasticSearchConStr);
PutConnectionStringResult connectionStringResult = store.Maintenance.Send(PutConnectionStringOp);
Syntax:
public class ElasticsearchConnectionString : ConnectionString
{
public override ConnectionStringType Type => ConnectionStringType.ElasticSearch;
public string Nodes { get; set; }
public string Authentication { get; set; }
public string Basic { get; set; }
public string Username { get; set; }
public string Password { get; set; }
}
Add a Kafka connection string
The Kafkah connection string is used by RavenDB's Kafka Queue ETL Task.
Learn how to add a Kafka connection string in section Add a Kafka connection string.
Add a RabbitMQ connection string
The RabbitMQ connection string is used by RavenDB's RabbitMQ Queue ETL Task.
Learn how to add a RabbitMQ connection string in section Add a RabbitMQ connection string.
Add an Azure Queue Storage connection string
The Azure Queue Storage connection string is used by RavenDB's Azure Queue Storage ETL Task.
Learn to add an Azure Queue Storage connection string in section Add an Azure Queue Storage connection string.
The PutConnectionStringOperation
method
public PutConnectionStringOperation(T connectionString)
Parameters | Type | Description |
---|---|---|
connectionString | RavenConnectionString |
Object that defines the RavenDB connection string. |
connectionString | SqlConnectionString |
Object that defines the SQL Connection string. |
connectionString | OlapConnectionString |
Object that defines the OLAP connction string. |
connectionString | ElasticSearchConnectionString |
Object that defines the Elasticsearch connction string. |
connectionString | QueueConnectionString |
Object that defines the connection string for the Queue ETLs tasks (Kafka, RabbitMQ, and the Azure Queue Storage). |
// All the connection string class types inherit from this abstract ConnectionString class:
// ========================================================================================
public abstract class ConnectionString
{
// A name for the connection string
public string Name { get; set; }
// The connection string type
public abstract ConnectionStringType Type { get; }
}
public enum ConnectionStringType
{
Raven,
Sql,
Olap,
ElasticSearch,
Queue
}