[MUSIC]
>> In this lab, we will be connecting to
Microsoft Azure Stack using PowerShell.
The scenario is that we have deployed
an actual Microsoft Azure Stack instance and we
would like to manage it using Azure PowerShell.
After we have completed this exercise,
you will know the steps that are involved in connecting to
Microsoft Azure Stack admin endpoint using PowerShell.
At a very high level,
this is a four-step process,
which we will go through in this exercise.
First thing that we need to do is
install Azure Stack compatible PowerShell modules.
Then, we will download Azure Stack tools.
Later, we will configure Azure Stack PowerShell environment.
Last and the fourth step into the process is we will
connect to Azure Stack instance using PowerShell.
So let's get right into it.
The first thing that we need to do is go
ahead and log into the server.
So in this case, I've already done that.
Then, go ahead and click on start and then type "PowerShell."
So there's "PowerShell ISE",
right-click on that and select "Run as an administrator."
In the interest of time,
I have already opened up the PowerShell session here.
As you can see,
there are multiple cmdlets that we need to
type during this lab environment,
and there are a couple of ways we could deal with that.
Either we can manually enter each one of them,
which is what I generally do,
or we can copy and paste
this cmdlet from the TechNet documentation.
I will read off you of these commands as we go
through this video today, however,
the suggestion would be to copy and paste
these commands from the documentations available on the TechNet,
as you could tell,
these are long strings that are available.
So the first task is install compatible Azure PowerShell module,
and the first command that we're going to
run is the "PSRepository",
just highlight this and click on "Run the Selected" command line.
What this will do is it actually
configure a PowerShell gallery as
a trusted repository for us to use later in the session.
The second command is "Set- ExecutionPolicy."
Select that and click on "Run."
So with this, what we have
done is we have stored the current value
of the Windows PowerShell execution policy in a variable.
The third command would be to install "AzureRm.
BootStrapper" modules.
Select that and click on "Run."
So this command will install AzureRm Bootstrapper module.
This module is actually necessary for us to subsequently
use the Azure Stack compatible AzureRm modules.
So we will be doing that in just a minute from now.
Go ahead and select the fourth command,
which is "Use-AzureRmProfile."
So we leveraged the API version profile,
so let's go ahead and run this command.
So one thing that you will notice here in this cmdlet
is the date that you see there.
That's one thing to keep in mind.
Of course, the date that we have in this command is 2018,
March 1st, and that's the date related to the profile.
It could change because there are plenty of
updates as for Azure Stack goes.
It gets updated fairly quickly,
so it'll continue to get updated and so you need to use
the current version for your own instance of
Azure Stack so make sure you check the latest version.
For the purpose of our lab environment,
we will go ahead and use the profile version of 2018, March 1st.
This is up-to-date as of today.
Now, the next command would be to go ahead
and install module name AzureStack,
the required version is 1.5.0,
which is an up-to-date version today.
So this command will go ahead and
install Azure specific PowerShell modules,
which we will need,
and this include Azure Stack admin,
Azure Stack storage, so let's go ahead
and run the last command in our task 1.
So we'll run this command,
"Get-Module ListAvailable Where-Object Name like Azure."
So go ahead and run that command.
So what this command will do is this will basically allow
you to view all the newly installed
AzureRm and Azure Stack modules.
It takes a couple of seconds and then you can see there's
quite a bit of information that's
available with respect to the modules that are installed on it.
So now we have completed
all the commands that are part of our task 1.
Now, we will move on to the task 2,
where we will install
the Azure Stack tools after we download them.
Again, the recommendation would be to copy and paste
these commands from the documentation on the TechNet.
However, one thing to keep in mind,
when you copy a command from the TechNet,
at the end of some of the lines,
you will see there's a single backtick
that indicates that it goes to the next line,
so it's a continuous string.
If you copy and paste,
make sure that you delete that single backtick at the end of it.
So the first command that we are
going to run as part of our task 2 is
"Set-Location -Path 'C:\'" and go ahead and hit enter.
As you can see, the next command,
it's a long string,
and there are three more commands that we need to execute here.
So I have already copied and pasted these commands here,
so let me go ahead and select the second command,
just "Invoke-WebRequest" and hit "Enter."
So what we are doing now is we are
copying the archive that contain
the GitHub repository that are hosting
the Azure Stack tools onto a local server.
Then the next command we will use is "Expand-Archive",
select that and hit "Enter. "
So we expand that archive to "C:\
AzureStack=Tools-masters," which is something that we will be
revisiting later in this session.
So go ahead and click the last command.
So the tools contain the PowerShell module that
offer a broad range of
features including Azure Stack capabilities,
Azure Stack VM infrastructure,
image configuring Resource Manager policies,
registering Azure and Azure Stack connectivity,
the Azure Stack tenant management,
as well as validation of Azure Stack Resource Manager templates.
So with this, we have completed
all the commands that are part of our task 2.
Now, we'll move on to task 3,
where we configure Azure Stack PowerShell environment.
So for that, we are going to run the first command,
which is "Import-Module", select that and then hit "Run."
So this command basically goes ahead and
import the modules and connect module into the Azure Stack tools,
and this is actually necessary in order for us
to connect to the Azure stack deployment
later in the session today.
Now, let's also go ahead and run the second command,
which is "AzureRmEnvironment", select that and hit "Enter."
So we have defined "ArmEndPoint" here,
select that and say "Run."
So what we are doing here is we are registering
an AzureRm environment that represents
the admin endpoint for our Azure Stack deployment.
Let's go ahead and do the same thing for
our "AzureStackUser", hit "Enter".
So once you enter this command,
this will just register an AzureRm environment,
representing the tenant endpoint for our Azure Stack deployment.
So we have completed step 1,
step 2 and step 3, now,
let's move on to task 4.
We will now move on to the task 4,
and since our lab environment
is using Azure Active Directory environment,
so we will be running a couple of commands here.
You will notice that there are
two strings that we see for the tenant IDs.
So I'm going to enter each of those because like I mentioned,
we are using Azure Active Directory
and then we'll move on to the next commands,
down in the PowerShell session.
So let's select the first one and this is for Azure Stack admin,
and as you could also see,
I have defined our Azure Active Directory tenant name here.
Highlight this and then go ahead and click on "Run",
and let's do that for our tenant as well.
Go ahead and click on "Run."
Now, we have done this command.
So step 4 is also completed.
Now, we are moving into our last part of this session,
which is to connect to the Azure Stack endpoint.
So what we are going to do now is connect to
the Azure Stack endpoint and we
will connect to the admin endpoint,
specifically, and we will do that,
of course, by using PowerShell.
So as you could see, there are a couple of
cmdlets that we need to run.
So let's go ahead and select the first one,
which is we define the admin username and hit "Enter."
Let's go ahead and run the second one,
which is admin password,
and this also convert to a secure string,
so go ahead and hit "Enter."
Let's go and run the admin credential,
and go ahead and click "Run."
So by doing this,
we are generating PSCredential object
that contain the encrypted credential of the admin user account,
so we need to run this command.
So now, what we need to do is sign into
our admin endpoint of our Azure Stack deployment.
In order to do that,
we are going to select this command
"Login-AzureRmAccount -Environment" and go
ahead and run this command.
So as you could see,
there is a good amount of information
available with respect to the account,
the subscription name, then we have the subscription ID,
we also have tenant ID,
and then the environment is Azure Stack admin.
Now, we are connected to it.
Now, let's go ahead and create
one resource group using our PowerShell session.
So in this case, the resource group name is "MyResourceGroup",
so let me go ahead and validate that from
the portal to see if a resource group with this name exist.
So let's go to admin portal.
Refresh this and I do not see "MyResourceGroup."
I see "MyResourceGroup1", but there's no "MyResourceGroup."
So let's go back to our PowerShell session,
select this command and go ahead and click on "Run."
Now, as we can see, the command completed successfully,
so that means the resource group is now created.
Let's go back to the portal and do validation.
If I go ahead and click on "Refresh",
there it is my resource group
has been created using the PowerShell session.
So that conclude this lab.
What we have done is we have been
able to connect to our Azure Stack admin,
our Azure Stack admin endpoint
and we have created a resource group. Thank you.
[MUSIC]