3.10 Event Grid Demo

Video Activity
Join over 3 million cybersecurity professionals advancing their career
Sign up with
Required fields are marked with an *
or

Already have an account? Sign In »

Time
18 hours 43 minutes
Difficulty
Intermediate
CEU/CPE
9
Video Transcription
00:00
>> Welcome back. In this episode,
00:00
we're going to finish up our serverless compute
00:00
concepts by taking a look at an Event Grid demo.
00:00
My objective includes going out to the Azure portal.
00:00
We're going to take a look how we can integrate
00:00
Event Grid into a logic app.
00:00
Remember, Event Grid is the glue between
00:00
event sources and event handlers inside of Azure.
00:00
In our case, we're going to take an event source
00:00
such as a virtual machine and
00:00
we're going to combine it with a Logic App
00:00
to perform a function like sending an e-mail.
00:00
Let's jump out to the Azure portal
00:00
and see what this looks like.
00:00
Back in our Azure portal,
00:00
we're going to walk through a demo of how we can
00:00
incorporate Event Grid into a Logic App.
00:00
Now, I've already got the Logic App built,
00:00
so let's go in and take a look at
00:00
the designer to see how it is built.
00:00
Now, if you remember, our logic apps
00:00
have to be triggered by something.
00:00
Something has to occur,
00:00
whether data is updated,
00:00
something's posted, maybe to a SharePoint list.
00:00
Something has to trigger the Logic App to occur.
00:00
The first trigger I've chosen
00:00
here is when a resource event occurs,
00:00
and this resource event comes out of Azure Event Grid.
00:00
Remember Azure Event Grid is ingesting all of
00:00
these changes that are occurring inside our Azure Tenant.
00:00
If we expand this out, we can take a look at
00:00
some of the properties we have set on it.
00:00
First, I've chosen a subscription that I want to monitor,
00:00
as well as the resource type.
00:00
Here, I'm looking at resource groups.
00:00
After that, I have to choose
00:00
a resource group name that I want to monitor.
00:00
What this Event Grid Trigger is
00:00
doing is looking at all the actions that are
00:00
coming out of our resource group and
00:00
the resources in it for serverless demo RG.
00:00
Our action after that is called a condition,
00:00
and I've renamed that condition from
00:00
its generic name to VM and a resource group has changed.
00:00
Let's take a look at its actions.
00:00
What we're looking at here is the information that
00:00
occurs in the Event Grid when something happens.
00:00
What I'm going to do is,
00:00
I'm going to delete this condition
00:00
and show you how re-created it,
00:00
so you understand what we're looking at.
00:00
I'm going to go over to expression
00:00
and paste it in this expression.
00:00
What we're looking at is the triggerBody.
00:00
This is the event we have right above this titled.
00:00
When a resource event occurs,
00:00
we're looking in its data and we're looking
00:00
for a field called operationName.
00:00
Now after we get this Logic App to fire,
00:00
I'll show you where we got this information from.
00:00
But for right now, just understand that we're looking for
00:00
an operationName based off the Event Grid Trigger.
00:00
What we're doing inside of that trigger
00:00
is we're comparing that operationName and we're
00:00
looking for an exact match
00:00
to Microsoft.Compute/virtualMachines/write.
00:00
We're looking for write operations
00:00
against our virtual machine.
00:00
When we see a match for that under this if true option,
00:00
I've added an action to send an e-mail.
00:00
In this send an e-mail action,
00:00
I've built out how I want the e-mail to look.
00:00
In the body of the e-mail, I've added several keys here,
00:00
and their values are based off
00:00
data coming out of the Event Grid.
00:00
Let's take a look at what other options we have.
00:00
We've already got the Event Time and the
00:00
Event Type as well as the ID.
00:00
We've already put the Subject of
00:00
the event into the Subject of
00:00
the e-mail and then we have
00:00
the Topic name that fired the event.
00:00
This is the dynamic content we have
00:00
available that's coming out of the event source,
00:00
in this case, our resource group.
00:00
We don't have any false actions if
00:00
it doesn't match what we're looking for.
00:00
Backup in this condition,
00:00
basically writing and making a change to
00:00
a virtual machine that we don't
00:00
care if anything happens or not.
00:00
Let's hop over to our virtual machine so we can
00:00
see how a change on a virtual machine and
00:00
that resource group that we're targeting will trigger
00:00
this Logic App through
00:00
the Event Grid and send us an e-mail.
00:00
One way to make a change is to change
00:00
the hardware profile of the virtual machine.
00:00
Right now, we're on a standard
00:00
B1s and I'm going to change it to a B2s.
00:00
If you change the size of
00:00
a virtual machine while it's running,
00:00
it will need to shut down the virtual machine,
00:00
make the change and then restart it.
00:00
Our virtual machine is done being resized.
00:00
Let's go back to our logic app.
00:00
On our overview page,
00:00
we can see a summary.
00:00
Here, we can see the runs history of
00:00
every time this Logic App has been triggered.
00:00
As you can see, it's happening quite a bit because we're
00:00
looking at any change inside of that resource group.
00:00
But we're only going to send an e-mail when
00:00
the virtual machine has a right action taken against it.
00:00
Let's go look at our latest triggered run history.
00:00
Let me zoom out here just
00:00
a little bit so we can fit it all on the screen.
00:00
It just so happens that this last run
00:00
in our run history is the one that we're looking for.
00:00
You can see that our expression result is true,
00:00
which means the condition we put in there evaluated to
00:00
true and this green
00:00
checkmark right here shows that it send an e-mail.
00:00
Let's go check our inbox.
00:00
Here, we have a couple of e-mails that
00:00
have gone through for
00:00
each time we had
00:00
a right success onto our virtual machine.
00:00
You can see in the e-mail,
00:00
it's configured with the properties that we
00:00
described in the send an e-mail action.
00:00
We have the Resource,
00:00
the Event Type, the Event ID,
00:00
and the Time that it occurred.
00:00
Let's go back to our logic app.
00:00
If we go back to when a resource event occurs,
00:00
if we look at our resource event
00:00
trigger out of our Event Grid,
00:00
we can look at the raw output
00:00
that came out of the Event Grid.
00:00
We scroll down to the bottom.
00:00
We're going to see an operationName here
00:00
for Microsoft.Compute/virtualMachines/write.
00:00
Now let me go back to the Logic App Designer.
00:00
Inside of our condition,
00:00
that's exactly what we're looking for.
00:00
What this condition is doing is it's
00:00
parsing that JSON response looking inside
00:00
a data operationName and we're
00:00
matching exactly on this value over here on the right.
00:00
Out of the Event Grid,
00:00
when that condition is matched out of the output,
00:00
is when we actually go down to this,
00:00
if true, and send an e-mail.
00:00
I hope that makes sense.
00:00
I'm just trying to show that there is a bunch of
00:00
data that is coming out of our Event Grid.
00:00
In this case, we are basing it off
00:00
an operationName of where we're
00:00
writing to virtual machines.
00:00
When that condition is true,
00:00
we're going to go in and send an e-mail.
00:00
Now, sending an e-mail is a little bit of a minor action,
00:00
but you could do additional things.
00:00
For instance, like we talked about in the slides,
00:00
you could monitor the Event Grid for when
00:00
a new virtual machine is
00:00
made and inside of your Logic App,
00:00
go and create an action of running
00:00
an Azure runbook inside of
00:00
Azure Automation to configure that virtual machine.
00:00
The idea is we can take multiple serverless compute
00:00
options and chain them
00:00
together to do lots of really cool things.
00:00
In this case, we took something out of the Event Grid,
00:00
put it into our Logic App,
00:00
and ran an action against it.
00:00
That does it for our demo,
00:00
hope all that is really helpful and maybe
00:00
conceptualizing some of these ideas.
00:00
Let's go back to the slides and wrap this up.
00:00
Like I said, that does it for
00:00
our serverless compute concepts.
00:00
Coming up next, we're going to take a look at
00:00
some advanced networking concepts with
00:00
an introduction to Application Load Balancing.
00:00
See you in the next episode.
Up Next