Authenticate and call Azure App Service with AAD using curl
Get AAD access token
curl -X POST -d 'grant_type=client_credentials&client_id=<APP_ID>&client_secret=<PASSWORD>&resource=https%3A%2F%2Fmanagement.azure.com%2F' https://login.microsoftonline.com/<TENANT_ID>/oauth2/token
Use bearer token in requests
curl -H 'Accept: application/json' -H "Authorization: Bearer <TOKEN>" https://bustroker.com/api/resource
Common curl patterns
POST form data
curl -X POST http://localhost:8080/data -d "param1=value1¶m2=value2"
POST JSON
curl -X POST http://localhost:3000/data -H "Content-Type: application/json" -d '{"key1":"value1", "key2":"value2"}'
POST from file
curl -X POST http://localhost:3000/data -d "@data.txt"
Disable certificate validation
curl -k https://localhost:8080
Format and parse responses
Add newline after output
curl localhost:8080 ;echo
Pretty print JSON
curl localhost:8080 | json_pp
curl localhost:8080 | jq "."
Extract JSON properties with jq
The -r flag outputs raw values without quotes:
curl localhost:8080 | jq -r ".some.property.in_Json.tree"