Using curl to access Azure Storage Container failure

Liz Wendland 0 Reputation points
2023-10-02T18:16:48.3766667+00:00

Hi,

I would like to use the Azure Storage API but the simplest things are not working for me.

curl -i --verbose \

-H "Content-Type: application/x-www-form-urlencoded" \

-d "grant_type=client_credentials&client_id=${APP_ID}&client_secret=${PASSWORD}&resource=https%3A%2F%2Fstorage.azure.com%2F" \

"https://login.microsoftonline.com/${TENANT_ID}/oauth2/token" \

-X POST

This does produce a token (access_token) But when I try to use it:

curl -i --verbose --oauth2-bearer "${access_token}" -H 'x-ms-version: 2019-12-12' \ "https://<mystorageprovider>.blob.core.windows.net/?comp=list"

Results in 400: BAD REQUEST

Any ideas?

Azure Blob Storage
Azure Blob Storage
An Azure service that stores unstructured data in the cloud as blobs.
3,199 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bhanu Ejjagiri 261 Reputation points Microsoft Employee
    2023-10-04T20:50:46.8466667+00:00

    Hi Liz Wendland,
    Thanks for reaching Microsoft Q&A team.

    Based on the error "400: Bad request" - it is a client-side issue or could be due to an incorrect formation of the API call.

    Can you try the below once, and let me know the status.

    curl -i --verbose -H 'x-ms-version: 2019-12-12' \

    "https://<storage-account-name>.blob.core.windows.net/?comp=list" \

    -H "Authorization: Bearer ${access_token}"

    Thanks!


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.