Add Connection String Operation
-
Use the PutConnectionStringOperation method to define a connection string in your database.
-
In this page:
- Add a RavenDB connection string
- Add an SQL connection string
- Add a Snowflake connection string
- Add an OLAP connection string
- Add an Elasticsearch connection string
- Add a Kafka connection string
- Add a RabbitMQ connection string
- Add an Azure Queue Storage connection string
- Add an Amazon SQS connection string
- The PutConnectionStringOperation method
Add a RavenDB connection string
RavenDB connection strings are used by RavenDB RavenDB ETL Tasks.
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 Studio Certificates view.
Add an SQL connection string
SQL connection strings are used by RavenDB SQL ETL Tasks.
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 a Snowflake connection string
Snowflake connection strings are used by RavenDB Snowflake ETL Tasks.
Example:
// Define a connection string to a Snowflake warehouse database
// ==========================================================
var SnowflakeConStr = new SnowflakeConnectionString
{
Name = "snowflake-connection-string-name",
ConnectionString = "ACCOUNT = " + SnowflakeAccount + "; USER = " + SnowflakeUser + "; PASSWORD = " + SnowflakePassword
};
// Deploy (send) the connection string to the server via the PutConnectionStringOperation
// ======================================================================================
var PutConnectionStringOp =
new PutConnectionStringOperation<SnowflakeConnectionString>(SnowflakeConStr);
PutConnectionStringResult connectionStringResult = store.Maintenance.Send(PutConnectionStringOp);
Add an OLAP connection string
OLAP connection strings are used by RavenDB OLAP ETL Tasks.
Example: To a local machine
// 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);
Example: To a cloud-based server
- The following example shows a connection string to Amazon AWS.
- Adjust 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
Elasticsearch connection strings are used by RavenDB Elasticsearch ETL Tasks.
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
Kafkah connection strings are used by RavenDB Kafka Queue ETL Tasks.
Learn how to add a Kafka connection string in the Add a Kafka connection string section.
Add a RabbitMQ connection string
RabbitMQ connection strings are used by RavenDB RabbitMQ Queue ETL Tasks.
Learn how to add a RabbitMQ connection string in the Add a RabbitMQ connection string section.
Add an Azure Queue Storage connection string
Azure Queue Storage connection strings are used by RavenDB Azure Queue Storage ETL Tasks.
Learn to add an Azure Queue Storage connection string in the Add an Azure Queue Storage connection string section.
Add an Amazon SQS connection string
Amazon SQS connection strings are used by RavenDB Amazon SQS ETL Tasks.
Learn to add an SQS connection string in this section.
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 | SnowflakeConnectionString |
Object that defines the Snowflake connction 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, Azure Queue Storage, and Amazon SQS). |
// 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
{
RavenNone,
Raven,
Sql,
Olap,
ElasticSearch,
Queue,
Snowflake
}