Database Connections

Goal: Give your workspace a database it owns, and connect historical data from databases you already run.


Current Status

FeatureStatus
CosmosDB accounts, provisioned from the UIAvailable
Container and document management from the UIAvailable
Per-container table APIsAvailable
SQL, PostgreSQL, MySQL, MongoDB, Azure Data ExplorerCustom code
Thinking Tip:

The UI path provisions CosmosDB accounts into your own Azure subscription. Other databases — ones you already run — still connect through custom integration code, covered further down this page.


Option A: Provision a CosmosDB account from the UI

  1. Open Environment in the workspace toolbar and choose Databases
  2. Sign in to Azure inside the modal if your session has expired
  3. Name the account and pick a scaling profile by name — Serverless, Standard or High volume
  4. Choose Save & Provision
  5. Watch the account's row move to Live — provisioning runs in the background and the list updates as it completes
  6. Drag a Database node from the Node Bank onto the canvas and choose the account it lives in

There is nothing to paste. The account is created in your own connected Azure subscription, and its credentials are resolved server-side — there is no endpoint field, no account key, and no connection to test.

The account is where data physically sits, which is why its region is fixed when it is created.

Your first account is created in your workspace landing zone region — that is not a choice made in this modal. Any additional account must state its own region, because it is not inherited from your landing zone. Each region is a separate CosmosDB account with its own cost floor.

→ Full walkthrough: CosmosDB Setup


Option B: Ask Azi

Azi can propose the records for you. Ask for what you want in plain language — "add a database for sample records in the home store" — and Azi drafts a proposal you review before it is applied.


Custom Code Approach

For databases you already run — Azure Data Explorer, SQL Server, PostgreSQL and others — you can build custom integrations.

Architecture

Your Database → Custom Integration Code → OpenIndustrial API → Control Plane

Example: Azure Data Explorer Integration

import { Client as KustoClient } from 'azure-kusto-data';

// Connect to your Azure Data Explorer cluster
const client = new KustoClient(
  'https://your-cluster.region.kusto.windows.net',
  { /* auth config */ }
);

// Query your database
const results = await client.execute(
  'your-database',
  `YourTable | where timestamp > ago(1h) | summarize avg(value) by bin(timestamp, 5m)`
);

// Push to OpenIndustrial via API
const response = await fetch(
  'https://www.openindustrial.co/api/workspaces/{workspace}/data-import',
  {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${apiToken}`,
      'Content-Type': 'application/json',
    },
    body: JSON.stringify({
      source: 'adx-historical',
      data: results.primaryResults[0].toJSON(),
    }),
  }
);

Example: SQL Server Integration

import sql from 'mssql';

const config = {
  server: 'your-server.database.windows.net',
  database: 'your-database',
  user: 'your-user',
  password: process.env.SQL_PASSWORD,
  options: { encrypt: true },
};

// Connect and query
const pool = await sql.connect(config);
const result = await pool.request().query(`
  SELECT timestamp, sensor_id, temperature, humidity
  FROM telemetry
  WHERE timestamp > DATEADD(hour, -1, GETUTCDATE())
`);

// Transform and push to OpenIndustrial
for (const row of result.recordset) {
  await pushToOpenIndustrial({
    deviceId: row.sensor_id,
    timestamp: row.timestamp,
    temperature: row.temperature,
    humidity: row.humidity,
  });
}

Supported Databases

Custom integrations work with any database that has a Node.js/Deno driver:

DatabasePackage
Azure Data Explorerazure-kusto-data
Azure SQL / SQL Servermssql
PostgreSQLpg
MySQLmysql2
MongoDBmongodb

Deployment Options

Run your custom integration as:

OptionBest For
Azure FunctionsEvent-driven, serverless
ContainerContinuous polling
Deno DeployLightweight, edge-deployed
On-premisesAir-gapped environments

Security Considerations

Use read-only database accounts. Never give write access to integration code.

  • Store credentials in environment variables or secret managers
  • Use managed identities where possible (Azure)
  • Enable query auditing on the database side
  • Implement rate limiting to prevent overload

These apply to the custom code path, where you hold the credentials. A CosmosDB account provisioned from the UI has no credential for you to store.


Next Steps

If you want to...Go to...
Provision a CosmosDB accountCosmosDB Setup →
Manage containers and documentsDatabase Management →
Publish a container's documents over HTTPDatabase Tables →
Connect external APIsExternal API Guide →
Build queries on imported dataWarm Queries Guide →
Connect IoT devicesIoT Hub Guide →
On this page