Time
7 hours 58 minutes
Difficulty
Intermediate
CEU/CPE
8

Video Transcription

00:00
Welcome back. In this episode, we're going to take a look at managed identities.
00:05
The objectives include understanding what managed identities are and then taking a look at a demo out in our azure portal.
00:12
So first, as always, what are managed identities? This is a feature of azure active directory that allows authenticating against any service that uses azure active directory for authentication.
00:23
The scenario here would be a developer building an application that requires accessing cloud resource is the application needs to authenticate against those. Resource is without storing credentials inside the application source code. A managed identity solves this problem by creating a service principle for the resource inside of azure A. D.
00:43
You can then use this identity to authenticate two. Other service is without putting credentials in your coat, for example, and we'll gonna see the center demo. We could provisions a managed identity for a virtual machine. We then provide this first machines managed identity permissions to query or access. Other resource is
01:00
the code running on the verge machine is automatically authenticated, and we don't have to worry about managing use names or passwords. Hence the manage portion of managed identities.
01:10
We do have two types of managed identities that we can work with. The first is a system assigned, and it's enabled directly on the service instance, meaning Azure creates the added indie for the instance, or the resource and the tenet, and it's trusted by the subscription. The credentials are then provisioned onto the instance for it to use
01:29
when the instance or resource is deleted. The managed identity credentials are also deleted automatically, and this is the type we're going to use inside of our demo when we're enabling a managed identity for a virtual machine. Our second type of managed identity is a user assigned,
01:44
and this is created as a standalone resource and is not tied to a specific service or other. Aditya Resource
01:49
Azure creates an identity that can be assigned to one or more service instances. This identity is managed separately from the service it is assigned to, meaning it will persist after the service it is assigned to is deleted.
02:01
Now let's jump out to the head or portals so we can take a look at how to create managed identities and see exactly how it is granted Access an authorization to other azure resource is
02:12
back in our azure portal for our demo. We're going to use a managed identity on a virtual machine
02:19
before we get started. I want to show both ways that we can enable this on a virtual machine. So first, let's go create a virtual machine.
02:32
Now we're pretty familiar with how to create a version machine, so I'm going to just bypassed some of these options initially. But let's go check out the management tab.
02:40
If we scroll down, we have the option to create a system assigned managed identity when we create the virtual machine. So here, just illustrating we can create a system assigned identity when we create the virtual machine.
02:53
In this case, we're not going to do that. So let me cancel out.
02:57
Let's go into a virtual machine already have created
03:04
and under settings. If we scroll down
03:07
and select identity
03:08
here, we have the option of turning on a system assigned managed identity.
03:14
We also have the option of taking an existing user assigned managed identity and associating it with this virtual machine.
03:21
But for right now, let's just go ahead and go back to system assigned
03:23
ends. Change the status to on,
03:27
we'll save our changes.
03:30
This is just showing the virtual machine is going to be registered with azure active directory. And when this is done, the virtual machine can be used to grant permissions to access. Different resource is just like we do with a user, identity or group.
03:43
Let's go ahead and enable.
03:45
Now that we have our resource, I'm gonna go back to overview
03:49
and I'm going to connect to our virtual machine over our DP.
03:59
So here I've logged into our V m 01 virtual machine and opened up in admin power show window.
04:05
And what we're gonna be doing is using the managed identity we've created for V M 01 and using it to make a call out to the azure resource manager.
04:15
Let's jump over to note pad. I've got all the commands documented that we're going to run.
04:19
This First command is just invoking Web request and we're gonna call it against this I p address here 169.254 that 169 to 54
04:29
This is just the azure instance metadata service
04:32
and what we're gonna be doing is making a request out to the managed identity for Azure resource is what we'll get back is an access token in order to access the Azure Resource Manager service,
04:46
let's go ahead and copy this.
04:51
Let's take a look at the response variable that we save this into
04:57
inside the content. We have an access token and a little bit more information.
05:00
Let's take our response and extract out the content portion of it converted to Jason
05:05
and save it to the content. Variable.
05:15
Let's take a look at the content variable.
05:16
So now we see we have an access token as well as our client I D. And some expiration information.
05:24
Let's take this one step further.
05:26
Let's take that access token and just save it to its own variable. If we take a look at its contents, we've got our access token safe to this variable, and this is gonna allow us to connect to the armed service.
05:38
Let's clear the screen real quick
05:40
and back in no pad. What we're going to do now is invoke another Web request out to management dot azure dot com.
05:46
Here. I'm making requests out to my subscription GW ID
05:49
and what we're gonna be doing is just acquiring a resource group in the name of that resource group that I have is just called identity Dash R G.
05:58
And we're including that access token inside the authorization header.
06:02
Let's go ahead and grab this command
06:11
and you're gonna see we're going to get an error saying we don't have authorization to perform this action.
06:15
That's what we're saying Here is our virtual machine. V M 01 does not have the authorization to access our identity Dash RG Resource Group to pull back information about it.
06:27
So let's jump back to the Ashram portal
06:30
here I have the identity desh RG Resource Group already open to our overview. Paige, let's go into access control.
06:38
Let's click on add
06:40
roll assignment.
06:43
I'm gonna select just the reader role,
06:46
and I'm gonna sign this permission to V. M. 01
06:49
And what comes up is the managed identity for R V M 01 virtual machine, meaning we can assign it permissions to other azure. Resource is
07:01
let's go ahead and save this.
07:04
If we go to roll assignments,
07:06
we see down here at the bottom the virtual machine, BMO one has reader access to this resource group, so you can see we've taken our managed identity and we can now give it access to other azure. Resource is if we need to query that or perform some kind of action against it, let's switch back to our virtual machine
07:26
and let's run our command again.
07:28
You see, this time we get a different response. We actually get an answer back showing the I. D of our resource group, the name of it, the location and also some properties saying the provisioning state is already succeeded.
07:41
So what we did here is we gave a managed identity to V M 01 We then granted V m 01 access to read our Identity Dash RG Resource Group. We created an access token out to the Azure Resource Manager service and then we use that access token to invoke a Web request against the resource group.
08:01
I hope this demo cements the concept of managed identities for you, where we create an identity for a virtual machine and then gave it authorization to access. Other resource is inside of azure, so anything running on this virtual machine could be an application or just simply power show commands like this.
08:20
We can then query our resource group.
08:22
Let's jump back to the slides and wrap this up.
08:26
Falling up from the demo, we tested out a managed identity on the Windows virtual machine, but they're also available for Lennox Virtual Machine, and you can create manage identities and associate them with other service is like ab service's function logic APS service bus, Evan hubs or container registry.
08:45
These are all service is we've looked at previously on this course
08:48
coming up. Next, we're gonna take a look at another security feature we can use called Azure Key Vote. See you in the next episode.

Up Next

AZ-300: Microsoft Azure Architect Technologies

Azure Solution Architects are responsible for taking business requirements and turning them into solutions. This course provides an introduction into Azure, Microsoft’s cloud platform.

Instructed By

Instructor Profile Image
Jeff Brown
Instructor