Test Dataverse
Dataverse — the database behind Dynamics 365 and Power Apps — exposes a read-only SQL endpoint. CAT queries it like SQL Server with the SqlServer@2 provider, so CRM data can be tested, and compared with the warehouse it feeds, without an export.
On this page
Prerequisites
- The environment’s TDS endpoint is enabled — Power Platform admin center → Environments → the environment → Settings → Product → Features → Enable TDS endpoint. It is on by default; an administrator may have turned it off. With user-level control on, the account also needs the Allow user to access TDS endpoint privilege.
- Microsoft Entra ID authentication only — your own account (MFA prompts included) interactively, a service principal with access to the environment for unattended runs. SQL and Windows authentication are rejected.
- Outbound TCP 1433 (or 5558) from the machine that runs CAT to
<organization>.crm.dynamics.com(the region suffix varies —crm4,crm11, …).
Add the data source
The server is the environment’s URL; there is no database to name. CAT Studio: technology Dataverse. YAML:
Data sources:
- Name: crm
Provider: SqlServer@2
Connection string: >
Server=contoso.crm4.dynamics.com;
Authentication=Active Directory Service Principal;
User Id=%DATAVERSE_CLIENT_ID%;
Password=%DATAVERSE_CLIENT_SECRET%;
Interactive instead: Authentication=Active Directory Interactive and no user/password. If only port 5558 is open, Server=contoso.crm4.dynamics.com,5558.
Write the tests
Tables are the Dataverse logical names — account, contact, opportunity; a lookup column comes as <lookup>id and <lookup>name, a choice column as value and label:
Tests:
- Name: Every active account has an owner
Suite: CRM data quality
Data source: crm
Query: SELECT TOP 50 accountid, name FROM account WHERE statecode = 0 AND ownerid IS NULL
Expectation: set is empty
- Name: Warehouse customers equal CRM accounts
Suite: CRM vs warehouse
First data source: crm
First query: SELECT accountid, name FROM account WHERE statecode = 0 ORDER BY accountid
Second data source: DWH
Second query: SELECT SourceId, CustomerName FROM dim.Customer WHERE SourceSystem = 'CRM' AND IsActive = 1 ORDER BY SourceId
Expectation: sets match
Key: 1
Good to know
- The endpoint is read-only and speaks a subset of T-SQL;
SELECTwith joins,GROUP BY,TOP, aggregates — yes; no temp tables, noINSERT. Details: How Dataverse SQL differs from Transact-SQL. - Queries time out after five minutes (two for
SELECT *, nestedFROMs and heavy joins) — select the columns you need,TOPwhat you can, and letKey+ORDER BYdo the comparison, not the query. - Dates come back in UTC. Choice labels are expensive — filter and compare on the value column.
- Dataverse is also a classic source for generated tests: one template over the list of entities or of option-set values.
Related
- SqlServer@2 — the provider, the Entra ID connection-string forms.
- Work with secrets — the service principal’s secret.