- In the previous labs, we learned how to configure machines
with custom script extension
and desired state configuration.
The downside of using these type of configurations is
that the configuration is only run once,
and configuration may drift either
by someone logging into the server and changing things
or uninstalling certain software.
The way in which we can ensure
that the state of the virtual machine is maintained,
is with automation, state configuration.
So let's go ahead and configure that, in this lab.
To start out, we're going to pick up
from where we left off in the previous lab.
And the first thing we're going to do is
we're going to go to the search bar
and we're going to look for Automation Accounts.
So go ahead and look for that service.
And we're going to create a new service.
So go ahead and click on the create button
and let's go ahead and create this
in our resource group that we have been using.
And I'm going to call this AZ400VL
as in video lessons, auto.
US East is fine.
The identities is fine as system assigned.
Networking, I'm going to leave public access,
No tags. Review and create.
All right, it's going to take a couple of seconds to
be deployed.
Shouldn't take too long.
All right, once it has been created,
let's head on over to our resource.
And well, here you can see details about your resource
in the overview page.
What we need for this lab is the state configuration
which you will find
within the configuration management menu.
So let's go ahead and click on this.
And here you will be, well, when this loads,
you'll be able to see details about the configuration
of the nodes that you have added to this automation account.
Right now, we have not added one.
So let's go ahead and, first, add a configuration
by clicking on the configurations tab.
And here we need to locate our file that well,
yeah, first we need to add the configuration
and then we're going to locate our configuration file
which is going to be the same one
that we previously uploaded the one for the window server.
And it's going to be the PS1 file.
You can see that I still have it in my desktop.
You may recall that this was what I called it
in the previous lab.
So go ahead and click on open.
And we need to name this just like our file
and click on, okay.
Oh, nevermind.
I needed to add the name of the configuration
which I still have open right here.
And you may recall, it's DscConfiguration with a capital C.
So let me input that right there.
Then click on, okay.
Okay, seems it's not pick it up.
Let me hit refresh. Okay, there it is.
So once it appears right there,
go ahead and click on it like I did.
And what we need to do now is compile it.
This is going to convert it.
Well, it's going to create an MOF file,
so that it can be applied to whatever nodes you add
to the state configuration in your Azure automation account.
So once you do that, it's going to tell you it succeeded.
So the way you can verify that is going back
to your Azure automation account,
going to state configuration,
and then clicking on the compiled configurations tab.
You can see it hasn't appeared yet.
So it's going to be a matter of refreshing for a little bit.
We need it to appear here in order to proceed.
So in the meantime, I'm going to go back
to my virtual machine,
the one with windows
and I am going to remove the desired state configuration.
You go to the virtual machine, you go to the settings menu,
and then you click on extensions and applications
and you will see that we still have
the previous desired state configuration there.
Let's go ahead and uninstall it.
And this will take a couple of seconds as well.
In the meantime, let's go ahead and refresh this
in order to see our configuration
when after it had been compiled.
Once you see it like this, you'll be able to add a node
and assign this configuration to the node.
So first I just want to make sure that this is removed.
Let's give it a couple of seconds.
Okay, it says that the extension
has been successfully deleted.
Let me refresh.
Okay, maybe a hard refresh.
Okay, you'll see
that the extension no longer appears listed right here.
This is where we had the desired state configuration
for our windows machine from the previous lab.
So move on back to the Azure automation account,
the tab where I have the automation account.
Click on state configuration.
Now we're going to click on nodes
and you can see we don't have any nodes right now.
Let's go ahead and add our very first node.
And we're going to select the video lesson window, VM,
which is the one I just removed the extension from.
If you removed it successfully,
it will say status, not connected.
So once you have selected the VM,
go ahead and click on connect.
And now it's going to allow you to select a configuration.
This is the one we just compiled.
So go ahead and select that.
Next, it's going to ask you,
if you want to modify the time it searches,
for a new configuration file
and the time it installs it,
every time it downloads a new configuration file
and in the configuration mode,
we can either tell it to just apply the configuration,
to apply and continuously monitor
that the state has been maintained,
or to apply an autocorrect, so if the configuration
of this machine gets changed, drifts,
it'll automatically correct it
and make it have the configuration
that we specified in the configuration file.
That's the way you maintain state in this VM.
So I'm just going to select this option.
This allows you to override older modules.
I'm fine with that.
And this will allow you to reboot the node
in case it's needed in order to comply
with the configuration.
And here are the options that you can select
for that last setting.
So I'm just going to go ahead and click on okay, now.
And it's going to connect to the VM.
And it's going to set up that configuration in the machine.
You may recall that this machine already had IIS installed,
so it shouldn't take long.
You can see IIS is still available in this machine.
So let's head on back to the Azure automation account.
Let's click on desired state configuration.
And I guess this is going to take a while as it's updating.
Let's go ahead and click on refresh.
A hard refresh, whoa.
Let's give it a...
Okay. There it is.
So you can see that now
our Azure 400 video lesson windows machine
has been added to our Azure automation state configuration
and it's listed as compliant.
Since we configured it to autocorrect,
if someone logs into this server
and uninstalls internet information services,
within 30 minutes, max, it's going to identify that drift,
that configuration change
and it's going to attempt to fix it.
So that was Azure automation state configuration.
Thank you for watching.