In this demonstration we're now going to go about creating a virtual network and a subnet via the portal.
And then we will follow that on by creating a series of subnets using power shells so we can do things
much more quickly.
But let's get started in the azure portal.
So to begin with I've already created a new resource group called SSL dash network.
And on the left hand side I'm going to select virtual networks.
And as you can see no networks currently present.
So let's go ahead and select ad and the network blade comes up for creating a new virtual network.
And let's give this one a name.
So the first one we'll call SL dash seventy five three three dash portal.
Now we are going to go too much into address spaces in this course there's plenty of youtube videos
on subnet and if you want to go about reading that but for the purposes of this course I'm going to
create a slash twenty three network for this one so 10 0 0 0 slash twenty three and then I'm going to
create to slash 24 subnets inside that slash twenty three.
Next thing we need to do is go ahead and select the subscriptions museum or pay as you go choose our
Resource Group.
So choose a cell dash network and you can see I'm doing this in north central U.S. and now I need to
name my subnet.
So the first one you can see it creates a default subnet called call the subnet a
and we're going to give it the address range of 10 0 0 0 slash 24.
That's the first slash 24 inside of our slash 23 range.
We'll go out and click Create you kind of create one subnet at this point from the portal and within
probably 30 seconds or so our network will be created.
But we'll speed things up here and that's created.
So hit refresh and there is our network.
So now let's go inside them and we can see if we scroll down to address space.
We've got our 10 0 0 0 slash twenty three and that's going to subnets and we can see we have subnet.
But let's go ahead and create subnet B
and you can see it's already picked the next slash 24 for us so 10 0 1 0 slash 24.
And if you look closely underneath it saying address range is 10 0 1 0 2 10 0 1 255.
So we actually only have 251 usable addresses in that because five are reserved for Azure.
And we're not going to cover network security groups and roundtables yet we'll come on to those later
on.
So go ahead and click Okay.
And that will create our second subnet should only take a couple of seconds and we should have our subnet
so you can see we now have a vignette with two subnets subnet a and subnet B.
All right.
So we can do things via the portal but it can get a little bit cumbersome particularly when I want to
create a lot of subnets for that in this next example I'm going to use power show instead.
And let's start off in Visual Studio code where I've already got a power show script ready then I can
walk you through.
So the top section of the script is just declaring kind of the global pieces I need.
So the resource group and the locations in this case I'm going to deploy this new virtual network along
with its subnets that you'll see shortly into SL dash network the same resource group it used before
and in the same location north central U.S. The second section I've got my V-neck name and address space
I'm calling this one SL dash seventy five three three dash v net dash P shell to differentiate it from
the portal one and I'm increasing my address space this time I'm going to use a slash 22 because inside
of that such 22 I'm actually going to create three slash twenty fours and there wouldn't be enough space
if I just stuck with the slash twenty three.
Now the next section I declare some variables around my subnets just sort of to type everything and
with every line so I've got subnet a name which is SL dash web and that's the first slash twenty four
10 0 0 0 then I've got my next slash 24 for SL dash app which is 10 0 1 0 and then my next one for SL
dash data which is 10 0 2 0 next I declare a variable which I'm going to use when I create the vignette
itself and I just call this $ subnets and in this one I created a new Azure R and virtual networks subnet
config and this takes subnet A's name and subnet A's address prefix and adds that that's so think of
this like when I created that B net in the portal I associated a subnet with it this is the first one
the scroll further down this is where I actually create my vignette and I include that subnet configuration.
So I'm declaring this is a variable I'm going to use it a little bit later but the command here is new
dash as you are am virtual network followed by the name of the vignette which again is SL seventy five
three three dash v net dash P shell which I stored further up my resource group name my location and
the address prefix for the V net as a whole.
And then the first subnet I want to create which I reference with Dash subnet $ subnets being my variable
for that at this point the network is created but now I want to create those additional subnet so I
use these additional commands which are add as you are and virtual network subnet config I reference
the virtual network I then reference my subnet configurations which is my name so subnet B name followed
by subnet B's address prefix and then I run that same command again for subnet C following that I have
to do one last task which is to save the additional subnet configurations there are only local at that
point they haven't been set against the virtual network so I simply do a set as you are and virtual
network and specify the V net and then that will save the changes that we added We added the additional
subnets.
So with all that let's go over to power show and run this
and I've got it here in my C drive scripts skylines network folder and I'm simply going to type in create
so create to be that top piece one is the file I've got hit enter and that is not gonna go off and do
all the hard work for us so we'll give that about 20 seconds or so here
and that's completed and then it's added the additional subnets
and now it's saved that config.
So if we go over to the Azure portal now go back into virtual networks and do a refresh.
I now see I have this power show version as well so we'll select this one and in there if I go down
to subnets you will see that I have my web app and data subnets as well.
So hopefully you can really see the flexibility and the ease of use that power show will allow you have
a highly encourage you to get used to it straight away and you almost certainly will get questions on
the exam related to power show commands in this area.