The course is part of these learning paths
Azure Logic Apps
Learn Configuring Serverless Computing on Azure with this course. Allowing cloud engineers to leverage serverless technologies to deploy solutions is vital to any enterprise. In this course you will learn to do this without the hassle of maintaining actual servers or virtual machines. In addition, this course provides a true insight into the creation of a 'Function App'. This is an interesting feature because creating a basic Function App is actually deceptively easy. Develop your skills with this course by learning exactly how to create a basic Function App.
We would recommend having an intermediate understanding of MS Azure along with knowledge of its principles and product offerings before starting, ensuring that you yield the maximum potential of the training content. This Azure training content is made up of 11 comprehensive lectures along with an overview and summary.
This course can also be found in the following Learning Paths:
- AZ-100 Exam Preparation: Microsoft Azure Infrastructure and Deployment
- AZ-101 Exam Preparation: Microsoft Azure Integration and Security
- Learn what serverless computing is and what it offers
- You’ll learn how to create an Azure Function in the Azure Portal and how to manage Azure Function App settings
- Learn how to create an automated workflow with Azure Logic Apps
- Learn about Event Grid and how to use it to monitor for changes in an Azure subscription
- Learn what Azure Service Bus is and how to use it
- IT professionals who are interested in earning Azure certification
- IT professionals who need to deploy and configure serverless resources in Azure
- Access to an Azure tenant to follow along with demos
- Moderate understanding of Azure
Related Training Content
In this demonstration, we're going to create an automated Logic App workflow. And what it's going to do is it's going to monitor our resource group for changes that happen to a particular virtual machine. Essentially what's going to happen is any changes that are made are going to be published to the Azure Event Grid which we registered with the subscription in the previous demonstration. The Event Grid is then going to push those events to our Logic App. Our Logic App will, in turn, send us an email telling us that there's been a change to a virtual machine in our resource group. So essentially what we're going to do is create a Logic App that monitors events that are coming from the Event Grid. We'll then add a condition that specifically checks for changes to virtual machines. We'll then configure the Logic App to send us an email when it sees those virtual machine changes. So to get started we need to create a Logic App. Now if you remember previously, we needed to register the Event Grid with our subscription, which has already been done. That was in our previous demonstration.
So with that done, let's go ahead and create our Logic App. On the screen here you can see I'm in my ServerlessComputing resource group, which is where I'm going to put everything. To create my Logic App, I simply click Create a Resource up here in the left, and then I can scroll down to Integration. From within Integration I can see that Logic App is one of the featured resources. So what I need to do is give my Logic App a name. And I have to tell it what subscription to deploy to. We're going to use my Pay-As-You-Go subscription, and the resource group I'm going to use is ServerlessComputing. As is the case with all of my other resources, I'm going to deploy into the East US location, and for this lab we don't need Log Analytics turned on. So we'll go ahead and click Create. What this is going to do is create the Logic App resource in Azure. Once it's done we'll pin it to our dashboard here so we can see it easily. Now once this Logic App has been deployed we can select it in our dashboard and launch our Logic App designer. So from the Logic App designer we can scroll down here and begin with a blank Logic App. Now since we're pulling data from the Event Grid we can select the Azure Event Grid. Now I can see it here in my recent list, however, I could also do a search for Event Grid here and see it show up as well. Under Event Grid, the trigger that we're looking for is when a resource event occurs, which is what we see here. So we'll go ahead and select this trigger. Remember, every Logic App has to have a trigger, so events going into the Event Grid are going to be the trigger for our Logic App. When I select Azure Event Grid here it's going to prompt me to sign in to my Tenant here, so I'll authenticate. And then once I've authenticated I have to supply a bunch of information here. We have to supply the subscription, which is the subscription that includes our virtual machine. So we'll select Pay-As-You-Go here.
The Resource Type tells our Logic App what to monitor. We only want to monitor our resource groups. We don't need to monitor everything that's going on here. And then the Resource Name is the actual resource group that we're going to monitor. So we're gonna monitor ServerlessComputing. Now if I were to change this to, let's say, Subscriptions, this name here would also change to only subscriptions. So let's go back to Resource Groups and then from our list select ServerlessComputing. After specifying our Resource Group we need to specify an Event Type that we're looking for. So we'll select the Event Type drop-down here and we'll specify WriteSuccess, because if a change is successful on one of our VMs this resource WriteSuccess is going to trigger. Now after specifying the event type we have one more piece of information to provide, and that is a unique name for our Event Grid subscription. So what we'll do is we'll call this MySubscription. And then from here we can click Save. After saving our Logic App we can minimize this information here and clear our canvas by clicking on the title bar here. Now what happens when we save our Logic App here with an Event Grid trigger is that Azure is going to automatically create an event subscription for this Logic App to the selected resources. In this case it was our resource group. So now what's gonna happen at this point is when that resource publishes an event to the Event Grid, Event Grid is going to now automatically push that event to our Logic App. Now, as of right now, nothing's going to happen because we haven't defined any kind of workflow, but eventually what will happen is is that event will trigger our Logic App, which will then create an instance of the workflow that we set up. And that workflow is going to be the email notification that comes to us. So now that we have a Logic App that's live and listening for events from the Event Grid, let's add some logic that checks for virtual machines in our resource group.
To do this we can click the New Step button here in the Logic App designer. And what we're going to do is create a Condition. Now what I'm going to do is I'm going to paste some values into this condition and I'll explain them after I paste them in here. Now what I'm going to do is switch over to the Code View here so you can see what I pasted in here. The first bit of code I pasted in was this triggerBody piece, and the second piece was the Microsoft.Compute/virtualMachines/write. What this expression is doing, it's looking to see if the data operation name within the trigger body is equal to this value. If it is, that indicates a successful change, so what it's going to do is notify us on that condition. Now what we can do with our condition here's is we can give it a name by clicking the ellipsis and then clicking Rename. So I'm just going to call this VMChange. Now after we've added this condition we can save our Logic App, and like we did up here, we'll minimize our condition here. So at this point we've defined our trigger and we've defined the condition that we're looking for. So at this point in the process what we're doing is we're using our Logic App to monitor the Event Grid for any changes to a virtual machine. This condition here is going to look for those changes and when we define this next step it's going to send us an email when it sees those. So at this point we've defined our trigger here and we've defined our condition. As it stands right now, our Logic App, called MyLogicApp, is going to monitor the Event Grid for events that are related to VM changes. What's going to happen is our conditional here is going to look at that data, and if it finds that there was a change made, it's going to react based on our actions that we define here under true or false. Since, in this demonstration, we're only interested in changes that are made, we're only going to add an action to true; we're not worried about anything happening under false because that means no changes were made. So, to send ourselves an email when a change happens, we can click Add Action under If True. Now what I'm going to use in this demonstration is my Office 365 account. I'm essentially going to send an email to myself since it's just a demo.
So what I'm going to do here is I'm going to select Office 365 Outlook, and you see here it's under Actions, not Triggers, and we're gonna scroll down until we find send email. So we're going to Send an Email using Office 365 Outlook. When I do this, it prompts me to log in because it's going to send using my tenant. So we sign in here. We can authenticate to the tenant. And now in the Send an Email screen we can build our email. Now what I'm going to do in this box is tell this to send an email to Tom@ThomasMitchell.net, and in the Subject and Body fields I'm going to use some dynamic content. So for the subject let's just say, when we receive any email we want it to say: Subject, and then have a subject of the event in our subject field in our email. As far as the body goes, we're going to want to know about the topic, the event type, the event ID, and the time of the event. So what we'll do here is we'll do Topic, and then select Topic, and then what I can do here is hit shift-enter to go down to the next line within this box. So I'll type in here Event Type and select the type from the dynamic content. And we'll do the same thing for Event ID. And Event Time.
So now that we have our email defined we can click save to save our Logic App. Now to test our Logic App and our Event Grid what we can do here is switch over to our Dashboard and make a change to our virtual machine. So what I'm going to do here is I'm going to change the size of this VM from a B2s to something else. Let's change it to a B2ms and we'll resize it. Now once this resize happens we'll check my email to make sure that I received an email notification about this change. So now that the resize has completed, let's bounce over to my Outlook, and lo and behold, I see a Topic. I see the event type as Microsoft.Resource's WriteSuccess. I seen an Event ID, and I see a an Event time. So my Logic App and my Event Grid are working together to insure I know about changes that are made to my virtual machines in my ServerlessComputing resource group.
About the Author
Tom is a 25+ year veteran of the IT industry, having worked in environments as large as 40k seats and as small as 50 seats. Throughout the course of a long an interesting career, he has built an in-depth skillset that spans numerous IT disciplines. Tom has designed and architected small, large, and global IT solutions.
In addition to the Cloud Platform and Infrastructure MCSE certification, Tom also carries several other Microsoft certifications. His ability to see things from a strategic perspective allows Tom to architect solutions that closely align with business needs.
In his spare time, Tom enjoys camping, fishing, and playing poker.