How can I make a query request for Azure Data Explorer (Kusto) using curl?

Viewed 107

I'm trying to understand how to use Kusto (data explorer) via PHP and part it is the authentication.

I created the service-account, gave it "impersonation" for Azure Data Explorer on active directory.

But when I try to get a token for it (httpie instead of curl, but you get the idea):

http https://login.microsoftonline.com/$AZURE_TENANT_ID/oauth2/token\
   client_id=$AZURE_CLIENT_ID \
   grant_type=client_credentials \
   client_secret=$AZURE_CLIENT_SECRET \
   scope=https://myclustername.brazilsouth.kusto.windows.net/.default

I get a token with a

 "aud": "00000002-0000-0000-c000-000000000000"

instead of the expected

 "aud": "https://myclustername.brazilsouth.kusto.windows.net"

This gives me the correct (with correct aud) token:

az login --service-principal -u $AZURE_CLIENT_ID -p $AZURE_CLIENT_SECRET --tenant $AZURE_TENANT_ID --allow-no-subscriptions
az account get-access-token --resource myclustername.brazilsouth.kusto.windows.net --query accessToken --output tsv

I can correctly make requests using that token and get the results.

Does anyone know what I'm missing here? Do I need to do some sort of token exchange to access Azure Data Explorer service via curl?

1 Answers
Related