June 30, 2026

Connecting SitecoreAI with Microsoft Dataverse: Authentication & Access Configuration

How to Connect SitecoreAI with Microsoft Dataverse: Authentication Guide & Best Practices

Posted on June 30, 2026  •  7 minutes  • 1439 words

Table of contents

📊 Introduction

In the first part of our SitecoreAI and Microsoft Dataverse integration series , we explored the foundational concepts and architecture. Now, let’s dive into the practical aspects of establishing a secure connection between your SitecoreAI (XM Cloud) application and Microsoft Dataverse .

Authentication serves as the foundation for every integration. When linking SitecoreAI to Dataverse, it’s essential to configure your .NET application to securely call Dataverse APIs while upholding enterprise security and compliance requirements. This guide provides a step-by-step overview of authentication options, necessary permissions, and suggested approaches for establishing reliable connections.

What You’ll Learn:

  • Authentication options for Dataverse (Service Principal vs. User credentials)
  • Setting up Azure AD App Registration
  • Configuring service principal permissions in Dataverse
  • Building secure connection strings
  • Implementing connection code in .NET
  • Best practices for credential management

🔐 Understanding Dataverse Authentication

Microsoft Dataverse supports multiple authentication methods, but for server-to-server integration with SitecoreAI, Microsoft Entra ID (formerly Azure AD) Service Principal authentication is the recommended approach.

Why Service Principal Over User Credentials?

Authentication MethodUse CaseProsCons
Service Principal (App Registration)Server-to-server, automated workflowsNo user interaction, Scalable, Auditable,Doesn’t expire with userRequires Azure AD admin access
User Credentials (OAuth 2.0)Interactive applications, Power AppsUser-specific permissions, Easy for testingRequires user sign-in, Not suitable for automation
Client SecretDevelopment/testingQuick setupLess secure than certificates, Manual rotation
Certificate-BasedProduction environmentsMost secure, Recommended for prodRequires certificate management

For SitecoreAI integration, we recommend:

  • Development/Testing: Service Principal with Client Secret
  • Production: Service Principal with Certificate

Step 1: Create Azure AD App Registration

An App Registration in Azure AD serves as the identity for your SitecoreAI application when connecting to Dataverse.

1.1 Navigate to Azure Portal

  1. Go to Azure Portal

  2. Search for Azure Active Directory

Microsoft Dataverse supports multiple authentication methods
  1. Select App registrations ➡ New registration
Microsoft Dataverse supports multiple authentication methods

1.2 Register Your Application

Configuration:

Name: SitecoreAI-Dataverse-Connector
Supported account types: Accounts in this organizational directory only (Single tenant)
Redirect URI: Leave blank (server-to-server integration)
Microsoft Dataverse supports multiple authentication methods

Click “Register”

API Permission to read

Microsoft Azure AD App API

1.3 Note Critical Information

After registration, record these values (you’ll need them later):

  • Application (client) ID
Microsoft Azure AD App Client ID

Step 2: Create Client Secret or Certificate

An App Registration in Azure AD serves as the identity for your SitecoreAI application when connecting to Dataverse.

Option A: Client Secret (Development)

  1. In your App Registration, go to Certificates & secrets
Microsoft Azure AD App Client Secret or Certificate
  1. Click New client secret
Description: SitecoreAI-Dev-Secret
Expires: 12 months (or custom)
Redirect URI: Leave blank (server-to-server integration)
  1. Click Add
Microsoft Azure AD App Client Secret

CRITICAL

Copy the secret value immediately (you cannot retrieve it later)

  1. Generate Self-Signed Certificate (for testing):
# PowerShell script to generate certificate
$cert = New-SelfSignedCertificate `
   -Subject "CN=SitecoreAI-Dataverse" `
   -CertStoreLocation "Cert:\CurrentUser\My" `
   -KeyExportPolicy Exportable `
   -KeySpec Signature `
   -KeyLength 2048 `
   -KeyAlgorithm RSA `
   -HashAlgorithm SHA256 `
   -NotAfter (Get-Date).AddYears(2)

# Export certificate (upload to Azure AD)
Export-Certificate -Cert $cert -FilePath "SitecoreAI-Dataverse.cer"

# Export private key (use in your application)
$password = ConvertTo-SecureString -String "YourStrongPassword" -Force -AsPlainText
Export-PfxCertificate -Cert $cert -FilePath "SitecoreAI-Dataverse.pfx" -Password $password

Upload to Azure AD:

  1. Go to Certificates & secretsCertificates tab

  2. Click Upload certificate

  3. Select SitecoreAI-Dataverse.cer

  4. Click Add

Step 3: Grant Dataverse Access to Service Principal

Now your App Registration exists, but it needs permission to access Dataverse.

3.1 Navigate to Power Platform Admin Center

  1. Go to Power Platform Admin Center
Microsoft PowerPlatform
  1. To create new environment, follow Create and manage an environment
Microsoft PowerPlatform New Environment Microsoft PowerPlatform New Environment

3.2 Create Application User

  1. Select your Dataverse environment from Power Platform Admin Center ➡ Manage ➡ Environments

  2. Go to SettingsUsers + permissionsApplication users ➡ Click New app user

Add an app from Microsoft Entra

Create and manage environments in Dataverse

You can check details about users and roles within an environment here

Configuration:

App: Select your App Registration (SitecoreAI-Dataverse-Connector)
Business unit: Your organization's business unit
Security roles: System Administrator (or custom role with appropriate permissions)

⚠️ Security Best Practice:

Instead of System Administrator, create a custom security role with minimum required permissions:

Recommended Permissions for SitecoreAI Integration:

  • Core Records: Create, Read, Update, Delete (as needed)

  • Business Management: None

  • Service Management: None

  • Customization: Read (if reading metadata)

Step 4: Determine Required Access Level

Access levels in Dataverse control what data your application can read/modify.

Access Level Hierarchy

Access LevelScopeExample Use Case
NoneNo accessRestricted tables
UserOnly records owned by the app userPersonal data
Business UnitRecords in the app user’s business unitDepartment-specific data
Parent: Child Business UnitsBusiness unit + child unitsMulti-department
OrganizationAll records in the environmentGlobal data access

For SitecoreAI Form Submissions (typical scenario):

  • Create: Organization level (allow forms from any site)

  • Read: Organization level (read any submission)

  • Update: Business Unit level (only update your records)

  • Delete: Business Unit level (controlled deletion)

Step 5: Build Dataverse Connection String

With authentication configured, construct your connection string.

Connection String Components

AuthType=ClientSecret;
Url=https://yourorg.crm.dynamics.com;
ClientId=12345678-1234-1234-1234-123456789abc;
ClientSecret=abc123DEF456ghi789JKL012mno345PQR678stu901VWX234

Component Breakdown:

  • AuthType: ClientSecret or Certificate

  • Url: Your Dataverse environment URL (find in Power Platform Admin Center)

  • ClientId: Application (client) ID from App Registration

  • ClientSecret: Secret value (if using client secret)

  • CertificateStoreName / CertificateThumbprint: (if using certificate)

Certificate-Based Connection String

AuthType=Certificate;
Url=https://yourorg.crm.dynamics.com;
ClientId=12345678-1234-1234-1234-123456789abc;
CertificateStoreName=My;
CertificateThumbprint=ABCDEF1234567890ABCDEF1234567890ABCDEF12

Find Certificate Thumbprint:

Get-ChildItem -Path Cert:\CurrentUser\My | Where-Object { $_.Subject -like "*SitecoreAI*" }

Step 6: Implement Connection in .NET

6.1 Install NuGet Package

dotnet add package Microsoft.Data.SqlClient
dotnet add package Microsoft.Extensions.Hosting
dotnet add package Microsoft.PowerPlatform.Dataverse.Client
Install NuGet Package

It is always recommended to use environment variables to store configuration details. This makes it easier to deploy the application to different environments, as the configuration can be updated through environment variables without modifying the application code.

{
  "Dataverse": {
    "DataverseEnvironment": "environmentid.crm.dynamics.com/",
    "ClientId": "client id",
    "ClientSecret": "client secret"
  },
  "Logging": {
    "LogLevel": {
      "Default": "Information"
    }
  }
}

6.3 Create Dataverse Service Client (using Client Secret)

Create Dataverse Service Client

Secure Credential

NEVER hardcode secrets in your code or commit them to source control!

6.4 Register in Dependency Injection (Startup.cs / Program.cs)

using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using SitecoreAI.Dataverse.Services;

// Build host with dependency injection
var host = Host.CreateDefaultBuilder(args)
    .ConfigureServices((context, services) =>
    {
        services.AddSingleton<DataverseConnectionService>();
    })
    .Build();

Console.WriteLine("Dataverse Connection Validation");

// Get the service from DI container
var dataverseService = host.Services.GetRequiredService<DataverseConnectionService>();

try
{
    // Get the service client
    var serviceClient = dataverseService.GetServiceClient();
    Console.WriteLine("Connected to Dataverse successfully.");
}
catch (Exception ex)
{
    Console.WriteLine($"Dataverse call failed: {ex.Message}");
    if (ex.InnerException != null)
    {
        Console.WriteLine($"Inner Exception: {ex.InnerException.Message}");
    }
    Console.WriteLine($"\nStack Trace: {ex.StackTrace}");
}

Step 7 Verify Connection

You can download the code from the SitecoreAI-Dataverse-Connector GitHub repository. After configuring all the required settings, run the project. If the connection to Microsoft Dataverse is established successfully, the success message Connected to Dataverse successfully. will be displayed in the console:

Dataverse Connection Validation

Explore More & Share Your Feedback

📱 Scan to access the complete SitecoreAI-Dataverse-Connector repository
💻 Azure Functions integration, .NET 8 code, authentication setup & CRUD examples



Share your feedback or contribute to support the Sitecore developer community!


🐞 Troubleshooting Common Issues

Issue 1: “Entity doesn’t contain attribute”

Cause: Using the wrong entity and its attributes

Solution: Verify table name and its fields

System.ServiceModel.FaultException`1: ''crf21_Department' entity doesn't contain
 attribute with Name = 'crf21_ID' and NameMapping = 'Logical' 
 (look up attribute by name is case-sensitive).orgIndex: 1514, id: 
 123456-c66c-5678-987, logicalName: crf21_department'

Issue 2: “No valid connection string parameter was found”

Cause: Malformed connection string
Solution: Verify format, ensure no line breaks, check for typos

// ❌ Incorrect (line breaks causing issues)
var conn = "AuthType=ClientSecret;
Url=https://yourorg.crm.dynamics.com;
ClientId=...";

// ✅ Correct (single line or use verbatim string)
var conn = @"AuthType=ClientSecret;Url=https://yourorg.crm.dynamics.com;ClientId=...;ClientSecret=...";

Issue 3: “AADSTS7000215: Invalid client secret provided”

Cause: Incorrect client secret or expired
Solution: Regenerate secret in Azure AD, update configuration

Issue 4: “Principal user is missing prvReadAccount privilege”

Cause: Application user lacks necessary permissions
Solution: Update security role in Power Platform Admin Center

Issue 5: “Request failed with status code 401 Unauthorized”

Cause: Service principal not added as Application User in Dataverse
Solution: Follow Step 3.2 to create Application User

👣 Next Steps

Now that you’ve established a secure connection with Dataverse, you’re ready to perform CRUD operations!

In Article 3, we’ll build Azure Functions to interact with Dataverse table:

  • Implement Add (Create) operations

  • Implement Update operations

  • Implement Delete operations

  • Handle transactions and error scenarios

Stay tuned! 👀

🧾Credit/References

Authenticate with Microsoft Dataverse web services Comprehensive guide on all authentication methodsUse connection strings in XRM tooling Connection string syntax and examplesCreate an application user in Dataverse Step-by-step guide for adding service principals
Microsoft.PowerPlatform.Dataverse.Client NuGet Package Latest SDK package for .NETAzure Key Vault integration with .NET Secure secret management guideDataverse Connection Strings - Power CAT Team Blog Real-world connection string examples
Sitecore Community - SitecoreAI (XM Cloud) Integration Patterns Sitecore-specific integration discussionsPower Platform Community Forums Community support for Dataverse authentication issuesHow SitecoreAI Integrates with Microsoft Dataverse Introduction to SitecoreAI and Microsoft Dataverse Integration
Build Custom Sitecore MCP Tools in .NETSitecore MCP Server Sitecore Marketer MCPMCP Server vs Copilot vs GenAI
View All

This article is part of a series:   SitecoreAI and Microsoft Dataverse Integration
comments powered by Disqus
All posts