Dynamics 365 CRM On-Premises — Gotchas
These traps apply to any kalamos project working against a D365 CE on-prem deployment. Cross-project; not specific to CRMAPIGenerator.
Auth quirks
- Plain Windows auth + ADFS + IFD is the production scaffold for most regulated customers. The
CrmServiceClientconnection string has different shapes for each:- AD:
AuthType=AD; Url=...; Domain=...; UserName=...; Password=...; - ADFS:
AuthType=Federation; Url=...; HomeRealmUri=...; UserName=...; Password=...; - IFD:
AuthType=IFD; Url=...; Username=...; Password=...; HomeRealmUri=...;
- AD:
- OAuth on-prem requires the deployment to have ADFS configured for OAuth flows (not all do).
- S2S / app-user auth is not available on on-prem before v9.0 RU8 — and even then has limitations vs Online.
- Token-cache misses on long-running services manifest as silent retries; instrument with logging at the
CrmServiceClientboundary.
API
- OData v4 endpoint at
/api/data/v9.x/. The version segment matters; mismatched client/server versions fail with HTTP 404. - Web API uses different metadata than the SOAP/Org Service endpoint. A property name in
EntityMetadata.LogicalNamemay not equal the OData entity-set name (e.g.,account→accounts). Always introspect at runtime; don’t hardcode pluralization. - Batch operations via
$batchhave a hard 1000-change-set limit per request. Larger payloads must be chunked. Prefer: odata.include-annotations="*"header is needed for FormattedValue, navigation-property, and lookup logical-name annotations. Most agent code forgets this and ends up withnulls where labels were expected.
Plugin sandbox
- Sandbox plugins (the only kind allowed in cloud, optional but recommended on-prem) cannot:
- Make outbound network calls except via
IOrganizationService - Touch the filesystem
- Use
System.Reflection.Assembly.Load* - Spawn threads
- Make outbound network calls except via
- Plugin steps at
Pre-Validationrun outside the database transaction.Pre-OperationandPost-Operationrun inside. State leakage across stages is a common bug source.
Data import / export
ImportandBulkDeletejobs are async and report progress viaImportJobandBulkDeleteOperationentities. Polling these is the only reliable way to know when they finish.- Audit data does not export through standard tools. Custom retrieval against
Auditentity required.
Versioning
- Customer environments are typically pinned at a specific Update Rollup (
Microsoft.Crm.Sdk.Proxy). Mismatched SDK version on the agent’s machine vs server: most ops still work but specific entity attributes (newer ones) won’t appear in metadata calls.
See also
[[Microsoft-Xrm-Sdk]]— the SDK itself[[Yellow-Banner-Trap]]— pipeline anti-pattern, applies to any GitHub-based work