How to connect the Microsoft Defender XDR event logs using the API?

Robbe Willeme 0 Reputation points
2024-08-12T14:22:49.1466667+00:00

I'm currently working on a project to fully automate the deployment of a Microsoft Sentinel workspace. I already developed a working PowerShell script that uses the Microsoft.SecurityInsights API to install solutions from the content hub and enable the analytic rules that come with the templates installed by these solutions. The next step in the process is to connect to data connectors, I'm using ARM templates to accomplish this. But I'm having some issues here to connect the Microsoft Defender XDR connector. With the help of the Microsoft documentation, I was able to connect incidents and alerts using an ARM template, but I can't find how to connect the event logs from the various Microsoft Defender XDR products.

With the event logs I mean the following tables:

DeviceInfo

DeviceNetworkInfo

DeviceProcessEvents

DeviceNetworkEvents

DeviceFileEvents

DeviceRegistryEvents

DeviceLogonEvents

DeviceImageLoadEvents

DeviceEvents

DeviceFileCertificateInfo

EmailEvents

EmailUrlInfo

EmailAttachmentInfo

EmailPostDeliveryEvents

UrlClickEvents

CloudAppEvents

IdentityLogonEvents

IdentityQueryEvents

IdentityDirectoryEvents

AlertInfo

AlertEvidence

I discovered that Azure uses this endpoint: "https://api.security.microsoft.com/api/dataexportsettings" to enable these events when I manually configured it. I'm now trying to use this endpoint in a Powershell script to automate this process, but I encountered the following error message when calling the API:

"message": "Application context is not allowed to access this API. Expected user context."

It appears that using an application context to call this API is not possible? So the question is, is there any way to get around this issue and fully automate the process of connecting the event logs without requiring user interaction?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,105 questions
Microsoft Sentinel
Microsoft Sentinel
A scalable, cloud-native solution for security information event management and security orchestration automated response. Previously known as Azure Sentinel.
1,130 questions
0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.