I have a web site hosted on Azure (http://mike-ward.azurewebsites.net/). I set up an Azure CDN from the Azure portal that points to (references?) my web site. According to the articles and docs I've read, content is only served from the /cdn/ folder (http://az667460.vo.msecnd.net/cdn/images/favicon.ico for example). However, it also seems to serve the dynamic web site stuff by simply referencing the root (http://az667460.vo.msecnd.net/).
Has the policy changed with regard to serving content from other than the /cdn/ folder? If not, what's happening here?
Al website content is now available through the CDN, see these new examples:
http://azure.microsoft.com/en-us/documentation/articles/cdn-websites-with-cdn/
In your site you manage the url, so if a resource is referenced with the CDN url: http://az667460.vo.msecnd.net it will be served from the CDN.
the special /cdn folder isn't required anymore
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 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
I'm creating a react.js based SPA, and I'll have a landing page on launch. The static landing page should have an action button that directs to the full SPA.
For AWS, I realized it's done by simply using S3 and Cloudfront, and Cloudfront also allows routing to custom error page on 404. This means no server code is needed to handle this, and it may free up some server resources?
For Azure, however, I'm unsure of how to mimic such an architecture. I'm guessing I should use Blob storage to store the SPA and the landing page, but how would I be able to mimic the abilities of Cloudfront? Is Azure CDN sufficient? Thanks!
Azure CDN supports to cache Web Apps.
You can build up a simple Azure Web App with your SPA and custom routing rules and the 404 error page. Then create the Azure CDN, configure the Origin type to web app, and select or type your origin domain in the Origin hostname dropdown.
You can refer to https://azure.microsoft.com/en-us/documentation/articles/cdn-create-new-endpoint/ for the detailed steps.
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