Microsoft Secure Tech Accelerator
Apr 03 2024, 07:00 AM - 11:00 AM (PDT)
Microsoft Tech Community

Microsoft Defender EndPoint API's Access Token in Azure DataFactory

Copper Contributor

Hi All,

 

I am trying to pull Defender EndPoint API data through Data Factory pipelines. I am able to generate token and tested in PostMan and Azure DataFactory and all working fine.

 

The only issue I am getting the generation of AcessToken. Currently I am have to use the below script in PowerShell to generate the Access Token:

 

# This script acquires the App Context Token and stores it in the variable $token for later use in the script.
# Paste your Tenant ID, App ID, and App Secret (App key) into the indicated quotes below.

$tenantId = '' ### Paste your tenant ID here
$appId = '' ### Paste your Application ID here
$appSecret = '' ### Paste your Application key here

$sourceAppIdUri = 'https://api.securitycenter.microsoft.com/.default'
$oAuthUri = "https://login.microsoftonline.com/$TenantId/oauth2/token"
$authBody = [Ordered] @{
    scope = "$sourceAppIdUri"
    client_id = "$appId"
    client_secret = "$appSecret"
    grant_type = 'client_credentials'
}
$authResponse = Invoke-RestMethod -Method Post -Uri $oAuthUri -Body $authBody -ErrorAction Stop
$token = $authResponse.access_token
$token

 

 

and then use in my Pipeline to get the data as per the API.

 

Is there any way I can generate access token directly in my ADF pipeline and pass to pipeline. Any idea or guidance's will be appreciated. 

 

Many Thanks

Imran Aslam

0 Replies