Dataverse / Dynamics 365 : Azure Managed Identities from Plugins. Step by Step.
Introduction
The days of storing Client ID and secret of your Key Vault in Dynamics are coming to an end. With Power Platform Managed Identity, Dataverse plug-ins can now connect to Azure resources that support managed identity without the need for credentials. Please note that at the time of writing this article, this feature is still in preview and is not intended for production use.
This marks a significant improvement in security and access management, eliminating the risks associated with storing credentials while simplifying integration between Dataverse and Azure. In this article, we’ll explore how this feature works and the process for implementing it.
How to implement it
Microsoft’s documentation is missing some details that can make the configuration process challenging. In this article, I’ll provide a clear, step-by-step guide with practical examples to help you set everything up quickly and efficiently. My goal is to simplify the process and ensure you have a smooth experience getting it to work.
Step 1 : Create a new app registration or user-assigned managed identity
- Create new "User Assigned Managed Identity". You can follow this documentation to create it.

- Copy and save the "Client ID" value of your managed identity to be used in step 6

Step 2 : Create Key Vault
- Create a key vault
- Create a secret with name "DynamicsChroniclesSecret" and with secret value = "Managed identity for Power Platform is working"
- In "Access control (IAM)" of your key vault, add the role assignment "Key Vault Secrets User" to the User Assigned Managed Identity created in step 1
Step 3 : Create a certificate
- Open Powershell to create a certificate using this script
# Generate a self-signed certificate
$cert = New-SelfSignedCertificate -Subject "CN=dynamicschronicles, O=corp, C=dynamicschronicles.ch" -DnsName "www.dynamicschronicles.ch" -Type CodeSigning -KeyUsage DigitalSignature -CertStoreLocation Cert:\CurrentUser\My -FriendlyName "dynamicschronicles"
# Set a password for the private key
$pw = ConvertTo-SecureString -String "complexpwd12345" -Force -AsPlainText
# Export the certificate as a PFX file
Export-PfxCertificate -Cert $cert -FilePath 'C:\temp\dynamicschronicles_certificate.pfx' -Password $pw
Write-Host "Self-signed certificate exported as C:\temp\dynamicschronicles_certificate.pfx."
# Display thumbprint
$cert.Thumbprint
- Copy and save the "Thumbprint" value to be used in step 5
![]()
Step 4 : Create a plug-in assembly, sign it and register it
- Create a new plug-in using Visual Studio. Here is an example of code :
using Microsoft.Xrm.Sdk;
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Headers;
namespace ManagedPlugin
{
public class ManagedPlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
// Obtain the tracing service
ITracingService tracingService =
(ITracingService)serviceProvider.GetService(typeof(ITracingService));
// Obtain the execution context from the service provider.
IManagedIdentityService managedIdentityService = (IManagedIdentityService)
serviceProvider.GetService(typeof(IManagedIdentityService));
// Obtain the execution context from the service provider.
IPluginExecutionContext context = (IPluginExecutionContext)
serviceProvider.GetService(typeof(IPluginExecutionContext));
// Initialize empty token
string token = string.Empty;
string[] scopes = new string[] { "https://YOUR-DYNAMICS-ORG-URL.crm4.dynamics.com/.default" };
try
{
tracingService.Trace("Scopes in GetAccessTokenManagedIdentity: " + string.Join(", ", scopes));
token = managedIdentityService.AcquireToken(scopes);
tracingService.Trace($"MANAGED IDENTITY TOKEN : {token}");
}
catch (Exception ex)
{
tracingService.Trace($"Failed to acquire token {ex.Message}");
}
var keyvaultname = "YOUR-KEYVAULT-NAME";
var secretname = "DynamicsChroniclesSecret";
// Get Token
var kv_scopes = new List { "https://vault.azure.net/.default" };
var kv_token = managedIdentityService.AcquireToken(kv_scopes);
tracingService.Trace($"KV TOKEN : {kv_token}");
var keyvaultsecretUrl = $"https://{keyvaultname}.vault.azure.net/secrets/{secretname}?api-version=7.4";
try
{
using (HttpClient client = new HttpClient())
{
client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", kv_token);
client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
var request = new HttpRequestMessage(HttpMethod.Get, new Uri(keyvaultsecretUrl));
var response = client.SendAsync(request).Result;
string json = response.Content.ReadAsStringAsync().Result;
var keyVaultResponse = System.Text.Json.JsonSerializer.Deserialize(json);
tracingService.Trace($"KV SECRET VALUE : {keyVaultResponse.value}");
}
}
catch (Exception ex)
{
tracingService.Trace($"Failed to acquire token {ex.Message}");
}
}
}
}
public class KeyVaultResponse
{
public string value { get; set; }
public string id { get; set; }
}
- Replace the following values with yours
- Line 27 => "https://YOUR-DYNAMICS-ORG-URL.crm4.dynamics.com/.default"
- Line 40 => "YOUR-KEYVAULT-NAME" (name of the key vault created in step 2)
- Build the plugin
- Sign the plugin using signtool and the following Powershell command
.\signtool sign /f "C:\temp\dynamicschronicles_certificate.pfx" /p "complexpwd12345" "C:\Path_to_your_plugin\bin\Debug\ManagedPlugin.dll"
- Register the plug-in and register a new step (i.e. create of account)
Step 5 : Configure federated identity credentials
- Open the User Assigned Managed Identity created in step 1
- Navigate to "Settings/Federated credentials" and click on "Add Credential"

- Select "Other" for "Federated credential scenario"
- Set "Issuer" = https://[Dynamics environment ID prefix].[Dynamics environment ID suffix].environment.api.powerplatform.com/sts
- Replace "[Dynamics Environment ID prefix]" with your environment ID (except the last two characters and without dashes)
- Replace "[Dynamics Environment ID suffix]" with the two last characters of the environment ID
- Set "Subject identifier" = component:pluginassembly,thumbprint:[Thumbprint],environment:[Dynamics environment ID]
- Replace "[Thumbprint]" with Thumbprint value copied in step 2
- Replace "[Dynamics environment ID]" with your environment ID (with dashes)
- Set "Name" to whatever you want
- For "Audience", you can keep the default value


- Click on "Add" to create the Federated Credential
Step 6 : Create managed identity record in Dataverse
- Open "XRMToolbox" and open the tool "Plugin Identity Manager" (you can also create it manually if you want, see documentation here)
- Select your plugin assembly (1)
- Click on "Link to New Identity"

- Fill in the following information and click on "Create and Link"
- ApplicationId = "Client ID" value of your managed identity copied in step 1
- TenantId = Your tenant Id (Directory ID in Azure)

Verification
Good news ! You're ready to go and check if everything is working well. To do so:
- Trigger your plugin. In our case, it will be the creation of an account
- Open Plugin Trace Log and check the plugin execution and if the secret is correctly retrieved

Everything is working well — we are now able to connect and retrieve secrets from Key Vault without having to store or manage any credentials in Dataverse.
I hope this step-by-step guide was clear and helped you configure everything easily on your end. If that’s not the case or if any steps need further clarification, please let me know in the comments.
Published on:
Learn moreWe can help you with Dataverse / Dynamics 365 : Azure Managed Identities from Plugins. Step by Step.
If you want help implementing, troubleshooting, or improving this product, contact us and we’ll point you in the right direction.
Related posts
Contact Center Intelligence: where it fits next to Dynamics 365 Contact Center
Microsoft Contact Center Intelligence is generally available. What it adds to an existing contact center, how it relates to Copilot Studio, an...
Inventory data export ends: move to the Power Platform inventory API
Data export (preview) stops sending inventory data after December 1, 2026. How to rebuild the feed with the inventory API, and which fields yo...
Dynamics 365 plugins for Copilot Cowork: an admin setup checklist
The ERP, Sales and Customer Service plugins bring Dynamics 365 data into Copilot Cowork through MCP servers. What to configure, and where it b...
Migrate a Power Pages site to the enhanced data model with PAC CLI
A step-by-step guide to moving a Power Pages site off the adx_ tables with pac pages migrate-datamodel: modes, ALM sequence, remediation and r...
Copilot features retiring from Power Apps and Power Automate
Between November 30 and December 31, 2026, several in-studio Copilot and collaboration features disappear. What goes, what stays and what to u...
Unmanaged developer environments are ending: what to do before December 15
Unmanaged developer environments can no longer be created, are suspended on December 15, 2026 and deleted in January. Who is affected and how ...
Backfill Dataverse prompt columns on existing records
Prompt columns only ran on new or updated rows. A bulk option now fills existing records as a system job: the two settings, the steps and the ...
Reveal a masked Dataverse column with Dataverse.Unmask
A new Power Fx function lets authorised users of a canvas app reveal one masked Dataverse value on demand, while column security stays in char...
Generative pages in model-driven apps: a practical guide
What generative pages are, where they stand in November 2026, the two ways to build them, the code they produce, and the limits to plan for.
Big Update — CRMJetty Dynamics 365 Portal Now Comes with Powerful New Integrations
Enterprise portals are evolving rapidly. They are no longer mere portals through which CRM records can be viewed. Portals are now expected to ...