Skip to content

Instantly share code, notes, and snippets.

@damienpontifex
Last active October 5, 2018 06:08
Show Gist options
  • Save damienpontifex/7b9aae2cca1a9b750554cc0f39972c97 to your computer and use it in GitHub Desktop.
Save damienpontifex/7b9aae2cca1a9b750554cc0f39972c97 to your computer and use it in GitHub Desktop.
Access storage by using OAuth token from az cli
#!/bin/bash
# Add your use account as "Storage Blob Data Contributor" RBAC to the Access Control of the storage account
STORAGE_ACCOUNT=<account-name>
STORAGE_ACCESS_TOKEN=$(az account get-access-token --resource https://storage.azure.com/ --query accessToken -o tsv)
curl \
-H "Authorization: Bearer $STORAGE_ACCESS_TOKEN" \
-H "x-ms-version: 2018-03-28" \
https://$STORAGE_ACCOUNT.blob.core.windows.net/?comp=list
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment