Azure Cosmos DB (Table)
Azure Cosmos DB Table API provides a premium alternative to Azure Table Storage with the same programming model but enhanced features. This guide covers configuring Cloud Replicator to use Cosmos DB Table API as a destination.
Overview
Cosmos DB Table API is compatible with Azure Table Storage but offers:
- Lower latency with SLA guarantees
- Higher throughput capabilities
- Global distribution
- Automatic secondary indexing
Data structure is the same as Azure Table Storage:
| Cosmos DB Table Concept | Business Central Mapping |
|---|---|
| Table | Business Central table name (sanitized) |
| PartitionKey | Company name + optional postfix |
| RowKey | Primary key field(s) or SystemId |
| Properties | Field values |
When to Use Cosmos DB Table API
Choose Cosmos DB Table API over Azure Table Storage when you need:
| Requirement | Benefit |
|---|---|
| Low latency | Single-digit millisecond response times |
| Higher throughput | Scale beyond Table Storage limits |
| Global distribution | Data replication across regions |
| SLA guarantees | 99.99% availability SLA |
| Premium features | Automatic indexing, rich queries |
Prerequisites
Before configuring Cosmos DB Table API:
- Azure Subscription: Active Azure subscription
- Cosmos DB Account: Account with Table API (not Core/SQL)
- Access Key: Primary or secondary key from the account
Creating a Cosmos DB Table API Account
Step 1: Create Account in Azure Portal
- Sign in to the Azure Portal (https://portal.azure.com)
- Click "Create a resource"
- Search for "Azure Cosmos DB" and select it
- Click "Create"
- Select Azure Table API (NOT Core SQL)
Step 2: Configure Basic Settings
| Setting | Recommended Value |
|---|---|
| Subscription | Your subscription |
| Resource group | Create new or use existing |
| Account name | Unique globally (lowercase) |
| Location | Same region as Business Central |
| Capacity mode | Provisioned throughput or Serverless |
Step 3: Configure Throughput
For Provisioned throughput:
- Start with 400 RU/s for testing
- Enable Autoscale for variable workloads
- Tables share throughput by default
Step 4: Complete Creation
- Click "Review + create"
- Review settings and click "Create"
- Wait for deployment to complete
Step 5: Get Access Key
- Navigate to your Cosmos DB account
- Go to "Connection String" under Settings
- Copy the "Primary Key" or use the connection string
Configuring Cloud Replicator
Setup Steps
- Search for "Cloud Replicator Setup" in Business Central
- Locate the Azure Cosmos DB (Table) section
- Enter the following:
| Field | Value |
|---|---|
| Cosmos DB Account Name | Your account name |
| Cosmos DB Account Access Key | The primary or secondary key |
Testing the Connection
After entering credentials:
- Create a table mapping for a small table
- Select "Cosmos DB Table" as the destination
- Run a manual replication
- Check the Replication Log for success
- Verify data in Azure Portal > Data Explorer
Data Structure
Table Names
Business Central table names are sanitized the same way as Azure Table Storage:
- Spaces and special characters are removed
- Table names starting with a number are prefixed with "T"
- Maximum 63 characters
Partition Keys and Row Keys
Same structure as Azure Table Storage:
| Component | Format |
|---|---|
| PartitionKey | Company name (cleaned) + optional postfix |
| RowKey | Primary key fields or SystemId |
Entity Properties
All Business Central fields become entity properties:
- Field names sanitized for compatibility
- Data types mapped to OData types
- System fields included automatically
Compatibility with Azure Table Storage
Cosmos DB Table API is API-compatible with Azure Table Storage:
What's Compatible
- Same REST API
- Same SDK code works with both
- Same data model (PartitionKey/RowKey)
- Same query syntax
What's Different
| Feature | Table Storage | Cosmos DB Table |
|---|---|---|
| Throughput model | Pay-per-use | RU/s (provisioned or serverless) |
| Latency SLA | No | Yes (<10ms reads, <15ms writes) |
| Secondary indexes | PartitionKey/RowKey only | Automatic on all properties |
| Global distribution | Limited | Full multi-region support |
Performance Considerations
Throughput (RU/s)
| Operation | Typical RU Cost |
|---|---|
| Point read | 1 RU |
| Entity insert | 5-10 RU |
| Entity update | 5-10 RU |
| Query (per 1KB returned) | 2-3 RU |
Scaling Recommendations
| Scenario | Configuration |
|---|---|
| Testing | 400 RU/s minimum |
| Light replication | 400-1000 RU/s |
| Medium replication | 1000-5000 RU/s |
| Heavy initial load | 5000+ RU/s with Autoscale |
Autoscale
Enable Autoscale for production workloads:
- Automatically adjusts between 10% and 100% of max
- Handles replication spikes without manual intervention
- More cost-effective than fixed provisioning
Series Tables (Per Day)
When "Per Day" is enabled:
- A "Series" table is created (e.g.,
SalesHeaderSeries) - Contains daily snapshots of data
- RowKey includes the date for time-series analysis
Migrating from Azure Table Storage
If you're currently using Azure Table Storage and want to migrate:
Step 1: Create Cosmos DB Table API Account
Follow the steps above to create a new account.
Step 2: Update Cloud Replicator Configuration
- Open Cloud Replicator Setup
- Enter Cosmos DB Table credentials
- Change table mappings to use "Cosmos DB Table" destination
Step 3: Initial Replication
- Run a manual replication to populate Cosmos DB
- Verify data integrity
- Update downstream applications to use new connection
Data Migration Tools
For existing data:
- Azure Data Factory can copy between Table Storage and Cosmos DB
- Use the Data Migration Tool for one-time migrations
Cost Considerations
Pricing Components
| Component | Description |
|---|---|
| Throughput | RU/s provisioned × hours × regions |
| Storage | Per GB per month |
| Backup | Per GB (optional PITR) |
Cost Comparison with Table Storage
| Scenario | Table Storage | Cosmos DB Table |
|---|---|---|
| Low usage, storage-focused | Lower cost | Higher cost |
| High throughput needed | May throttle | Better performance/cost ratio |
| Global distribution | Not available | Premium feature included |
Cost Optimization
- Use Serverless for infrequent replication
- Enable Autoscale instead of fixed provisioning
- Exclude unnecessary fields from replication
- Clean up series tables periodically
Troubleshooting
Connection Issues
- Verify account name is correct
- Check that you're using a Table API account (not Core SQL)
- Ensure access key is valid
Throttling (429 Errors)
- Increase RU/s provisioning
- Enable Autoscale
- Reduce replication engine count
- Implement exponential backoff (handled by Cloud Replicator)
Table Creation Fails
- Check for invalid characters in table names
- Verify sufficient RU/s for table operations
- Review error details in Replication Log
SDK Compatibility
If querying from applications:
- Use same Azure Table Storage SDK
- Connection string format differs from Table Storage
- Update endpoint to
.table.cosmos.azure.com
Security
Network Security
- Configure IP firewall rules
- Use private endpoints for production
- Enable virtual network service endpoints
Authentication
- Primary/Secondary key for full access
- Use resource tokens for limited scenarios
- Azure AD authentication available
Encryption
- Data encrypted at rest by default
- Customer-managed keys available
- TLS 1.2 for data in transit