>> Hey folks. You may know that Azure functions
enables you to build highly scalable APIs,
but now Azure API management has
a new serverless friendly billing model.
It scales on demand and bills for
execution instead of a per hour fixed scale model.
Mike Bezinsky is here to show us
how it works today on Azure Friday.
[MUSIC].
>> Hey friends, I'm Scott Hanselman,
it's another episode of Azure Friday.
I'm here with Mike Bezinsky,
we're talking about Azure API management. How are you sir?
>> Very good. Thanks for having me Scott.
>> My pleasure.
>> So, we'll start with
a brief introduction of what API measurement is.
Its product and measure that how suitable integrates
other APIs from other services in one centralized location,
where then you can manage those APIs, you can do monitoring,
you can introduced new versions,
you can imply security fraught in crushing policies.
All of that in one centralized place.
We have been offering it in
a few tears based on a fixed multicast,
but what we haven't been seen in the recent years,
in the IT and software world is
this dramatic shift from
magnetic services to microservices and serverless architectures.
So, we have just come up with a new tear that fully enables all of
Azure customers of Azure users to leverage
the servers possibilities of our Microsoft platform.
The tier is called API management consumption tier,
and as you can see on this side,
it is fully based on the serverless properties.
So, in this case,
API management rounds totally on a shirt infrastructure,
meaning that it allows for
an instant provisioning and huge scalability.
You can say scale from zero to a hero and back to zero.
It also allows for proper billing.
So, you actually pay per action,
your purpose usage of APIs.
So, you don't pay a fixed monthly cost
of your API management instance.
So, the new tear it council a few limitations.
It has a curated feature set, so,
it does not allow you to have a website and
automatically generated developer portal
within the documentation for APIs,
but it does have a few other features.
So, what I have prepared for today,
I have implemented store,
a simple store up that runs completely on a service architecture,
it's called serverless pets.
So, in this case,
my store is implemented with
two function apps with a few functions,
and then those functions apps
are actually fronted with API management.
So, all the traffic happens through
API management to the function apps.
It's called serverless pets because it sets accessories for pets.
So, let me demonstrate that to you.
>> Okay.
>> Here we have the Azure portal,
I have prepared a resource group with a few resources in it.
So, I have the API management instance serverless pets.
I also have two function apps with storage account,
and I have application insights,
and Azure Redis Cache,
all in one resource group.
>> So, you have no Virtual Machines,
no app services is nothing?
>> Right. It's all serverless,
no servers, no infrastructure around it.
>> Wow!
>> So, let's take a look at my API management instance.
As you can see, it runs on the consumption tier.
So, datacenter greatest for service architectures.
When I go to my API's,
I have already imported one of my function app
into one of the APIs called serverless pets.
This has a couple of API methods in it like ordering products,
as you could see in the previous architecture side.
What I'm going to do now is adapt to
import my under function app into
the same API so that all of my store
API is under one common umbrella.
So, it shows all the properties,
it shows even the husband.
So, I'm clicking "Import," and then I can
select to import the function app,
it's just simple as that.
So, let me select my function app.
This is the serverless pets warehouse
which has the inventory methods in it.
So, what happens behind the scenes as
we are conducting this function app and
we are fetching the use of
functions with which to be traversing it,
and then once we select the functions that we want to import,
API management automatically creates a key,
a host in the function app and pulls
the same host key in API management.
So, all the permutation happens exclusively with
this new functional app host key.
So, I've already imported my function app,
and as you can see I now have the inventory methods as well.
Let me drill down to the products method.
So, to do that, I'm going to the "Test
App," and I'm setting the products method.
This method is supposed to trigger
my function app and return a list of products in my store.
So, as you can see I'm getting 200 okay,
so it means it's working.
I'm getting a list of products
that are saving my star one of them for example
being a diamond studded hair brush for poodle from $19,000.
Unfortunately, this hair brush does
not come with API management instance.
>> Okay.
>> But there are way cooler things that do.
>> All right.
>> So, if I go back to my API management instance,
there is a very cool new feature that we have just added
because the consumption theory does not count a bit in cash,
we have implemented a very innovative new feature
that allows you to plug
in your own external cache
whether it hosts it on Azure or somewhere else.
So, what you can see here,
I already added my Redis cache,
which I showed to you a few minutes before.
So, to activate it,
I'm going back to my API.
Let me go back to my Products method.
So, this is a pretty static method.
Every time I call it,
it triggers the function app and return the same list of products.
So, there is actually no reason to
trigger my function app every time.
So, what I'm going to do is,
I'm going to add the caches with policy,
we've just three clicks.
So, I'll click on "Add policy," then there is a couple of
policies that can go to my caching policy,
and they specify the time to leave to one hour,
3,600 seconds, and then click "Save."
Just three clicks and I have
implemented a caching policy in my API.
So, now has going see if my caching on policy works.
So, what I'm going to do is I'm going to go back to my test tab,
select the "Products operation," and then execute it again.
Then I'm going to the trace tab which allows me
to trace all of my API call.
As you can see, it now says that "Cache lookup resulted in a hit,"
meaning that my caching and
their response is already cached in my API management instance.
So, I don't have to execute my function app,
which allows me to reduce the latency of an API call,
it also allows me to save
some money because I'm not paying for that execution.
So, that's a very cool feature.
So, if I go back to my dashboard,
let's take a look at that creation instance now.
In application insights, I can see
the whole overview of my function
apps as far as the API management instance.
So, if I built the application map,
which sometimes take a few seconds to load,
I have my function app here on the right,
and I also have my API management instance.
What worries me is
this red ring around my API management instance,
so, let's investigate what's happening here.
This actually pretty insane,
I'm getting 20,000 failed request in my API management instance,
which is true, it's not what I expect.
So, I want to drill down and investigate this failers.
So, as you can see now, I have
only two failed HTTP status response codes.
One of them is 401 with
12.5 percent failed requests, 401 means unauthorized.
So, someone did their or a malicious agent
is trying to call my API without a subscription key,
or with the wrong subscription key,
and they are trends to breach my API.
>> Okay.
>> So, what happens is these calls are rejected in API management.
They are not going further to the functional.
>> Oh! Interesting. So, from a consumption perspective,
you're stopping at API management,
and the function app doesn't have to deal with an unauthorized?
>> Exactly right. Then, there's
another failed requests which is four to nine.
meaning too many requests.
So, before coming here,
I have implemented a throttling policy in my API management
instance,and I set throttling to 10 requests per half a minute.
So, if I get more requests than that,
they being rejected with four to nine HTTP the status code.
So, that allows me to protect
my Backend services from abusive actors.
To one last feature that they would like to
show is the Live Metric stream.
So, it allows me to actually monitor my store live.
So, to demonstrate that,
I'm going to issue a few 100 calls to my API,
and then as you can see,
I'm a seeing this traffic live in application insights.
So, that's very powerful.
My test is configured to issue above
requests that are unauthorized and request that should succeed,
and these are actually reflected in my live charts.
So, this is a very powerful tool.
So, that's what I had to show today.
>> It's pretty amazing how people can snap these things
together that in the past they would have had to write themselves.
>> That's okay.
>> If you have a function and maybe it
calls a SQL Server or a Cosmos DB,
or even just a JSON object in a table,
you have to ask yourself, where does the caching code go?
Where does the authorization code go?
Where are the cross-cutting concerns?
API management provides those for you.
>> Exactly, API management is like
a central piece to almost every cloud architecture,
just because it does APIs which are the common protocol
for communication between the services and users.
>> Exactly. It also had me thinking about
that different teams make different microservices,
but you want to put a face or a front on it that makes it
look like those microservices are a cohesive version to API,
and API management can give you that face.
>> Absolutely. So, API management has many more features.
I highly encourage all of you to go look it up.
We have a very comprehensive documentation that
allows you to get started in just five minutes.
We even prepared as simple Backend service that that you can
just call and get sample responses from it.
>> Fantastic. I'm learning all about one of
my favorite things in Azure, Azure API management,
be sure to check out the other Azure API management videos
that we have here on Azure Friday,
and of course the extensive documentation.
I'm learning all about Azure API management and
the new consumption tier for
serverless architecture today on Azure Friday.
>> Thank you.
[MUSIC]