Skip to content

Instantly share code, notes, and snippets.

View xenatisch's full-sized avatar

Pouria Hadjibagheri xenatisch

View GitHub Profile
@ChrisRomp
ChrisRomp / script.sh
Created October 7, 2021 23:34
Create Service SAS Token for Azure Storage REST API with Service Principal
# Using Service Principal
tenantid=xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
clientid=xxxxxxxx-xxxx-xxxx-xxxxxxxxxxxx
clientsecret=xxx....xxxx
# Reqeust Bearer Token
token=$(curl -s -X POST -H 'Content-Type: application/x-www-form-urlencoded' \
-d "grant_type=client_credentials&resource=https%3A%2F%2Fmanagement.azure.com%2F&client_id=$clientid&client_secret=$clientsecret" \
"https://login.microsoftonline.com/$tenantid/oauth2/token" | jq -r .access_token)