Migrate to the new Logs Ingestion API that uses the Data Collection Rule (DCR)

The legacy HTTP Data Collector API is slated for removal on September 14, 2026, requiring migration to the new Logs Ingestion API that uses the Data Collection Rule (DCR). Check Data collector API for more info.
I found the practical documentation a bit limited and felt the urge to write a short blog about this. I will describe what is needed for the new Logs Ingestion API, how it can be used with a Data Collection Rule, and share some code with samples.
What I will use in my scenario:
- A new app registration (aka Service Principal) that needs to have the Reader and Monitoring Metrics Publisher role assigned on the Data Collection Rule . We will use it for data ingestion.
- An Azure DevOps Pipeline to create the Data Collection Rule, set permissions for specified Service Principal (ObjectId) and create the custom table based on gathered properties.
- I will use an Azure Automation Account runbook that will collect all managed devices in Intune and upload their retrieved properties to a Log Analtyics Workspace custom table by using the Data Collection Rule.
Most of my info shared is based on the PowerShell module AzLogDcrIngestPS created by Morten Knudsen (MVP) and his team. Many thanks for the content shared and the clear explanation that comes with it! If you want a deep dive into how it all works, I recommend reading his content.
I made some changes and created my own PowerShell functions that are based on the module mentioned earlier. Below the changes:
- In my scenario it was not necessary to have a Data Collection Endpoint (DCE). I removed the DCE dependency and will ingest the data directly with the Data Collection Rule (DCR).
- Changed the API version (api-version=2024-03-11) used to create the Data Collection Rule, so it will support platform type Direct that is needed to generate endpoints.
- Truncate the name for each table property when the threshold of 60 characters is met, to ensure that the property name is accepted by the Log Ingest API.
- The Reader and Monitoring Metrics Publisher role on the Data Collection Rule are set based on the Service Principal Object ID’s declared in the (permissions.txt).
- Declare custom table properties (tablename.txt) and their corresponding type like string, integer, guid, boolean and real.
- The posibility to remove a Data Collection Rule and it’s corresponding Custom Log Analytics Workspace Table.
| All technical content related to this blog can be found on my GitHub. Be careful and test it first before using it in a production environment! |
Create new custom table instead of migrating the classic custom table
I choose to always create a new custom table instead of migrating to the (classic) custom table that we already have. The current table contains properties that refer to their type, for example _s for a type string. That is not how it will work for the new custom table resulting in all kinds of duplicated properties. Other than that, some properties with type Dynamic are added that are not available in the classic custom table.


Create app registration
The app registration will be used to set up the connection to ingestion log data. I chose to create a new one for this without having any API permissions. It only needs to have the Reader and Monitoring Metrics Publisher role assigned. Based on the least privileged principle I choose to set these role assignments directly on the Data Collection Rule.

Create DCR with custom table in Log Analytics Workspace
The following actions will be done in preparation for the data upload:
- Create the Data Collection Rule in Monitor and a custom table in Log Analytics Workspace.
- Assigning the Reader and Monitoring Metrics Publisher role to the Data Collection Rule.
- Generate some sample data or declare each property that will be used as input for creating the custom table and its properties. Beware of the 60 character limitation for a table name and the type the property will have in the custom table.

The Reader role is used to retrieve the Data Collection Rule and Log Analytics Workspace data, the Monitoring Metrics Publisher role used for uploading the data with the Data Collection Rule to Log Analytics Workspace.


Go to the Data Collection Rule in Monitor and select JSON view. When you created the Data Collection Rule with Platform Type Direct while using API version api-version=2024-03-11 or later, the Endpoint properties should be available.

Those properties will be used when ingesting the log data directly via the Data Collection Rule to the Log Analytics Workspace custom table.
Ingest data with Azure Automation Accounts runbook
In my scenario I am using an Azure Automation Account runbook for ingesting data to Log Analytics Workspace by using the Data Collection Rule we created earlier. It’s not necessary to have a runbook for this, you can also do this with an Azure DevOps pipeline or other automation solution.
See the runbook examples on my GitHub when using the HTTP Data Collector API and the new Log Ingestion API.

When you go to your Log Analytics Workspace, select Logs, select Tables and expand Custom Logs you should see your custom log. Simple run the kusto query and you will find that the data is uploaded via the new Data Collection Rule.

Feel free to use it for your own needs and reach out when you have some questions!

