Skip to content

Instantly share code, notes, and snippets.

@ToroNZ
Created July 14, 2022 23:32
Show Gist options
  • Save ToroNZ/f77fb1f9c3ffe3f0d8be51bb503f5717 to your computer and use it in GitHub Desktop.
Save ToroNZ/f77fb1f9c3ffe3f0d8be51bb503f5717 to your computer and use it in GitHub Desktop.
Access Azure resources from managed identities
#Get Token using Azure scope
curl -s 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fmanagement.azure.com%2F' -H Metadata:true
#Get Token using storage scope
curl 'http://169.254.169.254/metadata/identity/oauth2/token?api-version=2018-02-01&resource=https%3A%2F%2Fstorage.azure.com%2F' -H Metadata:true -s
#^Could use jq if/when available
# Store the token in variable
ACCESS_TOKEN="RESPONSE_TOKEN"
#Curl blob
curl -vv -XGET -H "Authorization: Bearer ${ACCESS_TOKEN}" -H "x-ms-version: 2017-11-09" -H "Content-type: application/json" "https://STG-ACCOUNT.blob.core.windows.net/container/toro.txt"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment