When beginning a cloud improvement/optimization project, an easy place to start is to focus on the initial low-hanging fruit of your virtual machine (VM) environments. This article takes a closer look at these steps, using a Microsoft Azure VM environment as an example.
Here are five best practices that can be easily achieved when using VMs on Azure cloud.
1. Properly Size Your Virtual Machines: To maximize performance and minimize costs, it’s important to size your VMs appropriately. You can use the Azure portal to determine the right size for your workloads and then select the right VM size based on the CPU, memory and storage requirements of your application. For example, you can use the Azure VM sizing calculator tool to get an estimate of the virtual machine size based on your workload requirements.
Let’s say you want to host a web application that requires 2 vCPUs, 8 GB of memory and 50 GB of storage. You can use the Azure VM sizing calculator tool to determine the appropriate VM size based on these requirements. The tool may suggest using a “Standard B2s” VM which has 2 vCPUs, 4 GB of memory and a maximum disk size of 32 GB.
In this case, you would need to increase the disk size to 50 GB. You can do this by adding a data disk to the VM or using a larger VM size with enough disk space. For example, you could use a “Standard B4ms” VM with 4 vCPUs, 16 GB of memory, and a maximum disk size of 64 GB.
It’s important to note that the actual VM size may vary based on your workload requirements and the specifics of your application. The Azure VM sizing calculator tool provides a helpful starting point, but you should also perform your own testing and validation to ensure that the VM size meets your needs.
2. Use Managed Disks: Managed disks provide increased reliability, scalability and security compared to traditional storage accounts. For example, you can use managed disks to automatically scale the disk size and performance as the data grows and to replicate data for disaster recovery.
For example, to create a 100 GB managed disk, follow these steps:
- In the Azure portal, go to the “Disks” section and click on “Add.”
- Select “Blank disk” as the source and specify the disk size as 100 GB.
- Choose the appropriate storage account type (Premium or Standard), replication options and disk type (HDD or SSD).
- Give the disk a name and create it in the same resource group as your VM.
- Once the disk is created, you can attach it to your VM by going to the virtual machine’s “Disks” section, clicking on “Attach,” and selecting the newly created disk. By using managed disks, you benefit from automatic disk management and replication as well as improved reliability and security compared to traditional storage accounts. Additionally, managed disks simplify the process of attaching and detaching disks to and from VMs, making it easier to manage your storage resources.
3. Enable Monitoring and Diagnostics: To monitor the health and performance of your VMs, you can use Azure Monitor which provides real-time insights into resource utilization, application performance and other key metrics. You can also configure alerts to notify you of potential issues and diagnose problems using Azure Log Analytics. For example, you can set up an alert to notify you if the CPU usage of a VM exceeds a certain threshold.
You can also use Azure Monitor to gain real-time insights into the virtual machine’s resource utilization, application performance and other key metrics by following these steps:
- In the Azure portal, go to the virtual machine’s “Monitoring” section.
- Click on “Diagnostic settings” and then click on “Add diagnostic setting.”
- Give the diagnostic setting a name, select the VM you want to monitor and choose the metrics and logs you want to collect.
- Choose the storage account you want to use to store the monitoring data and specify the retention policy for the data.
- Click “Save” to apply the changes.
By enabling monitoring and diagnostics for your virtual machines, you can proactively monitor the health and performance of your VMs and quickly identify and resolve potential issues. Additionally, you can use the collected data to generate reports, visualize trends and perform analysis to gain deeper insights into the performance of your VMs.
4. Implement Security Best Practices: To secure your virtual machines, you can use Azure Security Center to implement security best practices and monitor for potential threats. You can also use Azure Active Directory to control access to VMs and secure your identity management. For example, you can use Azure Security Center to assess the security of your VMs and implement security recommendations such as enabling network security group (NSG) rules to restrict inbound and outbound traffic.
If you have a VM that you want to connect to other resources in your Azure environment, you can use a managed virtual network to provide a secure and scalable networking solution for your VM.
Here is how to create a managed virtual network in Azure:
- In the Azure portal, go to the “Virtual network” section and click on “Add.”
- Give the virtual network a name, select the appropriate subscription and resource group and specify the address space.
- Create one or more subnets within the virtual network, and specify the subnet address range and subnet name.
- Associate the virtual network with a network security group (NSG) to control inbound and outbound traffic.
- Create a network interface for your VM and associate it with the virtual network and subnet you created.
By using a managed virtual network, you can create a secure and isolated network environment for your VM and connect it to other resources in your Azure environment. Additionally, you can use the virtual network to control and manage network traffic and implement advanced networking scenarios such as load balancing, VPN connectivity and more.
5. Keep Virtual Machines Up-to-Date: Regularly updating your VMs with the latest security patches and software updates helps ensure that they are protected against potential threats and vulnerabilities. You can use Azure Update Management to automate the update process and keep your VMs updated. For example, you can schedule regular updates for your VMs to ensure they always have the latest security patches and software updates installed.
When planning public cloud environments, two commonly used words are “progress” and “results.” Following the best practices above will help position your cloud journey for success.