Time
23 hours 16 minutes
Difficulty
Intermediate
CEU/CPE
23

Video Transcription

00:01
Hello and welcome back to Cyber Aires. Microsoft Azure Administrator A Z 103 course I'm Will Carlson. And this is Episode nine about policies In today's episode, we're going to look at a policy definition and how they enforce compliance.
00:17
We're gonna apply that policy definition with an assignment to inappropriate scope.
00:22
We're also gonna discuss the schema of a policy definition. So the Jason Template that makes a policy definition work,
00:30
we're gonna get right into portal. And I want to point out as we get going that there are oftentimes a number of different ways to access what you want to access here within portal.
00:41
Right now, we could to get the policy, go to subscriptions
00:45
when I click one here in this free trial and you can see here that policy is an item in this section of the blade.
00:53
I could also go to resource groups,
00:56
pick a resource group, and I can see that policy is also an option here. 1/3 option would be to come to all service is
01:03
and search for policy, and I could navigate to policy that way as well. There's not a wrong way to get to it. But rest assured, if I get toe a particular item in azure that you're not familiar with, it's likely just a different way to get to the exact same thing.
01:18
We're gonna jump in here to this get started blade here in policy, and I recommend you look through this click around, make sure all of this makes sense to you. It really is a great high level view of what policy is all about an azure.
01:30
But for us to get started, we're gonna go ahead and you a policy definition. Now
01:34
a policy definition is going to be the rule set of what you want to happen or want to prevent within azure.
01:45
And this is a list of all of the policy definitions. Now, one thing to note these air, not policies, will. What's up? Well, the's air initiatives and initiatives are just a simple way to bundle policies together so that you don't have to deploy policies individually. One at a time.
02:02
You may have five or six policies that affect the location of resource is within your azure environment.
02:08
You want a bundle? Those up is an initiative and deploy those and manage those all at once. So an initiative is just a bundle of policies and you can see that Illustrated here in Azure. So this particular initiative has 87 policies bundled in it.
02:23
You clearly wouldn't want to deploy those one at a time. You wouldn't want to remember which policies made up this initiative tohave to deploy them
02:30
one of the time.
02:30
But to get started, we're actually gonna look at just a policy definition
02:35
so we can filter that there. You can also search. I'm gonna go ahead and search for location.
02:39
What we're gonna look through here is the policy for preventing or Onley allowing resource groups from certain locations also known as regions.
02:49
And this is the Jason for that policy definition.
02:52
Now, a couple of the things I want to call out here that are of particular importance to this policy definition are going to be First of all is the mode.
03:00
There are two options here from mode all and indexed all does just what it says. That policy can be applied to. All resource is and will be
03:08
that you're applying to
03:10
index is going to single out and only apply the policy to resource is that support tags and locations.
03:17
This is particularly important because there are some resource is resource types and azure that don't aren't location bound. So there are some that are global in nature. And you wouldn't want to try toe enforce a policy on a global resource that limited it to a particular location. It would not have the desired outcome that you want.
03:38
So
03:38
all an index are the two options promote
03:43
parameters are gonna be just like they were four hour armed template gonna be things that are said it run time
03:50
so you can reuse this policy definition
03:54
in more than one instance.
03:57
Then we get down into the policy rule. The real heart of this policy and the Policy Rules section is going to be an if then block. So if these things are true or not, depending on how you set this, then we want you to do this effect. In this case, we want all of these things
04:14
to be true. So as long as our location is not in this list of allowed locations, which we set the A parameter
04:20
and it is not a resource group or it sorry, it is a resource group,
04:27
then we're going to deny it. So all this policy does is, say, if it's not in the allowed locations and it's a resource group deny
04:34
There are a number of effects that are possible here other than Deny denies. Gonna do exactly what it says. It's gonna deny you the ability to create a resource group. That doesn't mean our policy. It's also gonna log that and the activity log that that was attempted
04:48
audit is another option here that's just gonna log the attempt. It will let it be done, but it's gonna log that it was done.
04:57
Upend is another option here, and that's going to add a fields to the request. A common example would be you wanted to make sure a tag gets added to every resource you would upend that tank.
05:09
There's audit. If not exists. So is if these resources don't exist, create them and make an audit log
05:15
deploy if not exists. If these resource is don't exist already, then go ahead and deploy them and then disabled is the last effect, and that's just it. It's disabled. It's not going to hurt.
05:28
So now how do we assign this policy. And what is the policy assignment mean? So too
05:33
make policy work In Azure, you have to have the policy definition, which is what we looked at.
05:40
You assign that policy to a given scope.
05:44
Now, let's do this a little differently. We're gonna come here to subscriptions. I'm gonna pick my free trial subscription, and I'm gonna click on policy.
05:51
I'm going to assign a policy,
05:55
and you can see that we're already scoped into the free trial. And that's because that's how I navigated to hear if we had done this from the policy blade. It would have asked me, what scope did I want to use
06:05
now? These exclusions air Just that if there are certain resource is within this subscriptions or resource groups that I don't want this policy to apply to, I can exclude them here.
06:16
This is the policy definition. So we're gonna go ahead and filter this space on location
06:24
allowed locations for resource group and hit select.
06:27
I'm gonna put a description. It's not required. And then here I'm going to select
06:30
the locations or regions that are allowed. And just for the sake of illustration, I'm gonna go ahead and select
06:38
Korea Central. That's all that was allowed.
06:42
And I'm gonna go ahead and hit a sign,
06:44
and that's applied that policy to this subscription. Now again, we're at the subscription level, and the policy has applied to my free trial subscription, So my pay as you go subscription does not have to deal with this policy.
06:56
One thing to illustrate here is the component in the concept of management groups
07:00
before management groups existed. If I wanted to apply the same policies to all of my subscriptions, you have to do it one at a time.
07:08
Management groups allow me to put an organizational unit above my subscriptions and apply policy toe. All of them all at once
07:15
highly recommend you doing that for consistency sake across an organization. But it's not required.
07:21
What we can see here is that Azure is applying this policy to all of the resources that are currently in this subscription. Now you can see that it's not started yet.
07:32
It will take azure up to an hour to apply this policy across. All of my already deployed resource is in this subscription that's important to note
07:42
or compliance policy can take up to an hour to apply.
07:46
Now, if I want to go in and create a resource group within this
07:50
subscription, let's do just that.
07:54
Resource groups, Let's add one.
07:57
We're gonna leave it in free trial. We're gonna call this test
08:00
and we're gonna deploy this to Central us. That's clearly not in the region that was allowed. I'm gonna hit, review and create
08:07
validation past, and we're gonna create that resource,
08:11
and I get an error.
08:13
So although policy takes some time to apply for compliance, it applies immediately for new resource is and resource updates. So since I tried to deploy this in an unsupported region, it's going to fail. It's gonna give me some details about why that failed and what policy really affected me.
08:31
And it logs that away.
08:33
And it did not create that resource group
08:35
Now to complete the loop for managing policy. Let's go back to subscriptions. We're gonna go back to free trial into the policy blade.
08:45
And if I want to delete this policy, I can click here, delete the assignment,
08:52
and that policy definition is gone.
08:54
So in today's episode, we talked about how we set up policies with policy definitions a bit about the Jason options that air there, so you can understand those as you go forward.
09:03
But we also talked about taking a policy definition creating a policy assignment and that that is applied to the given scope. And that scope could be a management group, a subscription, a resource group or even down at the resource level itself.
09:18
Coming up in the next episode, we're gonna talk about how we very broadly can prevent things from happening to. Our resource is an azure via locks, and
09:30
also the concept of moving resource is around an azure to get him where we want them to be.
09:35
Thank you so much for joining me today. I look forward to talking more with you in the next episode.

Up Next

AZ-103 Microsoft Azure Administrator

This Microsoft Azure AZ-103 Certification training course teaches students to perform tasks like managing Azure subscriptions and resources, implementing and managing storage, deploying and managing virtual machines (VM) and networks, and managing identities!

Instructed By

Instructor Profile Image
Will Carlson
Director of IT and Cybersecurity
Senior Instructor