1

API link: https://learn.microsoft.com/en-us/rest/api/storageservices/list-containers2?tabs=azure-ad#Request

enter image description here

If I try without headers (token), I'm getting the below error:

<?xml version="1.0" encoding="utf-8"?>
<Error>
    <Code>ResourceNotFound</Code>
    <Message>The specified resource does not exist.
RequestId:<guid_id>
Time:2023-06-30T08:03:13.9508663Z</Message>
</Error>

1 Answers1

1

I have reproduced the issue at my environment and able to get the result by using https://myaccount.blob.core.windows.net/?comp=list URL.

I have generated the Bearer token like below, mention the resource name as https://storage.azure.com while you are requesting for a token.

enter image description here

Then called https://myaccount.blob.core.windows.net/?comp=list URL by including x-ms-version: 2017-11-09 in the header along with the Bearer Token.

enter image description here

Please refer ms docs.

Ikhtesam Afrin
  • 897
  • 1
  • 1
  • 6
  • I took the bearer token through Developer Tools in the browser page of Azure Storage Account - https://i.imgur.com/GgHE63m.png and passed the headers same like you - https://i.imgur.com/Bo0xdkB.png - didn't get the result –  Jun 30 '23 at 09:25
  • try to generate the token using Azure AD as documented here in https://learn.microsoft.com/en-us/rest/api/storageservices/authorize-with-azure-active-directory and alike my approach – Ikhtesam Afrin Jun 30 '23 at 09:43
  • I can't create in your approach as we do not have permission to create App registration in our organization. This takes lot of time to get it approval for creation. Any other way to get the bearer token? –  Jun 30 '23 at 09:49
  • @Afrin, What access do you have to get the above result and what is the least RBAC required to get the same? –  Jun 30 '23 at 09:59
  • I having Contributor access – Ikhtesam Afrin Jun 30 '23 at 10:17
  • We too have Contributor access but its customized. We cannot create or see SAS and other few operations in the storage account. –  Jun 30 '23 at 10:42
  • So, do we have any other approach to get the bearer token or can you try with my approach and check –  Jun 30 '23 at 10:43
  • according to MS documentation, you can only send authorized request to storage account in 3 ways- 1. Azure AD(https://learn.microsoft.com/en-us/rest/api/storageservices/authorize-with-azure-active-directory) 2. Shared key(https://learn.microsoft.com/en-us/rest/api/storageservices/authorize-with-shared-key) 3. Delegate access with SAS(https://learn.microsoft.com/en-us/rest/api/storageservices/service-sas-examples). Among all easiest way to get the token is Azure AD. Try to get the required access to create App registration. – Ikhtesam Afrin Jun 30 '23 at 10:57
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/254313/discussion-between-ikhtesam-afrin-and-profiler). – Ikhtesam Afrin Jun 30 '23 at 11:02
  • By trying my approach, we're able to get the result for this [API](https://learn.microsoft.com/en-us/rest/api/storagerp/blob-containers/list?tabs=HTTP) but failing for this [API](https://learn.microsoft.com/en-us/rest/api/storageservices/list-containers2?tabs=azure-ad#Request). –  Jun 30 '23 at 11:02