SQL Database Connector

You can create a SQL connector to connect to a SQL database (SQLite or SQL Server). This enables digital twin instances (both real-time and simulation) to retrieve saved values for their state properties and to persist updates to their state properties in corresponding digital twin instances stored in the database.

To connect to a SQL database, you need to supply a SQL Database connection string. This string is an expression that contains the parameters required for applications to connect to a database server. Connection strings typically include the server instance, database name, authentication details, and other settings required to communicate with the database server.

In addition, you can supply the following parameters for the connection:

  • Update Interval: the minimum period in seconds between successive updates to a SQL persisted instance after updates to its corresponding digital twins instance

  • Retrieve State on Create: indication whether to retrieve properties from SQL when creating a digital twin instance

Note

The Update Interval parameter allows digital twin deployments with high message rates and/or many data sources to throttle their updates to the SQL database and avoid hitting its resource limits.

Here is a screenshot of the dialog in the ScaleOut Digital Twins™ UI for creating a SQL connector:

sql_connector_image

You can deploy the connector immediately after it is created, or you can deploy it at a later time. The connector authenticates with the SQL database when it is deployed.

Enable Persistence for a Digital Twin Model

Java Models

A Java digital twin model can enable persistence by adding enablePersistence to the model definition file and setting it to true. The model will use the default, configured persistence provider, which is the last persistence provider that was configured. If more than one persistence provider has been configured, the value persistenceProvider can be added to the model definition file and set to one of the following strings: “CosmosDB”, “DynamoDB”, “SQLServer”, “SQLite”, “AzureDigitalTwinsService”, or “Default”.

.NET Core Models

A .NET Core digital twin model can enable persistence by adding EnablePersistence to the appsettings.json and setting it to true. The model will use the default, configured persistence provider, which is the last persistence provider that was configured. If more than one persistence provider has been configured, the value PersistenceProvider can be added to the model definition file and set to one of the following strings: “CosmosDB”, “DynamoDB”, “SQLServer”, “SQLite”, “AzureDigitalTwinsService”, or “Default”.

Here is an example:

 {
     "StartupDll": "WindTurbine.dll",
     "ModelName": "WindTurbine",
     "ModelType": "WindTurbine.dll, WindTurbine.WindTurbineDigitalTwin",
     "MessageType": "WindTurbineMessages.dll, WindTurbineMessages.DeviceTelemetry",
     "EnablePersistence": true
 }

Rule-based Models

To enable persistence in a rule-based model, set the EnablePersistence property in the model definition file. This can be done directly in the ScaleOut Model Development Tool:

persistence_dev_tool