i have an Angular web site built and hosted as a static website on in Azure Blob storage.
url looks like this.
https://xxxx.blob.core.windows.net/yyyy/index.html
when i navigate to the url it works fine. but then browser strips out "index.html" and if user refreshes the page url gets invalidated. is there a way to get make a url as such that it opens correctly with or without .html
but then browser strips out "index.html"
No, the browser does not change the URI at all. There is nothing in HTTP that says index.html is implicit in a URI.
Follow these instructions for setting up a static website in Azure Blob storage:
https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website-how-to
https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website
Specifically:
Use the {accountName}.{misc}.web.core.windows.net host-name (you can configure a custom hostname separately). Do not use the blob's direct URIs ({accountName}.blob.core.windows.net)
Your file blobs must be located in a container named $web (which will be mapped to your .web.core.windows.net root).
To specify the default-document (index document), i.e. the name of the blob that will be served when a blob filename is not specified, use the az command-line or Enable-AzStorageStaticWebsite PowerShell to specify --index-document index.html or whatever your website needs (e.g. Default.html, Index.htm, etc).
Related
Just wondering if there is a way to add the "X-Robots-Tag: noindex" tag specifically to PDFs that are served from azure blob storage via an azureedge CDN url. For example -
Blob Storage URL - {subdomain}.blob.core.windows.net/container/test.pdf
CDN URL - {subdomain}.azureedge.net/container/test.pdf
I have read in some places that a way to do this is to add a robots.txt file to the $root container on the blob storage and set "Disallow: *.pdf", however it states that this is not completely reliable and I would rather set the X-Robots-Tag header. Is there a way in azure portal to set it up so that any "*.pdf" file being requested via either the blob or CDN url automatically has this header added to the response?
Many thanks in advance
You can find the CDN rule engine here(I am using Standard Microsoft tier):
Test result:
I want to rewrite URLs for my static API to match the accordingly named files on my blob storage (at the moment static website with $web directory, files are in /api folder), e.g.:
/api/universities --> /api/universities.json
/api/universities/1 --> /api/universities/1.json
I have tried configuring a CDN Rule for it. But I can't get it to work, anyone who can help? Docs are really thin on variables for URL Rewriting with Azure CDN.
I have an Azure CDN profile resource with Premium Verizon tier which allows customization for Rule Engine
Created an endpoint which serves from a URL https://test-cdn1.azureedge.net the content from a storage account which is mapped as the origin to blob container in storage account with origin path pointing to blob container name /blob-container
I am trying to add Rewrite rules (in HTTP Large Object Rules Engine Section) for specific two pages
https://test-cdn1.azureedge.net/main.js URL should rewrite to https://test-cdn1.azureedge.net/js/main.d20ff936.chunk.js
This file is at /blob-container/js/main.d20ff936.chunk.js
https://test-cdn1.azureedge.net/main.css URL should rewrite to https://test-cdn1.azureedge.net/css/main.cb03e.chunk.css
This file is at /blob-container/css/main.cb03e.chunk.css
https://test-cdn1.azureedge.net/vendor.js URL should rewrite to https://test-cdn1.azureedge.net/js/js/1.77a25e9f.chunk.js
This file is at /blob-container/js/js/1.77a25e9f.chunk.js
Here is a screenshot of what I have added at hte momement and is not working.
Also for any other URL request, I wish to give back a plain old empty 404 - Not Found.
Need help, thanks
I know the problem now, solved it by a few tries, it does take some time to get effective though.
The source and destination entries are the mapped folder path to the resource, so in above the three entry would be
Source: blob-container/main.js, Destination: blob-container/js/main.d20ff936.chunk.js
Source: blob-container/main.css, Destination: blob-container/css/main.cb03e.chunk.css
Source: blob-container/vendor.js, Destination: blob-container/js/1.77a25e9f.chunk.js
Still look for a way to return 404 Not Found for all other CDN path URL fetches
I create the the Storage account, CDN Profile and CDN endpoint from powershell. But adding images to the storage account is a manual process after creating all azure components. Now we have the issue that images are not showing up in page. When I try to access the CDN image url directly, I get this error
The requested URI does not represent any resource on the server
But I can access the content directly by using blob storage url to ensure content exist. I tried changing the caching rules , but nothing is working. I have standard verizon cdn profile.
Any suggestions?
Update1 : When I delete the endpoint and recreate the endpoint with all images already loaded in Storage account, everything works fine. Any idea what is the predictable behaviour?
This error happens when you're using a "/" with the root container where the blob is present (sub-folders). for now the "/" are not supported, you can get around it by referencing the root container in the link, ex:
GET https://myaccount.blob.core.windows.net/$root/myphoto
When using the CDN, the format should look like the following:
http://<EndpointName>.azureedge.net/<myPublicContainer>/<BlobName>
There is also a cool tutorial on how to host static sites via blobs and CDN worth checking out: https://blog.lifeishao.com/2017/05/24/serving-your-static-sites-with-azure-blob-and-cdn
Documentation:
You can get more info from these links: https://learn.microsoft.com/en-us/rest/api/storageservices/Working-with-the-Root-Container?redirectedfrom=MSDN
https://learn.microsoft.com/en-us/azure/cdn/cdn-create-a-storage-account-with-cdn
We have a Blob Storage baseurl like this:
https://mycompany.blob.core.windows.net/myprod
.. which has several files and folders inside it.
Now, when at some point an app (not in our control) makes a HTTP request to the above URL, which now returns a 404 not found (this is Blob Storage behavior; accessing the files inside the base url is fine).
And this causes things to blow up in our setup!
So, to workaround this, we want to listen through webhooks the HTTP request made to the baseurl above (only the baseurl, not when HTTP requests are made to files inside it) and return a 200 from an Azure Function.
Is this possible and how?
You cannot intercept calls pointing directly to blob storage. That DNS name (yourname.blob.core.windows.net) routes directly to Azure Blob Storage.
If you specifically need to intercept calls, then you need to route them to a dns name of your app (e.g. yourname.azurewebsites.net or yourname.com mapping to yourname.azurewebsites.net, if it's a web app). At this point, you could redirect to whatever you want (including blob storage URI's).
Note: Any blob URI you redirect to either needs to be public-accessible or have a Shared Access Signature (or policy) for your client app to get to it, otherwise a 404 will result.