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".
.
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
).
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
I also got a similar error and fixed it by adding index.html to the Index document name
.
https://docs.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website-how-to?tabs=azure-portal
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With