2

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?

kg123
  • 395
  • 2
  • 4
  • 16

1 Answers1

2

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.

Jerry Liu
  • 17,282
  • 4
  • 40
  • 61
  • Thanks very much @JerryLiu. I went through that process, enabled all permissions, and appended the sas token to the end of the url with `&`. I got a `403 (This request is not authorized to perform this operation.)`. I then tried some other basic requests from the documentation and got the same error. Any ideas? – kg123 Oct 12 '18 at 16:19
  • @kg123 Have you tried the url with sas directly in browser? Two potential causes 1.the token may have expired. 2. url encoding issue in code – Jerry Liu Oct 12 '18 at 16:51
  • I have tried it in the browser and it have me the same error. I tried a new key to confirm expiration wasn't the issue. Also, I already have successful calls in my code for a blob in the same storage account as the queue I'm trying to access. So, I dont think the encoding would be an issue. – kg123 Oct 12 '18 at 17:06
  • forgot to mention @JerryLiu – kg123 Oct 12 '18 at 17:33
  • @kg123 Have a look at this [post](https://stackoverflow.com/questions/22828279/403-error-in-production-from-windowsazure-storage/22829215#22829215). – Jerry Liu Oct 12 '18 at 17:49
  • Aligned my computer timezone with the server and storage account timezone, as well as the timezone option in creating a SAS token. Getting the same error. Opened a support request with Azure. I'll post what I find out @JerryLiu – kg123 Oct 12 '18 at 18:13
  • 2
    The solution was putting the SAS token before the message operation options like `https://myaccount.queue.core.windows.net/myqueue/messages?SASTOKEN&peekonly=true`. @JerryLiu – kg123 Oct 16 '18 at 15:18
  • @kg123 Good to know you conquered it, a little strange that I don't need to put the token at the first parameter to access. – Jerry Liu Oct 16 '18 at 15:22