<p style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Designers and developers often work with systems that require a lot of CPU and storage power. This is because the development and deployment of apps, video editing, batch processing, machine learning, etc., require a lot of energy from the hardware. However, Azure’s Virtual Machines are an excellent alternative for professionals to work with. In Azure, a Virtual Machine (VM) is a service that allows you to create and work with virtual machines on the cloud.</span></p><h2 style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Introduction - Virtual Machine in Azure</span></h2><p style="text-align:justify;"><span style="font-family:Arial,sans-serif;">To understand in simple terms, a virtual machine in </span><a href="https://devopsden.io/article/what-is-microsoft-azure"><span style="font-family:Arial,sans-serif;">Azure</span></a><span style="font-family:Arial,sans-serif;"> is like the name suggests - it is a virtual setup on the cloud that you can use just like your physical PC. In this digital version, you can choose the specifications like CPU, memory, etc., similar to that on your laptop or personal computer. </span><br> </p><p style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Microsoft refers to virtual machines as "software-defined computers" that exist within physical servers, basically just as codes. These on-demand services are created using the concept of virtualization of hardware. As a service listed under Azure's Infrastructure-as-a-Service (IaaS), virtual machines can be made as per the user's needs, and the fee for these machines is determined by the storage size and other factors.</span></p><h2 style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Different Sizes in Azure Virtual Machine</span></h2><p style="text-align:justify;"><span style="font-family:Arial,sans-serif;">In the VM service offered by Azure, it is crucial to choose the right storage size to work efficiently on the cloud. Based on the workload on the virtual machine, you should pick the size of the machine. Here are some of the different types of machines and sizes Azure offers.</span></p><ol><li><span style="font-family:Arial,sans-serif;">General Purpose: The sizes for general purpose machines include B-series, D-series, and E-series. These sizes are used for hosting web servers, handling small and medium-sized databases, and developing and deploying applications. These virtual machines have a balanced CPU-to-memory ratio.</span></li><li><span style="font-family:Arial,sans-serif;">Compute Optimized: The compute-optimized virtual machines are used for processes that require a lot of CPU energy. For example, batch processing and batch coding are some of the activities done on these VMs. H-series, F-series, and M-series sizes are used for compute-optimized VMs.</span></li><li><span style="font-family:Arial,sans-serif;">Memory Optimized: While compute-optimized VMs are for CPU-intensive tasks, memory-optimized is for memory-intensive activities like machine learning and in-memory analytics. The ratio here leans towards more memory - the M-series, G-series, and GS-series sizes are suitable for these tasks.</span></li><li><span style="font-family:Arial,sans-serif;">Storage Optimized: As the name suggests, these VMs are for storage-intensive tasks - big analytics and data warehousing fall under this category. The storage to CPU and memory ratio is high, making them the perfect choice for these tasks. The L-series and H-series sizes are used for storage-optimized VMs.</span></li><li><span style="font-family:Arial,sans-serif;">GPU Optimized: These VMs are made for high-density graphical workings and video workloads, making them computer-intensive. The N-series is used for GPU-optimized virtual machines to manage the dense workload.</span></li></ol><p style="text-align:justify;"><span style="font-family:Arial,sans-serif;">The hourly charges are calculated based on the VM size and the operating system that the user is utilizing.</span></p><h2 style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Uses of Virtual Machine in Azure</span></h2><p style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Azure VMs are utilized for various purposes like deploying apps on the cloud, testing new operating systems, and accessing corrupted data. Here are a few other uses of virtual machines in Azure.</span></p><h3 style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Building Applications</span></h3><p style="text-align:justify;"><span style="font-family:Arial,sans-serif;">A main chunk of users who utilize Azure VMs are software developers. Virtual machines provide you with the perfect environment to develop and deploy an application. Since you can pick your own operating system, you can create apps for any OS and test them to see their effectiveness.</span></p><h3 style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Disaster Recovery Cases</span></h3><p style="text-align:justify;"><span style="font-family:Arial,sans-serif;">One of the most outstanding features of virtual machines is that users can back up their OS data on a virtual machine for future use. This comes in handy in disaster recovery cases and cases of file corruption. Backing up your data on a virtual machine can be a game-changer as you can ensure that all the necessary information stays safe.</span></p><h3 style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Managing Dense Workloads</span></h3><p style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Users prefer virtual machines because they can select the desired CPU, storage, and memory requirements to manage high workloads. This feature is handy for designers and developers who work remotely - by creating VMs that handle high-density workloads, they can manage their designs from remote locations.</span></p><h3 style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Trial for New OS</span></h3><p style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Azure VMs can be used to try new operating systems you want to install on your physical setup. By exploring the positives and negatives in terms of the performance of the OS in the virtual machine, you can determine whether you want actually to install it on your device.</span></p><div class="raw-html-embed"><iframe width="100%" height="400" src="https://www.youtube.com/embed/rfms1VW5HJY?si=-lqE6H61mZKQjsVk" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen=""></iframe></div><h2 style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Advantages of Using Azure Virtual Machines</span></h2><p style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Virtual Machines in Azure are like individual computers but without the hardware. This makes the service a convenient one for users across the world to operate them on cloud simply. Virtual machines boast many advantages, as briefed below.</span></p><ul><li><span style="font-family:Arial,sans-serif;">Cost efficiency - Using a single virtual machine, you can run multiple projects and tasks, thus saving costs used for physical infrastructure. Down the road, it also saves maintenance costs.</span></li><li><span style="font-family:Arial,sans-serif;">Scalable - A great feature of VMs is that you can distribute workload among other virtual machines. By doing so, you can quickly scale the applications you have developed and increase their performance.</span></li><li><span style="font-family:Arial,sans-serif;">Agile - Virtualization increases the speed of the processes undertaken in VMs. Setting up and managing a virtual machine definitely takes less time compared to your PC.</span></li><li><span style="font-family:Arial,sans-serif;">Secure - As virtual machines run on the cloud, the security benefits are better compared to their physical counterparts. </span></li></ul><h2><span style="font-family:Arial,sans-serif;">Useful Commands of Virtual Machines in Azure</span></h2><h3><span style="font-family:Arial,sans-serif;">Basic VM Management</span></h3><h4>1. Create a VM</h4><pre><code class="language-plaintext">az vm create --resource-group myResourceGroup --name myVM --image UbuntuLTS --admin-username azureuser --generate-ssh-keys</code></pre><h4>2. List VMs</h4><pre><code class="language-plaintext">az vm list --resource-group myResourceGroup --output table</code></pre><h4>3. Delete a VM</h4><pre><code class="language-plaintext">az vm delete --resource-group myResourceGroup --name myVM</code></pre><h3>VM Operations</h3><h4>1. Start a VM</h4><pre><code class="language-plaintext">az vm start --resource-group myResourceGroup --name myVM</code></pre><h4>2. Stop a VM</h4><pre><code class="language-plaintext">az vm stop --resource-group myResourceGroup --name myVM</code></pre><h4>3. Restart a VM</h4><pre><code class="language-plaintext">az vm restart --resource-group myResourceGroup --name myVM</code></pre><figure class="table"><table><thead><tr><th><strong>Functionality</strong></th><th><strong>Command</strong></th><th><strong>Description</strong></th></tr></thead><tbody><tr><td><strong>Resize a VM</strong></td><td><pre><code class="language-plaintext">az vm resize --resource-group myResourceGroup --name myVM --size Standard_DS3_v2</code></pre></td><td>Changes the size of the specified VM.</td></tr><tr><td><strong>Add a Data Disk</strong></td><td><pre><code class="language-plaintext">az vm disk attach --resource-group myResourceGroup --vm-name myVM --name myDataDisk --new --size-gb 100</code></pre></td><td>Attaches a new data disk to the specified VM.</td></tr><tr><td><strong>Configure NIC</strong></td><td><pre><code class="language-plaintext">az network nic update --resource-group myResourceGroup --name myNIC --ip-configurations myIPConfig --public-ip-address myPublicIP</code></pre></td><td>Updates the network interface configuration of a VM.</td></tr><tr><td><strong>Update VM Tags</strong></td><td><pre><code class="language-plaintext">az vm update --resource-group myResourceGroup --name myVM --set tags.Owner=MyName</code></pre></td><td>Updates the tags of the specified VM.</td></tr><tr><td><strong>Enable Accelerated Networking</strong></td><td><pre><code class="language-plaintext">az network nic update --resource-group myResourceGroup --name myNIC --accelerated-networking true</code></pre></td><td>Enables accelerated networking for a VM's NIC.</td></tr><tr><td><strong>Change OS Disk Size</strong></td><td><pre><code class="language-plaintext">az vm update --resource-group myResourceGroup --name myVM --os-disk-size-gb 128</code></pre></td><td>Changes the size of the OS disk for the specified VM.</td></tr><tr><td><strong>Configure Boot Diagnostics</strong></td><td><pre><code class="language-plaintext">az vm boot-diagnostics enable --resource-group myResourceGroup --name myVM --storage myStorageAccount</code></pre></td><td>Enables boot diagnostics for a VM.</td></tr><tr><td><strong>Set Static IP Address</strong></td><td><pre><code class="language-plaintext">az network nic ip-config update --resource-group myResourceGroup --nic-name myNIC --name ipconfig1 --private-ip-address 10.0.0.4</code></pre></td><td>Sets a static IP address for a VM's NIC.</td></tr><tr><td><strong>Attach Existing Data Disk</strong></td><td><pre><code class="language-plaintext">az vm disk attach --resource-group myResourceGroup --vm-name myVM --disk myExistingDisk</code></pre></td><td>Attaches an existing data disk to the specified VM.</td></tr><tr><td><strong>Detach Data Disk</strong></td><td><pre><code class="language-plaintext">az vm disk detach --resource-group myResourceGroup --vm-name myVM --name myDataDisk</code></pre></td><td>Detaches a data disk from the specified VM.</td></tr><tr><td><strong>Update OS Disk</strong></td><td><pre><code class="language-plaintext">az vm update --resource-group myResourceGroup --name myVM --set storageProfile.osDisk.name=newOSDiskName</code></pre></td><td>Updates the OS disk of the specified VM.</td></tr><tr><td><strong>Enable Managed Disks</strong></td><td><pre><code class="language-plaintext">az vm update --resource-group myResourceGroup --name myVM --set storageProfile.osDisk.managedDisk.id=<diskID></code></pre></td><td>Enables managed disks for the specified VM.</td></tr><tr><td><strong>Update VM Size</strong></td><td><pre><code class="language-plaintext">az vm update --resource-group myResourceGroup --name myVM --size Standard_DS2_v2</code></pre></td><td>Updates the size of the specified VM.</td></tr><tr><td><strong>Set Availability Set</strong></td><td><pre><code class="language-plaintext">az vm availability-set create --resource-group myResourceGroup --name myAvailabilitySet</code></pre></td><td>Creates an availability set for VMs.</td></tr><tr><td><strong>Add VM to Availability Set</strong></td><td><pre><code class="language-plaintext">az vm update --resource-group myResourceGroup --name myVM --set availabilitySet.id=<availabilitySetID></code></pre></td><td>Adds the specified VM to an availability set.</td></tr><tr><td><strong>Configure Custom Script Extension</strong></td><td><pre><code class="language-plaintext">az vm extension set --resource-group myResourceGroup --vm-name myVM --name CustomScript --publisher Microsoft.Azure.Extensions --settings '{"fileUris": ["https://path/to/script.sh"], "commandToExecute": "./script.sh"}'</code></pre></td><td>Adds a custom script extension to a VM.</td></tr></tbody></table></figure><h2>Pricing of Virtual Machine in Azure</h2><figure class="table"><table><thead><tr><th><strong>Instance Type</strong></th><th><strong>vCPUs</strong></th><th><strong>RAM (GB)</strong></th><th><strong>Pay-as-you-go ($/hour)</strong></th><th><strong>1-year Reserved ($/hour)</strong></th><th><strong>3-year Reserved ($/hour)</strong></th><th><strong>Spot ($/hour)</strong></th></tr></thead><tbody><tr><td><strong>B1s</strong></td><td>1</td><td>1</td><td>$0.008</td><td>$0.005</td><td>$0.004</td><td>$0.002</td></tr><tr><td><strong>D2s v5</strong></td><td>2</td><td>8</td><td>$0.096</td><td>$0.060</td><td>$0.043</td><td>$0.029</td></tr><tr><td><strong>E2s v5</strong></td><td>2</td><td>16</td><td>$0.112</td><td>$0.070</td><td>$0.051</td><td>$0.034</td></tr><tr><td><strong>F4s v2</strong></td><td>4</td><td>8</td><td>$0.169</td><td>$0.106</td><td>$0.075</td><td>$0.048</td></tr><tr><td><strong>L8s v2</strong></td><td>8</td><td>64</td><td>$0.504</td><td>$0.318</td><td>$0.224</td><td>$0.144</td></tr><tr><td><strong>NC4as T4 v3</strong></td><td>4</td><td>16</td><td>$1.203</td><td>$0.762</td><td>$0.537</td><td>$0.349</td></tr></tbody></table></figure><h2 style="text-align:justify;">Pricing Comparison of VM in Azure With AWS EC2</h2><figure class="table"><table><thead><tr><th><strong>Instance Type</strong></th><th><strong>vCPUs</strong></th><th><strong>RAM (GB)</strong></th><th><strong>Azure Pay-as-you-go ($/hour)</strong></th><th><strong>AWS On-Demand ($/hour)</strong></th><th><strong>Azure 1-year Reserved ($/hour)</strong></th><th><strong>AWS 1-year Savings Plan ($/hour)</strong></th><th><strong>Azure Spot ($/hour)</strong></th><th><strong>AWS Spot ($/hour)</strong></th></tr></thead><tbody><tr><td><strong>B1s / t3.micro</strong></td><td>1</td><td>1</td><td>$0.008</td><td>$0.0104</td><td>$0.005</td><td>$0.007</td><td>$0.002</td><td>$0.0035</td></tr><tr><td><strong>D2s v5 / m5.large</strong></td><td>2</td><td>8</td><td>$0.096</td><td>$0.096</td><td>$0.060</td><td>$0.061</td><td>$0.029</td><td>$0.028</td></tr><tr><td><strong>E2s v5 / r5.large</strong></td><td>2</td><td>16</td><td>$0.112</td><td>$0.126</td><td>$0.070</td><td>$0.080</td><td>$0.034</td><td>$0.035</td></tr><tr><td><strong>F4s v2 / c5.large</strong></td><td>4</td><td>8</td><td>$0.169</td><td>$0.085</td><td>$0.106</td><td>$0.054</td><td>$0.048</td><td>$0.028</td></tr><tr><td><strong>L8s v2 / i3.large</strong></td><td>8</td><td>64</td><td>$0.504</td><td>$0.312</td><td>$0.318</td><td>$0.199</td><td>$0.144</td><td>$0.093</td></tr><tr><td><strong>NC4as T4 v3 / p3.2xlarge</strong></td><td>4</td><td>16</td><td>$1.203</td><td>$3.06</td><td>$0.762</td><td>$2.125</td><td>$0.349</td><td>$0.918</td></tr></tbody></table></figure><h2 style="text-align:justify;">Tips for optimizing costs for VM in Azure</h2><figure class="table"><table><thead><tr><th><strong>Tip</strong></th><th><strong>Description</strong></th></tr></thead><tbody><tr><td><strong>Use Reserved Instances</strong></td><td>Commit to a 1- or 3-year term for significant discounts. Ideal for predictable workloads.</td></tr><tr><td><strong>Leverage Spot VMs</strong></td><td>Utilize unused capacity at reduced rates. Best for flexible, interruptible tasks.</td></tr><tr><td><strong>Right-Size VMs</strong></td><td>Regularly review and adjust VM sizes to match workload requirements, avoiding over-provisioning.</td></tr><tr><td><strong>Auto-Shutdown Policies</strong></td><td>Schedule automatic shutdowns during non-peak hours to save on costs.</td></tr><tr><td><strong>Monitor and Optimize</strong></td><td>Use Azure Cost Management tools to track usage, set budgets, and optimize resource allocation.</td></tr><tr><td><strong>Utilize Azure Hybrid Benefits</strong></td><td>Bring your existing on-premises licenses to Azure for additional savings.</td></tr></tbody></table></figure><h2 style="text-align:justify;">Real-World Use Cases</h2><figure class="table"><table><thead><tr><th><strong>Company</strong></th><th><strong>Use Case</strong></th><th><strong>Details</strong></th><th><strong>Benefits</strong></th></tr></thead><tbody><tr><td><strong>GEICO</strong></td><td>Enhanced Customer Experience and Operational Efficiency</td><td>GEICO migrated web applications to Azure VMs to improve digital customer experience.</td><td>Better scalability and performance, faster response times, improved disaster recovery.</td></tr><tr><td><strong>Adobe</strong></td><td>Scaling Creative Cloud Services</td><td>Adobe used Azure VMs to scale Creative Cloud services for millions of users.</td><td>Improved scalability, reduced latency, and consistent high-performance experience.</td></tr><tr><td><strong>BMW</strong></td><td>Developing Connected Car Solutions</td><td>BMW adopted Azure VMs to enhance vehicle telematics and infotainment systems.</td><td>Real-time data processing, advanced analytics, improved diagnostics, and predictive maintenance.</td></tr><tr><td><strong>Myntra</strong></td><td>Supporting E-commerce Growth</td><td>Myntra leveraged Azure VMs to handle high traffic during peak shopping seasons.</td><td>Efficient workload management, responsive platform, better cost management.</td></tr><tr><td><strong>Heineken</strong></td><td>Global Marketing Campaigns</td><td>Heineken used Azure VMs for global marketing campaigns requiring significant compute resources.</td><td>Quick deployment, real-time data processing, targeted marketing efforts.</td></tr></tbody></table></figure><h2 style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Conclusion</span></h2><p style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Azure Virtual Machine is a service offered by Azure that provides higher CPU and storage power to work in virtual environments. VMs are also known as software-defined computers, these machines offer the exact same purpose as a PC but without the hardware. They operate on Azure cloud and are easy and efficient to manage. You can choose different types of VMs with varying storage sizes to fit your activities. Virtual machines are used to build and test applications, manage high workloads, and perform other purposes. Due to its agility, increased security, and portability, Azure Virtual Machine is widely used by developers worldwide.</span></p><p style="text-align:justify;"><span style="font-family:Arial,sans-serif;">Read More</span></p><p style="text-align:justify;"><a href="https://devopsden.io/article/roadmap-to-microsoft-azure-certifications"><span style="font-family:Arial,sans-serif;">https://devopsden.io/article/roadmap-to-microsoft-azure-certifications</span></a></p><p style="margin-left:auto !important;">Follow us on</p><p style="margin-left:auto !important;"><a href="https://www.linkedin.com/company/devopsden/">https://www.linkedin.com/company/devopsden/</a></p>