This is Part 6 of azure tutorial. In our previous video, we discussed azure resource groups. In
this video, we'll discuss the benefits. Before we discuss the benefits, let's quickly recap the main
and important points of azure resource groups. An azure resource is any service instance that you
create. For example, virtual machine, azure sql database, storage account etc. A resource group
on the other hand, as the name implies is a group of related azure resources. In general, resources
in a resource group share the same lifecycle, so they can be easily created, deployed, updated
and even deleted as a single unit. When you create a resource group, you specify a region.
It is this region, where the metadata about the resource group is stored. However, the
resources themselves can be in any azure region. Resources in one resource group can interact
with resources in other resource groups. Each resource must be in one and only one resource
group. You cannot have a resource in more than one resource group at the same time. However,
you can move a resource from one resource group to the other. You can add or remove a resource
from a resource group at any time. You can group resources any way you want, anyway that makes
sense to your organization really - by department, by country, by application, by resource type
or even a combination of these. Now, let's take a look at the benefits of azure resource groups. One
of the main benefits is, administration is much easier. Let's understand this with an example.
Consider a virtual machine. When we create a virtual machine in azure, several other associated
resources are automatically created like the following - a disk for the virtual machine,
public IP address, network interface, network security group and a virtual network. Without
these resources, an azure virtual machine doesn't work as expected. After you're done with the VM,
you may want to delete it to save on cost. However, when you delete the virtual machine,
the associated resources are not automatically deleted. You have to delete them manually. If you
forget to delete one or more associated resources, you are unnecessarily paying for those resources
that you're not actually using. Now, let's quickly take a look at this in action. Let's flip over to
azure portal. At the moment, we're on the home page. Let's navigate to "All services" page
by clicking on this "More services" link, and then we are creating a virtual machine here.
So, let's search for "virtual machine". Hover over "Virtual Machines" and then click "Create"
As usual, when creating an azure resource, the first thing that we need to select is
the "Subscription". Let's select the "Free trial" subscription and then the "Resource group". If you
remember, we created this resource group in our previous video. So, let's select this and then
a name for our virtual machine. I'm going to call this "vmpragimtechdev". vm stands
for virtual machine, pragimtech is the name of the app that we are using this vm for and finally the
deployment environment we're going to use it for - development environment. So, by looking at
the name, we can be sure what is the purpose for which we are using this virtual machine
and then the region. Now, notice, by default it selected South India region because this is where
we have our resource group created. Now, just to prove that
the resource itself can be in any azure region, let's select the region to be East US.
Next, Image. Image is the operating system that you want on this virtual machine. Let's select
Windows Server 2019, and then you have to select a size for your VM. Again,
there are several choices here. Let's go with one of these choices and then we need to provide
a username and password that we can use to connect and log into this virtual machine.
Let's leave the rest of the options with the default values and then review and create.
Validation passed. So, let's click "Create" to have our virtual machine created.
Notice, several resources are being automatically created.
There we go. Deployment is complete, that is, our virtual machine is successfully created. Now,
let's navigate to this resource group. Notice, in our resource group "rg-pragimtech-development",
in addition to the storage account and virtual machine that we explicitly created, we have
several other resources like virtual network, public IP address, network security group, network
interface and a data disk. We didn't create these resources explicitly, when we created this virtual
machine. All these other associated resources are automatically created. Now, let's see what's going
to happen, when we try and delete this virtual machine. So, let's click on the virtual machine
name. At the moment we are on our virtual machine "vmpragimtechdev" and notice what's going to
happen when I click this "Delete" button. We have an alert here. This action will permanently delete
the virtual machine "vmpragimtechdev", but the associated resources like the disks, virtual
networks IP addresses, all those resources that were automatically created will not be deleted
and we have to remove them manually. Do you want to continue? So, when deleting a virtual machine,
the associated resources are not automatically deleted. We have to delete them manually. What
if you forget to delete one or more resources? You are unnecessarily paying for resources that you're
not actually using. Now, the good thing that we have done is, created this virtual machine in
this resource group "rg-pragimtech-development". So, let's go to this resource group and then if I
try to delete this resource group, it's going to delete all these resources automatically. I don't
have to delete them manually. So, administration is much easier. Now, another example. Let's say,
you are creating a web application. To aid this, you need several resources like a virtual machine,
storage account, SQL database, virtual networks and many other dependent and related services.
Without resource groups, if you have to develop and deploy this application you have to manually
create all these azure resources, that too, you have to create them in the correct order. If it's
just one time, then it's okay, but in real world, with every company using agile approach and CICD,
that is, Continuous Integration and Continuous Deployment, applications are deployed several
times a day. For example, every time a new piece of code is checked in to the source control,
a new build is deployed, maybe to the test environment. So, every time you have to do this,
if we have to create all these resources manually, it's not only tedious and time consuming
but also error prone. What if you create the resources in the wrong order or even worse,
what if you forget to create a resource? It gets even more messy and complicated,
if you have to manage multiple applications and multiple deployment environments. With resource
groups on the other hand, you can group related resources any way you want. Maybe for example,
by application and by deployment environment. This grouping obviously allows you to manage
all the resources that belong to a specific application and deployment environment as
one unit. You can even automate deployments using azure resource manager templates. We'll discuss,
resource manager templates in our upcoming videos. Another great benefit with resource groups is,
cost management is much easier. At the moment, we are looking at our resource group
"rg-pragimtech-development" and notice we have Cost Analysis blade here. Let me click on this.
At the moment, we only see the cost for the storage account because we just created
our virtual machine and which in turn obviously created several other resources. So, the idea is,
you can see the cost of running each resource. You can also see the total cost of all the resources
in the resource group and when we are done with a set of resources, there is no need for us
to manually delete each resource individually. When we delete a resource group, all the resources
in that group are also deleted. This obviously eliminates any possibility of orphaned resources,
that is, ghost resources left running and as a result running up costs. Another great benefit is,
role-based access control can be applied at the resource group level. Notice, on the left here,
we have this tab "Access Control", and using this blade, we can apply role-based access control.
This makes it much easier to manage user access to the resources in the group. When the user
logs into the azure portal, they will only see resource groups that they have access to and not
others within the same subscription. However, administrators will still be able to assign
access control for users to individual resources within the resource group based on their roles.
So, the point that I'm trying to make is, resource groups offer great benefits both to developers and
administrators. That's it in this video. Thank you for listening.