A powerful extension library for Dynamics 365/Dataverse client operations that simplifies authentication and service configuration through dependency injection. This library provides enhanced functionality for connecting to and interacting with the Microsoft Dataverse/Dynamics 365 platform.
Install-Package XrmBedrock.Extensions.Client
- Simplified Dependency Injection setup for Dataverse connections
- Built-in token provider implementations for client credentials flow
- Automatic tenant discovery
- Memory-cached token management
- Support for affinity cookies
- Interface-based token provider architecture for custom authentication scenarios
- Configure services in your
Program.cs
orStartup.cs
:
services.Configure<OrganizationServiceOptions>(configuration.GetSection("Dataverse"));
services.AddDataverse();
- Add configuration to your
appsettings.json
:
{
"Dataverse": {
"DataverseUrl": "https://your-org.crm.dynamics.com",
"EnableAffinityCookie": true
},
"DataverseClientId": "your-client-id",
"DataverseClientSecret": "your-client-secret"
}
public class MyService
{
private readonly IOrganizationServiceAsync _service;
public MyService(IOrganizationServiceAsync service)
{
_service = service;
}
public async Task DoSomething()
{
// Use the service to interact with Dataverse
var result = await _service.RetrieveAsync("account", Guid.NewGuid(), new ColumnSet(true));
}
}
- .NET 8.0+
- Microsoft.PowerPlatform.Dataverse.Client (1.1.27 or higher)
- Microsoft.Extensions.DependencyInjection.Abstractions (9.0.1 or higher)
- Valid Dynamics 365/Dataverse environment
- Application registration in Azure AD with appropriate permissions
The library supports client credentials flow out of the box through the ClientCredentialsTokenProvider
. It automatically:
- Discovers tenant ID if not provided
- Manages token lifecycle
- Handles scope building for different Dataverse environments
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
- Clone the repository including submodules:
git clone --recursive https://github.com/yourusername/XrmBedrock.Extensions.Client.git
- Open the solution in Visual Studio 2022 or later
- Restore NuGet packages
- Build the solution
MIT License
Copyright (c) 2024
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Please note: This package extends the functionality of XrmBedrock for client operations.