Once I`ve changed my custom domain to point to Azure rather than AWS, I just need a way to handle redirect requests for those root-level folders so that they look at the desktop version folder instead. I also want to be able to create other top-level folders in Azure (at the same level as the desktop versions), so I just had to be able to redirect if it was one of those numbered version folders or the “redist” folder. Azure CDN has a rules engine that allows you to redirect traffic that can be used to replace all HTTP traffic to HTTPS. What seemed strange to me here was that I found that it didn`t work unless I also had a regex statement in the URL redirect source that was actually identical to the IF statement (and I had all sorts of problems when they didn`t match exactly). It turns out that you simply do not need the IF statement. URL forwarding is only triggered when the regex finds a match in the source, so I have the IF General condition | Still used in the correct examples in this article. Regex is super powerful and we can use it to redirect all paths that start with number 1 instead of having to write individual rules for each folder (e.g. 1.0, 1.1, 1.2) On the CDN profile page, select the endpoint for which you want to create rules. We strongly recommend that you use an absolute URL. When using a relative URL, Azure CDN URLs may be redirected to an invalid path.
You can use the default rules engine for Azure CDN to customize http request processing. For example, you can use the rules engine to force content delivery to use specific protocols, set a caching policy, or modify an HTTP header. This article describes how to create a rule that automatically redirects users to HTTPS. The problem is that the user is initially redirected to example.com where there is no certificate and a privacy error occurs and the rules are not enforced. The rules can be modified as follows: First, there are two menu options to open the rules engine, HTTP Large and DNA. These are completely different things and if you set up the wrong thing, it won`t do anything. If you are deploying static files from Azure Blob storage, you must configure the Large HTTP Rules Engine. The magic here is that the source is actually a regex statement, parentheses () are used to capture the corresponding values, and .* in regex means that any character matches as many times as you want. So, it will capture everything that comes after verizoncdncam.azureedge.net/1.0. When I say capture, it is stored in a $1 variable, which you can then use in the target. Thanks to Microsoft and Verizon for helping me set up this rule here.
Microsoft also said that adding several additional origins to Azure CDN Endpoint is included in the roadmap. I hope they will release this feature soon so we don`t have to do the redirect. In addition, Azure CDN Premium costs 2 times more than Standard. If we extend this regex a little more, we can manage all version folders by matching any path that starts with the numbers 1 to 3 and is redirected to the desktop publish path. The Rules Engine pane opens and displays a list of available global rules. Let`s look at creating some rules and explain in more detail what we can specify in the source and destination to achieve some common redirection scenarios. Finally, here is the regex that redirects all version folders and redist folder from the root path to the desktop publish path in a single rule. Azure Blob Storage itself doesn`t include a mechanism for managing URL redirection, but I wanted to place a CDN in front of Azure Storage for better performance in deploying files globally, and I found that Azure CDN had the ability to perform redirection. When you create an Azure CDN, you can choose from multiple types of Azure CDN providers/products: You can choose from multiple compliance conditions in the Add Condition drop-down list. For a detailed list of game conditions, see Compliance Requirements in the Standard Rules Engine. Once recorded, it can take up to 10 minutes to propagate to all CDN points of presence.
But then any HTTP traffic should be redirected successfully. [! NOTE] The rules engine described in this article is only available for Microsoft Azure CDN. Examine the request URL and URL in the address bar. Azure CDN redirected the request to another endpoint based on the rule. This is what we`ll use in all the sample rules to reach redirects, but there are some things you need to know in advance. [! IMPORTANT] The order in which multiple rules are listed affects how rules are handled. The actions specified in a rule can be replaced by a following rule. As mentioned above, only Microsoft Cdn and Verizon Premium offers can perform URL redirection. I started with the Microsoft CDN, but found that it didn`t have support for regex template matching of the incoming URL path I`d need to recognize all those version folders (without having to configure a lot of rules for the exact folder names – and the images above are abbreviated, there are a lot more version folders!). So I switched to the Verizon Premium CDN offering. This will only verizoncdncam.azureedge.net/desktop-releases/1.0/widget-setup.exe the URL verizoncdncam.azureedge.net/1.0/widget configuration.exe I assumed that since I wanted to identify a certain pattern in the URL to be redirected (for example, those that start with 7th or 8th), I should use an IF clause and match it on the URL path.
Then, if I find a match, I would implement a function to perform a simple URL redirection of the entire path. It didn`t work out as I expected, especially if I set up multiple rules. This article describes how to configure and use the default rules engine for Azure Content Delivery Network (Azure CDN). I created a static page using Azure Storage and CDN with the Microsoft Standard tier. I have to redirect the user from example.com to www.example.com (with www), but my rules don`t seem to work – only the http to https redirect rule works, so when I type example.com I`m redirected to example.com the Verizon Premium Rules Engine documentation really lacks examples on how to set up redirects. You can create multiple redirect rules in the same IF condition. Here, I also redirect a request from /latest-release to /desktop-releases/3.0/widget-setup.exe I had existing links to files in AWS that use the HTTP schema, so I wanted to redirect them to use HTTPS instead. This can be implemented as a new rule, and I set it as the first rule because I want it to be applied to all traffic before other rules are evaluated. This time we use the request | Instruct the IF condition of the schema to match only traffic that uses HTTP, and then use a URL redirection rule to match any path, and then specify in the destination that HTTPS should be used. Note that I used another %(host) variable provided by the rules engine instead of hard-coding the incoming hostname (verizoncdncam.azureedge.net). This is a regex statement that specifies which requests are redirected. Oddly enough, it needs to start with an ID that Verizon CDN uses internally.
I do not quite understand that point, but here is where you get it. After digging here and there, we realized that Azure CDN Premium can perform a redirection based on the given condition, which can perform a similar task to AWS CloudFront. This indicates where users are redirected when the regex source matches. Now, the user will be redirected from example.com to www.example.com, but if someone enters example.com, they will still see an error. The solution to this might be to purchase an SSL certificate, as Azure CDN Managed does not allow SSL for the Apex domain. Here are the steps to get the same in Azure CDN: Both options are added in custom domains for this cdn: In my scenario, I had an Amazon Web Services S3 (file store) that included installation files for different versions of a product.