Hi, I am Vinay. I am a Certified Azure Architect and I am experience in Azure Architecting, Database Architecting, Cloud migrations, DBA by profession for more than a decade. This blog I use for sharing the new things I learn and the day-to-day issues I face. I also share other technical topics which I find useful to the readers. I invite you to follow me on LinkedIn, Twitter and this blog.
Tuesday, December 19, 2023
Cost of CosmosDB.
Monday, December 18, 2023
Cost saving in Azure SQL Managed Instance.
Friday, December 15, 2023
Cost saving in Azure SQL Database.
In your mobile phone there is a setting to turn off the screen if there is no activity for a certain amount of time. This helps in saving battery.
Similarly, if there is no activity in Azure SQL Database, we have an option to pause the database. This helps in saving cost.
The feature is called 'Auto-Pause' which is available in the Serverless Compute tier.
Once enabled the database will be paused if the CPU = 0 and number of sessions = 0 for a certain amount of time. The threshold that can be set is between 1 HR to 7 Days.
Eg: If we set auto-pause to 1 HR then if the CPU = 0 and number of sessions = 0 for more than 1 HR then the Azure SQL database will be paused.
This feature is supported only in vCore Purchase model and the Hardware Type supported is Standard-series (Gen-5).
The billing is done per second. For a minimum configuration of East US region, it would cost roughly 43 rupees per hour so almost 2000 rupee (almost $24) per weekend for a single database.
If we do a simple math approximately there are total 105 days as weekend in the year 2023. So if we calculate cost for all these days it would total to around 1 lakh rupees ($1300 roughly per year) for a single database.
If your DB will not have any activity during the weekend and by enabling this auto-pause feature this amount of cost saving can be done.
Thanks VV!!
#azuresql #azurearchitect
Friday, July 28, 2023
How to move a Database from one Azure SQL Managed Instance to another Azure SQL Managed Instance.
In Azure SQL Managed Instance we have the option to move the database between Azure SQL Managed Instances. It is quite simple to move the database from one SQL managed instance to another SQL managed instance. In this article we will see how to move or copy an sql managed instance database from one azure sql managed instance to another azure sql managed instance.
Login
to the Azure portal and search for SQL managed instance.
Click on the SQL managed instance and the database inside the managed instance which you want to move. Here I have only one sample database named ‘WideWorldImporters’ once you click on the database you should see an overview page like below
on the Overview page you can see several options and among them, there are 2 options COPY and MOVE. Copy is to copy the database to another subscription by keeping the original database in its source and move will move the database from the source location to the destination location.
Now
click on copy and we should see a similar page like below.
Here
we need to provide the destination resource group and the SQL managed instance.
After
that once we click on ‘Review+Start’ the copy process will start and if any
errors pop up we need to remediate those before copying can start.
Similarly,
we can also move the database by clicking on the MOVE button and selecting
source and destination SQL managed instances and their respective resource
groups and click on Review+Create as shown in below pictures.
Thanks
VV!!
#sqlmanagedinstance #azure #azuresql #azurearchitect #cloudarchitect
Wednesday, July 12, 2023
How to share Azure compute gallery to all Azure users.
In the previous article, we have seen how to create an image of Azure VM. When we create an Azure VM Image it will reside in storage and can be used any number of times we want for the creation of identical VMs. But let’s say we want this VM Image to be available across the entire company or multiple subscriptions so that any authorized team in the organization can create new VMs based on the image. We will see in this article how to achieve this requirement.
In Azure, we
have the option to share the images and Azure compute gallery to make them
available for all the required resources. In the previous article while
creating an Azure VM Image we first created an Azure Compute Gallery. This
Azure Compute Gallery acts as a repository of all the images we create.
Note: Microsoft does not recommend sharing
the VM images individually and only recommends sharing the Azure compute
gallery. Hence in this article, we will see how to share the Azure compute
gallery.
When we login
to the Azure portal and search for ‘image’ in the search box, we can see
‘Images’, click on it
After
clicking it will show us all the VM image versions
Click on the
‘1.1.0’ image version which we created in the previous article
And it will
show the overview page of the image version
To find to
which Azure compute gallery this image belongs to, on the right-hand side we
can see ‘Azure Compute gallery’. Here we can see this image belongs to the
Azure compute gallery ‘VMIG’. Click on the VMIG
That will
take us to the overview page of Azure compute gallery VMIG and here we can see
all the images that are in this gallery and the details of the image like OS
type, OS state, and so on.
On the left
side of the page, we can see a section named ‘Sharing’. Once we click on it, we
can see different sharing options available
Based on our
requirement we can select the type of sharing. I’m selecting ‘RBAC+ share
directly’ and at the bottom, we can see ‘Tenants and subscriptions’ under this
we can select to what all tenants and subscriptions we want this has to be
shared. After selecting click on ‘Save’. Once settings are saved this gallery
images will be available for all the selected subscriptions and tenants.
A Tenant in Azure is nothing but an instance of Azure Active Directory (Azure AD) which contains information like objects, users and groups about a single organization. It also contains access and compliance policies and its primary function is resource access management and identity authentication.
The gallery
can be shared with individual users, groups, service principals, and all users
of specific subscriptions or tenants and also can be shared publicly to all
users in Azure. Based on the sharing type we select it will depend on to whom
we can share. Example: In the above screenshot I selected ‘RBAC+ share
directly’ so when we select this option the gallery can be shared to individual
users, groups, service principal, and all users of specific subscription or
tenant but we cannot share publicly to all users in Azure.
You can follow
me on LinkedIn and Twitter for more articles.
Thanks VV!!
Tuesday, July 4, 2023
How to create our own VM image in Azure similar to Azure marketplace image.
We all know Azure marketplace have wide variety of
images with different combinations like different OS versions, different OS+DB
versions and so on. Let’s say we have a customer VUT and all the Virtual
Machines created for this customer should have some applications running in
them as per their policy or requirement and installing and configuring 100s of them
takes some time. So instead of installing the required applications manually every
time on all the VMs we can create our own VM Image just like Azure marketplace
image and use our VM Image across the company to create new VMs which will have
the required applications comes along with image.
Another use can be when we have to create multiple VMs with same configurations like OS disk or both OS and data disks we can use VM Image concept in Azure. This helps in scenarios like all the VMs in an environment should have similar configurations for example all the test VMs should have identical configurations then instead of creating each VM manually and configuring them we can use VM Images.
How to create a Azure VM Image.
In this article we will see how we can create VM Image
and in the next article we will see how an VM image can be shared across all
the subscriptions of an organization.
- Login to Azure portal and search for ‘Virtual
Machine’
- Select the VM for which you want to create an
image. In my case I want to create an image for virtual machine named
‘VM1’.
- Click on VM1 and you can see settings of VM1. In
the same ‘Overview’ click on ‘Capture’
- ‘Create an image’ page will open and here enter
Resource group details where you want create the image and select ‘Yes,
share it to a gallery as a VM image version’.
- We can store the images in a Gallery which helps
in sharing the image across the company and across the regions. This
gallery in simple terms acts as a repository.
Create an image gallery to store the VM image. If gallery doesn’t exist
already in the resource group click ‘Create new’.
- Give ‘VMIG’ as image gallery name and click ‘OK’.
- You can check the option ‘Automatically delete
this virtual machine after creating the image’ if you want to delete the
source VM once the image creation completes. But it is recommended to have
the source VM in place even after image creation.
- Azure compute gallery supports 2 Operating System
States. Generalized and Specialized. Generalized means the machine and user
specific information will be removed from the VM before creation of the
image and in Specialized state this information will not be removed. Both
the options have their own advantages and disadvantages. Specialized state
will not have osprofile in it, osprofile helps in passing sensitive
information to VM via secrets but advantage of specialized VMs is they can
start and run faster than the Generalized VMs. So as per your requirement
you can choose suitable option.
Here I select Operating system state as ‘Generalized’.
- Create VM image definition at ‘Target VM image
definition’. Here I’m giving name as ‘VM1Image’. Select publisher and
other details as shown below and click ‘OK’.
Image definition basically will have details about the image like OS
details, SKU details, VM generation and so on. This information helps in
logical group of images and also helps the user who is using this image to identify
the type of image being used.
- Under Version details, we can give ‘Version
number’ for the image, I’m giving as 1.1.0 and leaving other details
empty.
Versioning of image helps in segregating the images. For example, we can
have dedicated version for all production images, another dedicated versioning
for development images. Also, versioning helps in identifying the older and
newer versions.
- ‘End of life date’ this option helps in making
user aware if the image they are using is latest one or old one. VMs can
still be created after the end-of-life date of the image but it will act
as an indicator for the user to know the image is outdated. I’m leaving this
as empty.
‘Shallow replication’ option creates
the image faster as it will not copy the image. This option can be selected if VMs
have larger disks as image gets created faster but you can’t deploy large number
of VMs concurrently if this option is selected. It is recommended to check this
option for development and test environment. I’m leaving this option unchecked.
- We can copy the image we are creating to multiple
regions using ‘Replication’ option. To how many regions we want it to be
replicated and to which regions it has to be replicated can be configured
under ‘Replication’.
Under ‘Replication’ I’m giving ‘Default replica count’ as ‘1’ and selecting ‘(Asia
Pacific) Central India’ so the image will be replicated to this region.
- Now click on ‘Review+Create’.
- Wait for the image to be created.
- Once the image creation is completed click on ‘Go
to resource’ it will take us to the image we created.
- In ‘Overview’ section of the image you can see 2
options like ‘Create VM’ , ‘Create VMSS’. We can use these buttons to
create a new VM or VMSS using the image we created. Click on ‘Create VM’.
- If we click ‘Create VM’ it opens ‘Create a
virtual machine’ page and here if you scroll down you can see under ‘Image’
section the image we just created already selected.
- You can fill the other details and simply
click on ‘Review+Create’ and a new VM gets created which will have same
configuration as the image we used.
Hope this article helped in learning how to create our
own VM image in Azure similar to Azure marketplace image. Share your inputs in
comment section below.
Thanks VV!!
Wednesday, May 17, 2023
How to save cost in Cloud Environment.
The common misconception is
that if we move to cloud the cost will reduce automatically but in most
scenarios that is not the case. How much cost you save in cloud will be
determined by the services you choose and next will be determined by which cost
saving strategies you are following in your environment.
There are several strategies we can follow to optimize cost in Cloud environment. We will see high level view of those strategies here.
- Removal of Unused
Resources :
Yes, as per my experience one of the biggest mistakes cloud teams,
especially migration teams, do is not tracking the resources that are
created as part of migration activities. As multiple technical teams are
involved in cloud migration projects the main vacuum that appears is not
knowing what all resources are getting created by what all technical
teams. So, one important task cloud migration teams should add to their
project is tracking all the resources that are getting created as part of
the project and cleaning up of all the resources that are not in use on a
regular basis. This will amount to lots of cost saving for the customer.
Also, no need to mention separately that most of this tracking and removal
of resources can be automated.
- Turn off the lights when
not needed :
This strategy is straight forward shutting down of the resources when they
are not in use. Except production servers the other servers like Dev, Test
will not be in use round the clock. So, any lower environment servers
which are not required to be running after business hours need to be
stopped on a regular basis. This will save lot of cost its similar to
turning off the lights in the house when you are going out.
- Which size fits you? : This is one of
the most overlooked aspect. We all know there is no one size that fits all
of us in a similar way; we should not assume blindly that one size of VM
or one series of VM will suit all servers in a particular environment. For
example, there is no guarantee that all the VMs in a Test environment will
be of the same size or will require the same level performance. In a
environment each server will have its own resource requirements so while
deciding the server sizes or compute of any environment we should first
carefully calculate how much resources that particular VM require and
accordingly we should select the suitable series\sizing.
- Are you using it? : This
reminds of my friend who took a loan of 10 lakhs when he needed a loan of
7 lakhs. Now, he pays interest for entire 10 lakhs instead of his required
7 lakhs. Similarly, we should never equip the resources with more than
what they require. So regularly monitor how the cloud resources are used
and if you notice a pattern of any cloud resources which are underutilized
then you should plan and size those resources right. For example, if all a
server needs is the performance of medium web traffic and you are using H
series or F series, then it's obvious that it's underutilized so
monitoring the server usage patterns and reducing it to D series will save
a significant amount of money.
- Does this DB need a
dedicated VM ? : Now as part of cloud migration the majority
of the SQL Server instances are moved to cloud IaaS environment and this
is one of the sections where a lot of cost can be saved. I have seen
several VMs which are holding 2 to 5 databases that too non-critical
databases and getting migrated to cloud as it is to IaaS. In on-premises
we don't have any such option or facility to run database as
an independent resource but that is not the case in the cloud
where we can run only a single database without needing to configure VM,
we should make use of it. Evaluate all your database servers before
migration or even post migration and wherever possible move to PaaS
instead of IaaS.
- Group the DBs : One of
our customers has made a correct decision and moved several SQL Server VMs
to PaaS while migrating to cloud. But the catch is they moved each DB to a
separate PaaS resource and ended up resulting in high cost in cloud. Now
after analyzing what we realized is the move to PaaS is correct, but they
should have used DB Elastic Pools instead of individual Azure SQL DBs so
that bunch of DBs in pool would use common resources whenever required and
this would have saved lot of cost instead of allocating resources to each
Azure SQL DB separately.
- Budgeting : Another
strategy to track and optimize cost is budgeting. In Azure you can create
budgeting and set up alerting for actual costs and forecast costs. This
helps in understanding the actual usage and also to forecast the cost
according to the on-going spending. Accordingly, decisions can be made to
optimize the costs. One good example is one of our test subscription which
has to be taken down after analyzing the budget forecast as the cost of
the subscription started to go way more than expected.
- Licensing : A lot can be
saved when it comes to Licensing in Azure. There are multiple
strategies like Azure Hybrid Benefit (where you can use your on-prem
license in cloud), Azure Reservations (reserving required resources for
certain time period to avail discount price provided by MS instead of Pay
as you go) and so on.
There are many other ways as
well to reduce the cloud spending but as your cloud usage increases and cloud
environment starts expanding you can plan and implement suitable strategies as
per your environment.
Share what are the different
cost optimization strategies you use in your environment that help readers.
Thanks VV!!
#costoptimization #cloudmigration #azure #sqlserver #azurearchitect