>> Hey friends. Did you know that the Azure CDN
enables you to manipulate HTTP requests at the Edge?
You can add, edit,
delete headers, do URL redirects and rewrites,
and even manipulate caching policies
from millions of incoming HTTP requests.
This reduces the load on the origin and improves
overall application performance by
offloading that processing to the CDN.
Sohamn is here to show me how today on Azure Friday.
[MUSIC]
>> Hey, I'm Scott Hanselman and it's Azure Friday.
I'm here with Sohamn Chatterjee,
and we're going to talk about the Azure CDN.
I've had a lot of folks from CDN on the show before,
and I use it all my slides,
and every time someone brings me something, I go,
"I'm going to go back after The Show and
update my use of the CDN with this new feature."
What new feature have you brought for me?
>> So what we launched recently and is now in
public preview is the Rules Engine at the Edge,
and Rules Engine allows customers to edit
their headers at the edge than do URL redirects,
do URL rewrites, change caching policies,
and the best part of that is,
do all that based on certain match conditions.
Customers today can add up to three match conditions,
and at GA, we would allow customers to
add up to five match conditions per rule.
So by doing this,
customers can then move
all the processing that they might be doing in their applications,
thereby having a lot of scale
and performance hit and move all that over to Azure,
and improve the latency and reduce their cost.
>> It might seem obvious to some, of course,
you work on the CDN and I've
been working in the Web for very long time,
but I've always felt that the CDN or a CDN is
a superpower that you can so easily add to your application.
Just put it in there and think about your URLs,
and then it just does less work.
>> Yeah, absolutely.
>> The Edge in this case is you,
it's the Azure Edge and all the work that's not me.
>> Yeah.
>> The edge is the set of all computers that are not me.
>> Yeah.
>> Yeah. Being able to add a CDN,
for example, with my podcast,
just made things faster.
I had people complaining,
I was in Central US, people in Australia,
people in India, people in Japan,
far away from Central US,
were finding that the images loaded slowly.
>> Yeah.
>> It took me 20 minutes to set up a CDN, it was fantastic.
>> Yeah. Just to add in another example.
Let's take an example of an e-commerce customer.
This e-commerce customer is selling
hundreds of thousands of products in their portal.
Sometimes, some of these products go off the market.
Their sellers are no longer selling.
Let's take the example of iPhone.
They have different versions coming all over the years.
You had iPhone 10,
now you have iPhone 11,
and this customer of ours didn't want to maintain
all these sites that
they had created for a different versions of the phone.
So they said, "Look we want to rewrite
the URLs of the Edge and if somebody types an iPhone 5,
we want them to go to the iPhone main page,
but we don't want to do URL always redirect.
We didn't want customers to know that we are
redirecting to them to somewhere else."
This offers customer significant power
to manage so many pages that they might
have created and now pushed and not
affecting their end customer performance
or impact their Google search ranking.
>> Yeah. That's a really got an important thing to point out,
that as we think about our sites,
we need to remember how HTTP works in a redirect,
a 301 or 302 is not a rewrite.
Rewrites have a very special power.
>> Yeah.
>> I think your demo has a rewrite in it is well.
>> Exactly. Let me just show this demo.
Before the demo, let me just
show some of the rules that I created.
>> Okay.
>> So here is the rules engine,
and prior to creating the CDN endpoint,
what I did is I created a storage origin,
added some images, and I had
this image for Surface Pro and Surface Duo.
Now, if you see the rules,
now, we have a consumer's global rule.
You can set a global rule that works for every incoming request,
and then you can have condition-based rules.
So I have a global rule that says,
"If there is no caching policy,
set the cache to 30 days."
Then I also created
a rewrite rule and I'm going
to just show you the rewrite rule that I created here.
So that the device type not equals mobile,
and you could create multiple types
of conditions and device type is one such condition,
and the request method is GET.
So you're doing a simple request over the Web,
and the URL file name contains laptop.
I want to do a URL rewrite to Surface_Pro.JPEG.
>> So someone is literally asking for
an image and you're going to send them a different image.
It's not going to rewrite the URL,
it's not going to change the URL.
>> Exactly. To demonstrate that,
so let us say we have
a link wherein if customers type Surface_Pro.JPEG,
that would get the image.
On the other hand, if customers type laptops.JPEG,
and there is no file like laptop.JPEG.
>> So the laptop.JPEG does not exist on the storage?
>> It doesn't exist.
>> When you said the origin,
you keep using that word origin,
and origin with a CDN is any thing that's downstream of the CDN?
>> That downstream, exactly.
So if I take laptop.JPEG,
which doesn't exist, and I type that in.
It is doing a URL rewrite and
actually taking me to this particular URL.
So that demonstrates the power of
offloading all these capabilities at the edge
and not having to worry about writing
these complex rules at your downstream origin.
>> It's really important. I've actually written a blog post about
this called URLs are UI.
>> Yeah.
>> If you go out and Google with Bing for URLs are UI,
we work so hard on their CSS and they get all their images,
but then their URLs are ugly or they're mixed case or upper case.
So in this case, here,
without changing the origin,
you've made the URL better-looking.
I see also that you checked the casing of JPEG as well.
>> Yeah, exactly.
>> So this rule that you've got.
If you go back to the rules engine there,
I remember back in the day,
I would have to manipulate
complicated XML files and regular expressions and stuff like this.
But here, I've got a totally interactive rules engine
UI in the portal that goes with these things.
>> Yeah. To add on top of that,
let's say you want to add
some more security and you want to do something like a SAS token.
So you can create a header and add a token to the header,
and at your downstream origin,
you can filter requests that has that particular header value.
So what you can do is,
to protect your origin from, let's say,
some unwanted request or HTP floods,
you could take, look, I'll accept the requests only from CDN.
Previously, you could do based on the CDN IPs,
but that still doesn't
protect you enough because then somebody else could
also create an Azure CDN
and potentially attack you from that endpoint.
Now what you could do is create
a SAS token or any token that you might have at
your downstream origin and add that in rules,
and filter any requests that doesn't have the token.
>> Right.
>> Nobody else is able to look in
and see more token you
are sending because they don't have access to these rules.
>> Rewriting is incredibly powerful,
and I think I see it's just easier to do redirects,
and I think sometimes we as web developers
fall into the I'll just do a redirect.
But a rewrite and an insertion of additional information,
of a new header, of security,
can be hugely helpful stuff.
>> Exactly.
>> There is also other things like X-forwarded.
>> Yeah, expectantly for all the X- headers,
custom headers that you can add or manipulate.
Another thing that I wanted to show you is,
today, customers can manipulate
the caching policy as well based on certain conditions.
So for example, what you could do is,
let's say when you're streaming a video and there
is your manifest file and then you have your segments.
You could say, "Look, for the manifest file,
I will have a different caching policy,
and for the segments, I'll have a different caching policy."
Thereby, if you're doing,
let's say a live stream where
the manifest is changing quite frequently,
you could say, "Look, if it is a manifest,
just cache it for one second.
But if it's a segment,
then cache it for maybe 30 seconds or one minute."
Now, that can give significant performance benefit by
doing caching based on
these match conditions that you have created.
>> When you make these changes,
like I said, in the past,
I would do this in config files and then try to
redeploy them out to my web service.
It's really not the web server's job,
it is the Edge's job.
In this case, it's the CDN's job.
When I make this change, it propagates to the entire world?
>> Yes, it does. All within 10 minutes.
>> Really?
>> Yeah. So you can dumb down your web servers,
make it skinny, save a lot of cost,
and move all these processing at the 138 sites that we have today.
>> So speaking of costs, in the past,
a couple of years ago, when I set up the CDN on my podcast,
I noticed that I was paying for the movement of
my images out to the Edge because you pay
for ingress and you pay for egress really.
You don't pay for ingress rather, pardon me.
So I was basically paying to move data from
Central US out to these, but that's changed.
>> Yes. That's another great news
that we want to share with everybody.
That if you are using Azure CDN from
Microsoft and your downstream origins are in Azure,
Storage, App Service, Web Apps,
App Gateway, no matter where the origin is,
customers will not be paying
any network bandwidth charges from the origin to the CDN edge.
That's completely waved off.
>> That's huge because in the past,
I've always thought about, "Well,
I'm in the West US and I'm moving to East US, where is my CDN?
Where is my origin?"
Not having to think about that is going to
make one less thing for me to worry about.
>> Yeah, exactly.
>> So can I set this up right now?
Can we stop recording and I'll just go
back to the hotel and immediately set this u?
>> Yes, this is live in the Azure portal.
We have the CLI, we have PowerShell,
we have everything enabled for customers.
We will be adding some more rules when we do GA.
So probably we will cover with that
with an additional podcast or a blog.
But today, it's all available for our customers to use.
>> Fantastic, I love new features that I just got for free.
I am learning all about the new rules engine
for Azure CDN and I'm ready to set it up on my own sites,
today, on Azure Friday.
[MUSIC].