Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure Storage Static website error - Resource not found or content doesn't exist

To see how static websites work in Azure storage, I created a basic angular app and uploaded the files in dist folder to the static website. But when I try to access the URL, I get a 404 error message that says "The requested content doesn't exist".

Also, I can see that files are present under $web path, but when I click on the file URL <azurestorageurl>/$web/index.html the browser throws an error message "Resource not found".

.enter image description here

like image 987
Thomas Mathew Avatar asked May 09 '19 10:05

Thomas Mathew


3 Answers

The reason you're getting this error is because the ACL of the $web blob container is Private by default.

Please change the ACL to either Blob (recommended) or Container and you should not see this error.

UPDATE

So I reached out to Azure Storage team and brought this question to their attention. They were kind enough to explain the behavior to me.

Essentially if you access the static website's contents through the static website endpoint (e.g. account.z5.web.core.windows.net), there's no need to change the blob container's ACL. Contents should be accessible even if the ACL of $web is Private. Blob container's ACL comes into picture when you access the content through blob storage endpoint (e.g. account.blob.core.windows.net).

like image 114
Gaurav Mantri Avatar answered Nov 05 '22 15:11

Gaurav Mantri


I had quite a similar issue hosting an Angular app on Azure storage account static site, I was getting the below error when reloading the page or navigating by URL. I had to set the Angular Router to use HashLocationStrategy instead of the default strategy. Also, because I am using ASP boilerplate (ASPNetZero) I had to add it to the RootRoutingModule.

This is now working for me on refresh and navigating by changing the URL manually.

Angular Hash Location Strategy

404 Error on webpage

useHash on RootRouting Module

like image 27
Bennie van der Walt Avatar answered Nov 05 '22 14:11

Bennie van der Walt


I also got a similar error and fixed it by adding index.html to the Index document name.

  1. Sign in to the Azure portal to get started.
  2. Locate your storage account and display the account overview.
  3. Select Static website to display the configuration page for static websites.
  4. Select Enabled to enable static website hosting for the storage account.
  5. In the Index document name field, specify a default index page (For example: index.html).
  6. The default index page is displayed when a user navigates to the root of your static website.
  7. In the Error document path field, specify a default error page (For example: 404.html).
  8. The default error page is displayed when a user attempts to navigate to a page that does not exist in your static website.
  9. Click Save.

enter image description here

https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website-how-to?tabs=azure-portal

like image 45
Malith Avatar answered Nov 05 '22 15:11

Malith