WEBVTT 0:00:02.360000 --> 0:00:06.400000 Hi, in this video, we're going to talk about resource tagging. 0:00:06.400000 --> 0:00:10.180000 Resource tagging is one of those really simple things that you want to 0:00:10.180000 --> 0:00:15.440000 understand. It doesn't take a whole lot of, shall we say, mental bandwidth 0:00:15.440000 --> 0:00:18.500000 to get, but it's also something that I think is pretty important. 0:00:18.500000 --> 0:00:21.160000 So I'm going to talk about what tags are, and then I'm really going to 0:00:21.160000 --> 0:00:26.840000 jump into tags, and we'll take a look at the process of creating a tag, 0:00:26.840000 --> 0:00:31.500000 how you can also enforce tags, and then we'll take a look at some ways 0:00:31.500000 --> 0:00:33.260000 that you can use tags. 0:00:33.260000 --> 0:00:37.520000 So let's go ahead and get into the discussion of what tags are. 0:00:37.520000 --> 0:00:42.820000 Tags are simply metadata, information about your resources, and it's really 0:00:42.820000 --> 0:00:48.220000 very free form. They're in simple name value pairs, and this could be 0:00:48.220000 --> 0:00:53.680000 anything. It could be things like maybe a cost center, or maybe somebody 0:00:53.680000 --> 0:00:58.480000 that's a point of contact, or maybe a status, is this in development, 0:00:58.480000 --> 0:01:00.280000 is it testing, or whatever. 0:01:00.280000 --> 0:01:05.520000 Whatever information that is relevant to your environment can be applied 0:01:05.520000 --> 0:01:10.400000 to any of your resources and also to resource groups. 0:01:10.400000 --> 0:01:11.900000 And that's really what tags are. 0:01:11.900000 --> 0:01:14.460000 They're just very free form metadata. 0:01:14.460000 --> 0:01:17.120000 And there's a few things that you can do with tags. 0:01:17.120000 --> 0:01:19.380000 One, you can enforce tagging. 0:01:19.380000 --> 0:01:22.440000 You can use policy, and you may not be familiar with policy. 0:01:22.440000 --> 0:01:26.720000 We're just going to take a very short look at what policy is, or in terms 0:01:26.720000 --> 0:01:28.620000 of how they apply to tags. 0:01:28.620000 --> 0:01:34.800000 But I can have a policy whereby I say, okay, any resource in this resource 0:01:34.800000 --> 0:01:39.700000 group has to have a cost center tag, or maybe any resource in my entire 0:01:39.700000 --> 0:01:42.740000 subscription has to have a cost center tag. 0:01:42.740000 --> 0:01:45.080000 Or I could say, you know what? 0:01:45.080000 --> 0:01:48.740000 I want to make sure every resource in this resource group automatically 0:01:48.740000 --> 0:01:52.840000 gets tagged with the status of test, right, because this may be a test 0:01:52.840000 --> 0:01:55.760000 resource group. Lots of things you can do there in terms of enforcing 0:01:55.760000 --> 0:02:00.740000 policy. Now, where are these tags used? 0:02:00.740000 --> 0:02:04.100000 Well, first of all, your management tools. 0:02:04.100000 --> 0:02:10.380000 So if I'm in the Azure portal, I can go and I can search for tags. 0:02:10.380000 --> 0:02:15.520000 And in fact, I can also even pin a particular tag search to my dashboard. 0:02:15.520000 --> 0:02:21.680000 So again, let's say that I'm in charge of our testing process and system. 0:02:21.680000 --> 0:02:25.640000 And I want to make sure that I can always quickly view anything that's 0:02:25.640000 --> 0:02:28.720000 been marked with the status test tag. 0:02:28.720000 --> 0:02:30.120000 I could do that. 0:02:30.120000 --> 0:02:34.000000 Also billing, and I mentioned cost center. 0:02:34.000000 --> 0:02:37.220000 When you retrieve billing information, whether you download it from the 0:02:37.220000 --> 0:02:41.020000 portal or you retrieve it through the API, one of the fields that you 0:02:41.020000 --> 0:02:44.360000 can pull back is the tags, right? 0:02:44.360000 --> 0:02:48.360000 Whatever my billing system is and use the tags to really help with billing, 0:02:48.360000 --> 0:02:51.720000 particularly if I may have billing that goes across different resource 0:02:51.720000 --> 0:02:53.420000 groups, for example. 0:02:53.420000 --> 0:02:57.900000 And really because all of this ties into an API, pretty much whatever 0:02:57.900000 --> 0:03:01.260000 you want with it because, well, it's part of an API. 0:03:01.260000 --> 0:03:03.960000 We don't really go into the API in this course. 0:03:03.960000 --> 0:03:05.760000 It's really outside the scope of it. 0:03:05.760000 --> 0:03:09.340000 But it's good to know that the API is there because that's the foundation 0:03:09.340000 --> 0:03:14.360000 really of everything that you do interacting with Azure. 0:03:14.360000 --> 0:03:18.460000 Now let's go ahead and let's take a look at some demos. 0:03:18.460000 --> 0:03:24.040000 I'm going to go ahead and first of all create a resource group and then 0:03:24.040000 --> 0:03:26.820000 drop some resources in that resource group. 0:03:26.820000 --> 0:03:30.020000 And then I'll create some tags and that'll show you how you can enforce 0:03:30.020000 --> 0:03:34.360000 tags. And finally, I'll show you in a very simple way how you can use 0:03:34.360000 --> 0:03:40.640000 tags. So let's go ahead and let's jump right into this. 0:03:40.640000 --> 0:03:43.400000 If I can find it, there we go. 0:03:43.400000 --> 0:03:45.800000 Let's go back to my dashboard. 0:03:45.800000 --> 0:03:51.280000 Okay, the first thing I'm going to do is go ahead and create a resource. 0:03:51.280000 --> 0:03:54.240000 And I'm going to create a resource group actually. 0:03:54.240000 --> 0:03:59.380000 Well, I'll create the resource and the resource group together. 0:03:59.380000 --> 0:04:03.920000 And it was like creating route tables because they just create really 0:04:03.920000 --> 0:04:08.420000 quickly. If I have anything in particular about route tables, we'll say 0:04:08.420000 --> 0:04:13.740000 demo, RT, and create a new resource group. 0:04:13.740000 --> 0:04:17.320000 And we're just going to call this tagging. 0:04:17.320000 --> 0:04:21.780000 And there we go. 0:04:21.780000 --> 0:04:23.960000 And create that. 0:04:23.960000 --> 0:04:27.880000 All right, so I've now created this route table and I've created this 0:04:27.880000 --> 0:04:30.020000 resource group. Well, that's created. 0:04:30.020000 --> 0:04:32.840000 I'm going to show you another approach. 0:04:32.840000 --> 0:04:38.700000 In some cases, and I'll go ahead and create a virtual machine. 0:04:38.700000 --> 0:04:41.960000 That too, I'm going to add to tagging. 0:04:41.960000 --> 0:04:49.640000 Hagging VM, make it password based. 0:04:49.640000 --> 0:04:53.600000 Do this quickly. 0:04:53.600000 --> 0:04:58.780000 And everything else should be good. 0:04:58.780000 --> 0:05:09.380000 I can actually for some resources, for some resources, I can actually 0:05:09.380000 --> 0:05:14.940000 create the tag when I create the resource in the portal. 0:05:14.940000 --> 0:05:20.260000 And so for example, maybe I say cost center. 0:05:20.260000 --> 0:05:27.620000 And I can specify a value and one on one on one. 0:05:27.620000 --> 0:05:31.420000 Now, this is all right, there's going to be 11 resources created. 0:05:31.420000 --> 0:05:33.900000 Do you want that on all 11 resources? 0:05:33.900000 --> 0:05:37.740000 And I'm going to put it on all but two of those resources, just kind of 0:05:37.740000 --> 0:05:41.160000 randomly. And I'll go ahead and create it. 0:05:41.160000 --> 0:05:48.640000 So that's going to provision a virtual machine with a to use a technical 0:05:48.640000 --> 0:05:52.000000 term, whole bunch of resources that have tags. 0:05:52.000000 --> 0:05:55.860000 Now, what I'm going to do is I'm going to jump back to my tagging resource 0:05:55.860000 --> 0:06:02.260000 group. And I'm going to go to the route table that I had created. 0:06:02.260000 --> 0:06:06.140000 And when I go to any resource, and this is you will find this on every 0:06:06.140000 --> 0:06:11.080000 resource, even though it wasn't on the provisioning page, I can go to 0:06:11.080000 --> 0:06:13.320000 tags and I can add a tag. 0:06:13.320000 --> 0:06:23.440000 We'll add cost center as a tag and we'll add one, oh, one, oh, two. 0:06:23.440000 --> 0:06:25.240000 That's my cost center. 0:06:25.240000 --> 0:06:27.800000 And I can add more than one. 0:06:27.800000 --> 0:06:31.360000 Maybe I want to have a status tag. 0:06:31.360000 --> 0:06:35.140000 And again, this is on the one hand, it's really free form. 0:06:35.140000 --> 0:06:39.160000 On the other hand, you want to think about some governance to make sure 0:06:39.160000 --> 0:06:41.240000 that your tags are going in consistently. 0:06:41.240000 --> 0:06:46.320000 And I'll show you some of what you can do to enforce that. 0:06:46.320000 --> 0:06:47.700000 All right. So there we go. 0:06:47.700000 --> 0:06:52.680000 Very easy. I've now added these tags. 0:06:52.680000 --> 0:07:09.620000 And if I refresh my resource group, oh, did we not deploy, I thought I 0:07:09.620000 --> 0:07:12.320000 deployed a virtual machine. 0:07:12.320000 --> 0:07:17.960000 Perhaps I did not. 0:07:17.960000 --> 0:07:22.160000 So one thing that's really important when you are provisioning resources 0:07:22.160000 --> 0:07:25.900000 in Azure is to make sure that you actually click the create if you're 0:07:25.900000 --> 0:07:31.140000 in the portal, which I just did. 0:07:31.140000 --> 0:07:34.780000 And magically now all of these resources are here. 0:07:34.780000 --> 0:07:37.640000 So I've got the resources that I had created. 0:07:37.640000 --> 0:07:41.820000 And what I want to do is I'm actually going to sneak ahead a little bit. 0:07:41.820000 --> 0:07:46.460000 And I want to edit the columns of my resource group view. 0:07:46.460000 --> 0:07:52.240000 And I'm going to just add tags and apply. 0:07:52.240000 --> 0:07:58.400000 So now right here in the resource group, I can actually see my tags. 0:07:58.400000 --> 0:08:02.600000 And I can see this demo RT has cost, center, and status. 0:08:02.600000 --> 0:08:08.160000 And in fact, if I go to the resource itself, right there, I've got the 0:08:08.160000 --> 0:08:10.820000 tags, cost, center, and status. 0:08:10.820000 --> 0:08:13.580000 And I just jumped ahead, didn't mean to. 0:08:13.580000 --> 0:08:15.860000 But I can see that. 0:08:15.860000 --> 0:08:19.620000 Now I can also, as I mentioned, enforce tagging. 0:08:19.620000 --> 0:08:22.640000 And I'm going to do that by way of policy. 0:08:22.640000 --> 0:08:29.980000 I'm going to come into the policy and I am going to assign a policy. 0:08:29.980000 --> 0:08:33.780000 And policies allow you to enforce rules. 0:08:33.780000 --> 0:08:37.000000 And again, not going to go deep into it, other than just kind of give 0:08:37.000000 --> 0:08:38.940000 a quick example. 0:08:38.940000 --> 0:08:42.780000 There are scores of policies. 0:08:42.780000 --> 0:08:49.580000 I'll just tag. And what I want is I want to enforce the existence of a 0:08:49.580000 --> 0:08:53.020000 tag. So I'm not going to tell you what value it needs, but I am going 0:08:53.020000 --> 0:08:56.180000 to say that you need to have a tag. 0:08:56.180000 --> 0:09:00.200000 So I've got this policy to require a specified tag. 0:09:00.200000 --> 0:09:04.520000 And I'm going to specify that this needs to be. 0:09:04.520000 --> 0:09:08.780000 Cost Center. So everything in this resource group needs to have the cost 0:09:08.780000 --> 0:09:15.080000 center tag. I'm going to go ahead and create that. 0:09:15.080000 --> 0:09:20.580000 Okay. And now if I go and let's say that. 0:09:20.580000 --> 0:09:24.460000 Go up here to my resource group. 0:09:24.460000 --> 0:09:29.580000 And I'm going to add yet another route table. 0:09:29.580000 --> 0:09:33.400000 Probably is a resource that creates even faster than this, but this one 0:09:33.400000 --> 0:09:35.580000 just is very easy. 0:09:35.580000 --> 0:09:45.140000 And demo RT2. All right, creating it in here and create. 0:09:45.140000 --> 0:09:50.360000 Now this is going to be a little bit problematic. 0:09:50.360000 --> 0:09:53.900000 So downside of this. 0:09:53.900000 --> 0:10:00.080000 Wait for this to get finished. 0:10:00.080000 --> 0:10:05.140000 All right, let's take a look at my notice and it tells me that that deployment 0:10:05.140000 --> 0:10:09.980000 failed. And it'll tell me that it was disallowed by the policy. 0:10:09.980000 --> 0:10:12.560000 And it's the required specified tag. 0:10:12.560000 --> 0:10:16.040000 And that's one of the problems with kind of having different provisioning 0:10:16.040000 --> 0:10:19.960000 blades, is that there was really no way for me through the portal to specify 0:10:19.960000 --> 0:10:23.300000 the tag for that. 0:10:23.300000 --> 0:10:25.860000 I would have had to have done that from the command line or through the 0:10:25.860000 --> 0:10:27.580000 API or some other tool. 0:10:27.580000 --> 0:10:31.240000 Now I'm going to go back and leave it as is for now. 0:10:31.240000 --> 0:10:37.360000 And I'm going to go in and believe you notice that a couple of these do 0:10:37.360000 --> 0:10:45.800000 not have tags. But I can go in and I can edit it and modify the tag and 0:10:45.800000 --> 0:10:47.720000 put in cost center. 0:10:47.720000 --> 0:10:56.000000 So it's not going to do anything like delete or disable existing resource. 0:10:56.000000 --> 0:11:01.540000 But the way that policy is set up, it's now requiring me to have that 0:11:01.540000 --> 0:11:05.700000 tag whenever I create or update a resource. 0:11:05.700000 --> 0:11:09.500000 All right, so that's how you can enforce tagging again, be aware of some 0:11:09.500000 --> 0:11:11.400000 of the side effects of doing so. 0:11:11.400000 --> 0:11:16.060000 You can also do things like force tags with default values and do some 0:11:16.060000 --> 0:11:17.380000 other things as well. 0:11:17.380000 --> 0:11:20.380000 All right, now what I want to do is show you some ways that you can use 0:11:20.380000 --> 0:11:24.120000 tags. And I kind of jumped ahead a little bit in two ways. 0:11:24.120000 --> 0:11:30.920000 One, if I'm looking at my resource group view, I can view the tags here. 0:11:30.920000 --> 0:11:37.840000 But also if I click a tag, I guess I actually have to be in the object. 0:11:37.840000 --> 0:11:40.540000 Let's go to the object and click the tag. 0:11:40.540000 --> 0:11:46.120000 There we go. That's actually going to do a tag search format. 0:11:46.120000 --> 0:11:53.380000 And this is showing me all of the resources that have that specific tag. 0:11:53.380000 --> 0:11:58.040000 Now in this case, all of these resources are in the same resource group, 0:11:58.040000 --> 0:12:01.460000 but that would not necessarily be the case. 0:12:01.460000 --> 0:12:10.340000 And in fact, I can go up and if I go tags, there's actually a whole interface 0:12:10.340000 --> 0:12:20.360000 where I can see all 10102 and there I can very quickly see what's been 0:12:20.360000 --> 0:12:23.100000 tagged with the 10102. 0:12:23.100000 --> 0:12:25.980000 And those are some of the ways that you can use tags. 0:12:25.980000 --> 0:12:30.540000 And again, you can see in this case, I just have a lot of kind of random 0:12:30.540000 --> 0:12:33.180000 tags because this is not a production subscription. 0:12:33.180000 --> 0:12:38.100000 If it were production, I would definitely be enforcing some governance 0:12:38.100000 --> 0:12:42.800000 by way of policy to make sure that I've got consistent tagging that can 0:12:42.800000 --> 0:12:48.780000 be used in a rational and consistent way within my operation, whether 0:12:48.780000 --> 0:12:53.640000 it's looking for resources or having those resources filtered or just 0:12:53.640000 --> 0:12:57.340000 viewing the tags, whether it's in the resource blade or the resource group 0:12:57.340000 --> 0:13:00.620000 blade, or even using them in things like the billing API.