I have now successfully setup my static website in a CDN,
Is there a way to specify that index.html is the default document ?
It is a 1 page site I just would like to browse to the root url without having to type /index.html ..
Thank you
Based on your previous question, I am assuming that you have set CDN to map to blob storage. If this is correct, unfortunately it is not possible as of today because Azure Storage does not have a support for default document. This is one of the most requested feature on Azure Feedback - https://feedback.azure.com/forums/217298-storage/suggestions/1180039-support-a-default-blob-for-blob-storage-containers however it is still pending.
If you want, you can create a proper website (instead of having this index.html file in blob storage) and serve that website via CDN. You can find more details about it here: https://azure.microsoft.com/en-in/documentation/articles/cdn-websites-with-cdn/.
Microsoft is working on this. At the moment you have only two possibilities to solve this:
Use CDN: With the premium version of Verizon you can create rules like Redirect Rules
Create an Web-App which act as a proxy and serves/redirects (to) blobs
Using Premium CDN
If you purchased the premium version of Verizon CDN then you can create custom Rewrite rules. You'll find this in the "Advanced Features" section of your CDN endpoint. Once you click on "Manage" you will be redirected outside the portal where you can manage your cdn.
Hier you must create a redirect rule like this:
Note that each change in a rule takes about 5 hours to be activated.
To check if your redirect rule works you can install IIS and activate the URL Rewrite Module. In the Rewrite Module you can test your rules.
Open IIS
Open Url Rewrite Module
Add Rule
Add blank rule
Test Pattern
Please note that if you test your pattern, it must begin with the CDN source path which is a number and your endpointname like /829292/movies.
Sometimes redirect rules causes problems with CDN Purging. You can solve this isssue by adding an if clause in your rule which says that redirect should only be active if it is not the purge agent.
This is now possible with Static websites on Azure Storage
Creating a Static Website
Navigate to your storage account
Select Static Website from the blade and toggle to "enabled"
Once you save, this will create a URL endpoint and also a bucket named $web to host your files
Go to your $web storage container and upload any files you want
Add CDN / Custom Domain
Navigate to your CDN Profile and either Create / Edit your Endpoint
Select 'Custom Origin' and use the 'Origin Hostname' that was created for your static site
Give Azure up to 30 minutes to propagate all the settings
Further Reading
Tutorial: Host a static website on Blob Storage
Tutorial: Use Azure CDN to enable a custom domain with SSL for a static website
Related
I have a blog on WordPress, which I have converted into ASP.NET Core. I am using Azure Service App. As it's a blog, so it has a lot of images, around 4GB of images. For now, I have placed these images in the wwwroot folder. Now I want to transfer them to Blob storage.
But problem is that, when I add images in Blob, I get a different link. I have used Azure CDN and have tried custom domain. But here the issue comes is:
My Service App is running at www..com
I am able to redirect my Blob CDN to images..com .... I have added it in the DNS record
But what I want is to use the same domain www..com for both Blob and Service App, which I tried my best but couldn't achieve. The main reason is I couldn't add multiple CNAME for www.
Why I can't change the link, coz it will affect my blog's SEO, so I can't take that risk. Need help.
Thanks in advance.
what I want is to use the same domain www..com for both Blob and Service App
This is not possible you can use sub-domain on your CDN Endpoint and main domain on service app.
Create CDN.
Add custom sub-domain on CDN Endpoints. For example :- if your domain www.abc.com then you can use cdn.abc.com, image.abc.com, photo.abc.com etc.
More information about Add Cutom Domain on CDN read these Microsoft document.
SO thread on same issue It is not possible to provision same domain for different service
I got a website hosted in go daddy. The domain is using CPANEL.
Made a new Azure Blob Storage with another part of the website.
My current domain is www.mydomain.com, I added a new redirect from market.mydomain.com to Azure Blob. It works.
The problem is that when the redirection happens, the URL changes to azure's blob URL. What im trying to do here is to keep the DNS name pointing to Azure BLOB.
Channel seems to offer no access to CNAME configuration tho.
That is something that could be done in other providers using httaccess. Azure Blob has its own syntax, could not figure out examples on what should be configured to make this work.
What is the default configuration for Azure Blobs to handle redirections keeping the url ?
Thanks !
Following instructions in Static website hosting in Azure Storage and Add a custom domain to your endpoint I've managed to get a static website with a custom domain and https (albeit with a "www" subdomain) via Azure CDN.
However, the blob endpoint ends "/$web/index.html" and that is also required to access the custom domain. So it is of the form:
https://www.<customdomain>.com/$web/index.html
Because of the SPA framework I'm using, that immediately becomes:
https://www.<customdomain>.com/$web/index.html#/home
which is a bit long.
I see instructions for handling https on root custom domains and may give that try if I'm feeling brave. But is there a way to suppress the /$web/index.html part? Currently, if I go to:
https://www.<customdomain>.com
I get:
<Error>
<Code>InvalidQueryParameterValue</Code>
<Message>Value for one of the query parameters specified in the request URI is invalid. RequestId:...</Message>
<QueryParameterName>comp</QueryParameterName>
<QueryParameterValue/>
<Reason/>
</Error>
Instead of mapping your custom domain to regular blob endpoint (e.g. https://mystorageaccount.blob.core.windows.net/), please try to map it to static website endpoint which looks something like https://mystorageaccount.z22.web.core.windows.net.
Once you do that, then you will not need to specify $web in your requests as this endpoint always picks up the content from $web blob container.
You can find the static website endpoint for your storage account in going into Static website section for your storage account in Azure Portal.
I want to to be able to serve a SPA using just the Azure Front Door / and not Azure CDN. Looks like the Front Door provides the caching that the CDN would provide and I can add multiple regional storage accounts to it, making it global at scale.
The problem is, I can't match the path to index.html files. Found this feedback and it looks like this can be solved using the URL rewrite and redirect but couldn't figure out how.
I have /test/ and /test to match with the route below, so it should be matching /test and pointing the request to /test/index.html but this is not working. Can we not do file-based forwards?
This took some time to figure out but here's the solution.
Create Blob Storage(s)
To host the SPA you'll need blob storage accounts in Azure and these storage accounts should be configured to receive static webpage traffic. Navigate to Settings and then Static website in the blob storage settings.
To add content here - navigate to your blob storage again and you should see a container named $web.
Now the $web container is the one that you should put all your static files in, just make sure it's publicly accessible (depending on how you created it, it might not be)
More documentation on how to make a static website using blob storage is here: https://learn.microsoft.com/en-us/azure/storage/blobs/storage-blob-static-website
Get the static website endpoint
Once you enabled the static website and click on the static website blade, it should give you a different endpoint than the regular blob access endpoint - one that supports the static website. Something that looks like: https://somerandomstorageaccount.z8.web.core.windows.net/
Add the static website endpoint(s) to Azure Front Door as back-end
Navigate to your Front Door designer
Navigate to your Back-end pool and add a new entry if you don't have anything.
You should now add this new website endpoint as a back-end to your Azure Front Door. Picture below is the update configuration, but adding it is equally simple, you just add it as a Custom Host back-end type and point it to your blob static website location.
To enable better performance, use multiple storage accounts (from different regions) and add all of those to back-end in your Front Door configuration and turn-on the caching in Front Door.
#Mavi Domates' answer above is great, but doesn't address how to make an SPA route correctly using Blob Storage.
Root Cause: Blob Storage's static website doesn't rewrite URLs and returns back 404 for SPA routes that don't exist exactly in the storage container.
Azure CDN Fix:
Create URL Rewrite rules to forward any zero-length file extensions back to index.html. Link
Azure Front Door Workaround:
(Notice this says Workaround... this is not a fix). On your Blob Storage Static website config, set both the Index document name and Error document path to index.html. This causes any 404 error to be redirected to your SPA entrypoint. Your SPA will work, but any direct navigation to a SPA endpoint will return a 404. (This carries a whole host of other problems, but at least the site works, right?)
I have now successfully setup my static website in a CDN,
Is there a way to specify that index.html is the default document ?
It is a 1 page site I just would like to browse to the root url without having to type /index.html ..
Thank you
Based on your previous question, I am assuming that you have set CDN to map to blob storage. If this is correct, unfortunately it is not possible as of today because Azure Storage does not have a support for default document. This is one of the most requested feature on Azure Feedback - https://feedback.azure.com/forums/217298-storage/suggestions/1180039-support-a-default-blob-for-blob-storage-containers however it is still pending.
If you want, you can create a proper website (instead of having this index.html file in blob storage) and serve that website via CDN. You can find more details about it here: https://azure.microsoft.com/en-in/documentation/articles/cdn-websites-with-cdn/.
Microsoft is working on this. At the moment you have only two possibilities to solve this:
Use CDN: With the premium version of Verizon you can create rules like Redirect Rules
Create an Web-App which act as a proxy and serves/redirects (to) blobs
Using Premium CDN
If you purchased the premium version of Verizon CDN then you can create custom Rewrite rules. You'll find this in the "Advanced Features" section of your CDN endpoint. Once you click on "Manage" you will be redirected outside the portal where you can manage your cdn.
Hier you must create a redirect rule like this:
Note that each change in a rule takes about 5 hours to be activated.
To check if your redirect rule works you can install IIS and activate the URL Rewrite Module. In the Rewrite Module you can test your rules.
Open IIS
Open Url Rewrite Module
Add Rule
Add blank rule
Test Pattern
Please note that if you test your pattern, it must begin with the CDN source path which is a number and your endpointname like /829292/movies.
Sometimes redirect rules causes problems with CDN Purging. You can solve this isssue by adding an if clause in your rule which says that redirect should only be active if it is not the purge agent.
This is now possible with Static websites on Azure Storage
Creating a Static Website
Navigate to your storage account
Select Static Website from the blade and toggle to "enabled"
Once you save, this will create a URL endpoint and also a bucket named $web to host your files
Go to your $web storage container and upload any files you want
Add CDN / Custom Domain
Navigate to your CDN Profile and either Create / Edit your Endpoint
Select 'Custom Origin' and use the 'Origin Hostname' that was created for your static site
Give Azure up to 30 minutes to propagate all the settings
Further Reading
Tutorial: Host a static website on Blob Storage
Tutorial: Use Azure CDN to enable a custom domain with SSL for a static website