This guide is the public-safe setup companion for the SharePoint Embedded components in this repo.
It is intentionally narrow. It focuses on the runtime model used here:
- Dataverse custom APIs are the contract.
- A plugin package uses managed identity at runtime.
- Microsoft Graph is called app-only.
- Container type creation and billing stay outside this repo.
This solution uses two application identities.
The owning app is the Microsoft Entra application that owns the SharePoint Embedded container type and performs tenant registration.
The runtime app is the managed identity associated with the Dataverse plugin package. It creates containers, uploads files, lists content, and manages container membership through Microsoft Graph.
Before using the repo, make sure you already have:
- A working managed identity plugin package association in Dataverse.
- An existing SharePoint Embedded container type.
- An owning application that is allowed to register that container type in the target tenant.
- The billing model already decided and configured outside this repo.
The owning app needs the permission required to register the container type in the customer tenant.
FileStorageContainerTypeReg.Selected
The managed identity used by the plugin package needs:
FileStorageContainer.SelectedFiles.ReadWrite.All
The runtime app also needs an application permission grant on the registered container type. In this repo the grant is typically full so the custom APIs can create containers, upload files, and manage membership.
These are separate checks.
- Graph permissions control which SharePoint Embedded APIs the application can request tokens for.
- Container type registration enables the container type in the target tenant.
- Container type application grants allow a specific application to use that registered container type.
If one of those three is missing, the runtime flow will fail.
If you need the earlier foundation work, start with these posts:
- https://www.clive-oldridge.com/azure/2024/10/14/set-up-managed-identity-for-power-platform-plugins.html
- https://www.clive-oldridge.com/azure/2024/11/22/power-platform-plugin-package-managed-identity.html
This repository does not automate container type creation or billing attachment.
It does still automate target-tenant registration of an already existing container type through the runtime access helper script.
Use Microsoft documentation for:
- container type creation
- container type registration prerequisites
- billing configuration
Use the script in this repo once you know these values:
- tenant ID
- owning app ID
- managed identity app ID
- managed identity service principal ID
- container type ID
- owning app client secret
Command:
pwsh ./scripts/GrantManagedIdentitySharePointEmbeddedRuntimeAccess.ps1 \
-TenantId '<tenant-id>' \
-OwningAppId '<owning-app-id>' \
-ManagedIdentityAppId '<managed-identity-app-id>' \
-ManagedIdentityServicePrincipalId '<managed-identity-service-principal-id>' \
-ContainerTypeId '<container-type-id>' \
-OwningAppClientSecret '<client-secret>'That script does two things:
- assigns the Graph application permissions needed by the runtime managed identity
- registers the existing container type in the target tenant and grants the runtime app access to that registration
Build the package:
dotnet build ManagedIdentityPlugin.csprojDeploy it using your normal Dataverse plugin package deployment flow.
pwsh ./scripts/RegisterSharePointEmbeddedCustomApis.ps1 -OrgUrl 'https://your-org.crm.dynamics.com'The local UI is a thin Dataverse client. It never calls Microsoft Graph directly.
$env:DATAVERSE_URL = 'https://your-org.crm.dynamics.com'
node ./local-ui/auth-server.jsThen open http://localhost:3001.
The main building block is co_SharePointEmbeddedCreateContainerWithFile.
That API:
- Creates a SharePoint Embedded container.
- Applies initial container membership.
- Uploads the first file.
- Returns a serialized container snapshot.
This repo recommends one container per file. That keeps the sharing model simple because container membership becomes the boundary for access.
Check all three layers:
- Graph app permissions are assigned.
- Admin consent has been granted where required.
- The runtime app has a container-type application permission grant.
Review SharePoint Embedded billing and tenant registration. Those parts are outside this repo and are common causes of setup drift.
This sample uses the simple PUT /content upload path. Keep uploads within the standard simple-upload limits.
Deploy the latest plugin package first, then rerun scripts/RegisterSharePointEmbeddedCustomApis.ps1.