
In Microsoft Dynamics 365, auditing helps you keep track of what’s happening inside your CRM. Every time a record is created, updated, or deleted, the system records this activity as an audit log.
While this is great for transparency and troubleshooting, there’s a challenge – the platform doesn’t directly show how much storage each entity or partition is using for these audit logs.
For administrators and developers, this lack of visibility can make it difficult to manage storage efficiently. Over time, audit logs can grow large, and organizations might suddenly find themselves hitting storage limits.
To address this, Microsoft introduced the GetAuditStorageDetails Action in Dataverse.
This feature provides a detailed breakdown of your audit log storage usage by offering insights such as:
In short, this action helps administrators and system maintainers analyze and optimize audit storage usage, making planning and monitoring far easier.
In this blog, we’ll demonstrate how to call this action using a C# console application, showing both the request structure and expected response.
The GetAuditStorageDetails Action is a Dataverse API function that provides insights into how audit data is stored.
It helps you identify which entities or partitions consume the most storage, enabling administrators to better control audit data retention and cleanup.
Start by creating a simple C# console application in Visual Studio.
Make sure you reference the Microsoft.PowerPlatform.Dataverse.Client package to use the ServiceClient class.
Step 2: Implement the Code
Below is an example method that retrieves audit storage details using the GetAuditStorageDetails action:
private static void GetAuditDetails(ServiceClient value)
{
try
{
// Create a new request to get audit storage details
var request = new OrganizationRequest("GetAuditStorageDetails");
// Execute the request using IOrganizationService
var response = value.Execute(request);
// Retrieve the "Result" from the response, which contains audit storage info
var result = response.Results["Result"];
// Check if the result is not null
if (result != null)
{
// Use reflection to get the AuditStorageDetails property from the Result object
var auditStorageDetailsProp = result.GetType().GetProperty("AuditStorageDetails");
if (auditStorageDetailsProp != null)
{
// Get the value of the AuditStorageDetails property
var auditStorageDetailsValue = auditStorageDetailsProp.GetValue(result);
// Cast the value to IDictionary for iteration (AuditStorageDetails is a dictionary)
IDictionary auditStorageDict = (IDictionary)auditStorageDetailsValue;
// Log the total number of audit partitions
Console.WriteLine($"AuditStorageDetails contains {auditStorageDict.Count} entries");
// Loop through each entry in the AuditStorageDetails dictionary
foreach (DictionaryEntry entry in auditStorageDict)
{
// Log the key (usually the partition name or entity type)
Console.WriteLine($"--- Key: {entry.Key} ---");
// Get the value (AuditStorageDetails object) for this key
var auditDetail = entry.Value;
if (auditDetail != null)
{
// Get all properties of the AuditStorageDetails object
var props = auditDetail.GetType().GetProperties();
// Loop through each property and log its name and value
foreach (var prop in props)
{
var propValue = prop.GetValue(auditDetail);
Console.WriteLine($"{prop.Name}: {propValue}");
}
}
else
{
// Log if the auditDetail value is null
Console.WriteLine("Value is null");
}
// Separator for readability
Console.WriteLine("---------------------------------------------");
}
}
else
{
// Log if AuditStorageDetails property is not found
// Utility.SetTrace("AuditStorageDetails property not found in result.", workflowConfig, ref traceLog);
}
}
}
catch (Exception ex)
{
throw new Exception(ex.Message);
}
}
Step 3: Execute and Review Output
When you execute the code, it retrieves and displays audit storage information for each partition or entity.
Output

Note: When you first trigger the GetAuditStorageDetails Action, it may take some time to process — especially for large environments.
The Status field helps track progress:
Pending → The system is still compiling audit data.
Completed → The data is ready, and AuditStorageDetails contains the breakdown.
Once complete, the console output lists each entity or partition and its respective audit storage metrics.
FAQs
Understanding how audit data is stored is crucial for maintaining a healthy and optimized Dynamics 365 environment.
By using the GetAuditStorageDetails action, developers and administrators can:
This method not only simplifies monitoring and troubleshooting, but also ensures that organizations maintain a balanced and efficient auditing process in the long run.
The post How to View Audit Storage by Entity in Dynamics 365 Using the GetAuditStorageDetails Action first appeared on Microsoft Dynamics 365 CRM Tips and Tricks.






