Search code examples
angulartypescriptazureazure-storageazure-queues

Azure Queue Rest API "Resource Not Found 404"


On an Angular app I am trying to peek at a message in a queue (with multiple messages on it) on Azure using this URL format: https://myaccount.queue.core.windows.net/myqueue/messages?peekonly=true from Peek Messages | Microsoft Docs.

My request: (_http is a variable name for HttpClient)

return this._http.get('https://***.queue.core.windows.net/***/messages?peekonly=true')

It returnsstatus: 404, statusText: "The specified resource does not exist." I have triple checked my request URL and confirmed that CORS is enabled. What am I missing here?


Solution

  • Azure Storage returns 404 Not Found because Storage service is private by default. Plain URL without authorization can't access private resource.

    I recommend you to use Shared access signature to authorize your request.

    Go to Storage account on portal, click Shared access signature blade to generate sas token. Peek message needs (Queue/Object/Read) as the minimal permission. See permission by operation.

    enter image description here

    Then append generated SAS token to your url, note that you need to replace ? with & as it's the second query parameter in url.