[MUSIC]
>> Hello, my name is Anil.
In this lab, we will show a demo on how to deploy Azure resources,
specifically a virtual machine with
a JSON template using Visual Studio,
and then we will validate
the deployment in Azure Stack admin portal.
The scenario is that we have deployed
an actual Microsoft Azure Stack instance,
and with that, we would like to
deploy Azure Resource Manager template using Visual Studio.
So let's get right into it.
First, let's talk about
the prerequisites for this solution to work.
At a high level,
you will need to have Visual Studio 2015 installed,
with the latest Azure SDK.
You also need to have an Azure subscription.
So that's all you need.
So first thing you want to do is deploy Microsoft Visual Studio.
Since I have done that already in the interest of time,
so I'm going to launch Visual Studio,
click on the "Start" button,
and type "visual", and double-click on that.
So I have opened the Visual Studio here,
and once you launch Visual Studio,
the first thing you want to do is
sign in with the username and password.
I have done that, so let me show you my account setting.
So this is the account that I'm going to use,
I have a subscription.
In case if you have more than one subscription,
then you want to make sure you have selected
the right subscription to deploy those resources.
So I'm signed into the Visual Studio,
let me go and close it.
Now, let's go ahead and click on "File",
and then click on "New",
and then click on "Project".
So as you can see here,
we have got "Azure Resource Group".
So we are going to select this,
and down, you need to give it a name.
So in this case, the default name is "AzureResourceGroup11",
so I'm going to go with the default name,
but you can call it whatever name that you prefer.
Go ahead and click on "OK".
Basically, what this file is,
it's a collection of
JSON file parameter and
a little bit of PowerShell that we will see in a second.
Now, by the way, we are going to
download a template to deploy virtual machine,
and we will download the template from
the Quickstart for Azure Stack on GitHub.
Under short template from this location,
you can see, we can see the templates for Visual Studio template.
There are Azure QuickStart feature template
or Azure QuickStart template on the GitHub.
For this demo, we are going to select
"Azure Stack Quickstart" templates.
Now, it has got bunch of
templates out there and you can
pretty much do anything that you want.
A lot of those templates are ready to use,
just download them and start using them.
So you can see,
there are a lot of different choices available for deployment,
but for today, we are going to deploy a Microsoft virtual machine.
Now, you can see
the different template as a blank template available,
you also have templates that you can use for availability set.
If I keep going further down,
you can use a template for network security group,
you could create storage accounts,
you can have NSGs, the VNET.
I will keep going further down until I find a template that I
can use to create a Microsoft virtual machine.
Let's keep going further down.
There is a Virtual Machine Scale Set,
and you can also use this template to apply some extensions.
So this is the template that I would like to use.
This template deploy a simple Windows VM,
and also deploy virtual network
with DNS network security group and network interface.
So that's the template that I would like to use.
Let's go ahead and click on "OK".
Now, you can see here,
we have the start page,
and we do not see the solution explorer,
so let me go ahead and
click on "Solution Explorer" to open that window.
Here, we can see different options that are available.
So we basically have references,
we have the actual JSON template,
we have got parameter,
and we also have a PowerShell script here.
So let me just drag this towards the left side here.
So we can see the template here.
So I have got this ARM template and if
I click on the actual JSON template,
so I've got this template,
there are lot of lines in it and we're not going to be
able to get into the details of how ARM template is configured,
that's more in-depth and it's outside the scope of
this exercise to cover all the details.
So this template is going to deploy a virtual machine.
It'll also deploy the virtual network
for routing the network traffic,
storage account, and that is actually
going to hold the VHD for the virtual machine.
Also, there are certain parameters that we are going to pass,
runtime parameter in the ARM template.
So in this case, we have the VM name for instance,
we also have got the username,
then we're also going to define
which OS version image we are going to use for this deployment,
and then the name,
the OS disk, the subnet.
So those parameters will be defined in the ARM template.
So what do we want to do is,
let's go ahead and deploy this template.
So right-click on it and say "Deploy" and click on "New".
Now, like I mentioned, in this case,
I have got multiple subscription associated with this account,
so I need to make sure I select the right subscription.
So I'm going to select under Azure Stack,
the default provider subscription,
and under resource group,
I see multiple resource groups created there.
But if there is a resource group that I
want to select that's already created, I can pick that up.
However, in this, I want to create a brand new deployment,
so I'll create a brand new resource group right here.
So let's click on "Create",
and I would call this resource group as "MYVMRSG",
and then select a location as "local",
and click on "Create".
So this resource group should be created instantaneous,
it should have been done right now.
So resource group is now ready.
Now, first, before I go ahead and deploy the template,
I want to make sure the template is okay.
I would like to validate and test this template,
so I'm going to place a check mark
under "validate only" and don't deploy,
and then go ahead and click on "OK".
So let me show you how to test template looks like.
So if you see down here on the output window at the bottom,
you can see they started deploying them,
provisioning status is running,
and you can see that's how it works.
So you can see the resource group name, the location,
the provisioning status, any tags that you may have mentioned,
and it says the template is valid.
So that's how I know this template is okay,
but that doesn't necessarily mean the template is not
going to generate any errors or warnings at runtime.
It may very well but what it really means is,
we looked at the template,
we looked at the corresponding parameter,
and they all checked out to be okay.
So now, before I go ahead and deploy the ARM template,
I would like to show you the resource group that we
created a couple of minutes back.
So let me go ahead and refresh it,
and there is a resource group,
"MYVMRSG".
If I click on it,
you can see that there are actually no deployment,
there are no resources in this.
So this is just a proof positive that
there is nothing here before we executed the templates.
Let's go back to the Visual Studio,
and we are finally going to execute our template.
So right-click on it and say "Deploy", and select this.
This time, we are going to go ahead and deploy
the template and click on "OK".
Once you click on "OK",
you will see PowerShell window,
and that will disappear quickly.
So now, if you look at
here on the output window down at the bottom,
it started deploying them and provisioning status is running,
so you can see the different statuses here.
Right now, it clears
the deployment and it is deploying the network security groups.
So it's going to take some time,
but what we can do is we can go back to the resource group now,
and then just do a quick refresh.
As you can see,
it has already started deploying some of the resources.
However, it is not completed yet,
there is still some configuration going on.
If I go ahead and click on "Deployment",
then a new blade will open up.
It shows the status of this deployment.
It's in progress, it has been running for last 52 seconds.
If I click on the "Deployment",
it'll give me a status of
all the resources that we have
deployed and how the deployment went,
as well the environment variable that we pass.
So I can view the deployment here.
Once the deployment is completed,
I will also have an option to
redeploy the deployment which is a nice thing.
So while this is being created,
if you go back to the Visual Studio,
you have an option to define your own parameters,
you can put your own subnet mask,
your own IP address,
the OS disk name,
the Windows image offer,
the location, so all those values that you
can go and change according to your requirement.
Now, I'm going to go back to the portal one more time,
and then let's go and hit "Refresh" once.
As you can see, it has deployed quite a bit of resources now,
and right now, it is provisioning the virtual machine.
So if I click on "Virtual Machines" here,
I can see the VM status it is being created.
If I click on it,
then I will have an option to click on "Connect".
However, the virtual machine is still being created,
and it's going to take some time to
complete this process and then I will be able to connect to it.
So that concludes this lab.
So we have deployed
a Windows virtual machine with
the JSON script and using Visual Studio.
Thank you for watching.
[MUSIC]