DEV Community

Arun Kumar Palani
Arun Kumar Palani

Posted on

Azure Virtual machine & AWS EC2 Instance

Hi, I am Arun Kumar Palani, Senior software engineer in Luxoft & Microsoft certified solution Architect - Associate level.

Note: This article provides detailed idea about how IAAS provides virtual machines and enable entire control to organization to set up their own security implementation and configuration. The audience require some knowledge about cloud IAAS. If not, no problem I'll give some idea about IAAS in introduction.

Introduction:

IAAS: It is a method for providing computing infrastructure as on-demand services. It is one of the three essential models for cloud services. In a fully outsourced, on-demand service model, the user purchases servers, software data centers, or network equipment and rents those resources. The resources are distributed as services, and it supports dynamic scalability. On a single piece of hardware, numerous users are typically supported.

In this article, I will explain step by step how to create an AWS EC2 instance in AWS portal and Azure virtual machine in Azure portal and its usage, advantages, disadvantages, and how to deploy a .NET application in an AWS EC2 instance and Azure virtual machine in detail from portal also through CLI.

AWS EC2 instance:

Amazon EC2 or Elastic Compute Cloud is an AWS service that offers highly scalable computing capacity. In AWS, servers are referred to as “instances”. Amazon EC2 provides you with virtual servers in the cloud.

Step 1: Create an AWS account.

To use AWS services, you need to have an AWS account. Visit aws.amazon.com and click on the Sign-Up button. You will be prompted to enter your personal details and payment information.

Step 2: Select the Region.

After creating an AWS account, log in to the AWS Management Console. Then select the region where you want your EC2 instance to be deployed. It’s important to choose a region that is close to your users.

Step 3: Launch an Instance.

To launch an instance, go to the EC2 dashboard and click on the Launch Instance button. You will be taken to a wizard that will guide you through the process of launching an EC2 instance.

a) Choose an AMI (Amazon Machine Image):

The first step is to choose an Amazon Machine Image (AMI), which is a pre-configured virtual machine image. An AMI contains the information necessary to launch instances, such as the operating system, application server, and applications. You can either choose a pre-configured AMI or create your own custom AMI.

b) Choose an Instance Type:

Next, choose an instance type based on the amount of CPU, memory, storage, and network connectivity you require. The instance types range from micro to large and come with different pricing options based on your usage.

c) Configure Instance Details:

In this step, you can choose to configure Instance Details like Number of Instances, Network settings, IAM Role, Shutdown behavior, etc. You can also add user data and configure the instance to run a script on startup.

d) Add Storage:

In this step, you can add storage to your instance. You can choose the type of storage you want, like Elastic Block Store (EBS) or Instance Storage and specify the size of the volume.

e) Configure Security Group:

In this step, you need to configure the security group for your instance. A security group acts as a virtual firewall that controls inbound and outbound traffic to your instances. You can create a new security group or select an existing one.

f) Review and Launch:

After configuring all the settings, review them to ensure they are correct. Once you’re satisfied with the configuration, click on Launch to launch the instance. You will be prompted to select a key pair, which is used to securely log in to your instance.

Step 4: Connect and Configure your Instance.

Once your EC2 instance is launched, you need to connect to it and configure it to meet your needs. This can be done using Remote Desktop Protocol (RDP) for Windows instances and Secure Shell (SSH) for Linux instances.

Usage of AWS EC2 instances:

EC2 instances can be used to host websites and web applications, process big data and machine learning workloads, or store data in databases.
Below listed are few advantages that make EC2 instances popular among businesses.

Advantages:

Scalable: EC2 instances can scale up or down based on demand without any downtime, which helps businesses save money by paying only for the resources they use.

Easy Deployment: Setting up an EC2 instance is fast and easy using the console dashboard or API integration.
Security: AWS offers comprehensive security features to protect data and applications hosted on EC2 instances.

Reliability: EC2 instances are designed for high availability and offer a 99.99% uptime Service Level Agreement (SLA).

Cost-Effective: With EC2 instances, there are no upfront costs or long-term commitments, and users pay only for what they use.

Disadvantages:

Though AWS provides many benefits with the EC2 instances, it has a few challenges as well. Few challenges are listed below:
Steep Learning Curve: The platform has a high learning curve, especially for beginners or companies unfamiliar with cloud infrastructure.

Complexity: Setting up a complex network requires good knowledge of networking concepts.

Create an AWS EC2 instance through CLI.

Install and configure the AWS CLI:

To install the AWS CLI, visit the AWS documentation page and follow the instructions for your operating system. Once installed, open a terminal window and run ‘aws configure’ to provide your AWS credentials.

Choose an Amazon Machine Image (AMI):

Determine which Amazon Machine Image (AMI) you want to use as the basis for your instance. You can use one of the default Amazon AMIs, or create your custom AMI.

Choose an instance type:

Select the instance type that best suits your requirements based on the number of CPUs, memory, and storage.

Create a key pair:

A Key Pair is used to SSH in your instance. You can create a new key pair using the following command:

$ aws ec2 create-key-pair --key-name my-keypair --query 'KeyMaterial' --output text > my-keypair.pem

Create a security group:

A Security Group acts as a virtual firewall for your instance. You can create a security group using the following command:

$ aws ec2 create-security-group --group-name my-security-group --description "My security group"

Configure inbound rules:

Inbound rules control the traffic that’s allowed to reach your instance. You can add inbound rules using the following command:

$ aws ec2 authorize-security-group-ingress --group-name my-security-group --protocol tcp --port 22 --cidr 0.0.0.0/0

This example allows all IP addresses to connect to your instance over port 22.

Launch the instance:

Finally, launch the EC2 instances using the following command:

$ aws ec2 run-instances --image-id ami-xxxxxx --count 1 --instance-type t2.micro --key-name my-keypair --security-group-ids my-security-group --subnet-id subnet-xxxxxx

Replace ‘ami-xxxxxx’ with the ID of your chosen AMI, and ‘subnet-xxxxxx’ with your VPC subnet ID.

Deploying .NET Application in AWS EC2 instance:

To deploy a .NET application in an AWS EC2 instance, follow the below steps:

Step 1: Create an EC2 Instance.

Follow the steps and launch an EC2 instance. Choose an Amazon Machine Image (AMI) that is compatible with the version of the .NET framework you intend to use.

Step 2: Install IIS.

IIS (Internet Information Services) is a web server that can be installed on Windows Server OS to host web applications. You can install IIS from the Server Manager UI or PowerShell command-line.

Step 3: Configure Access to Your Application.

Once IIS is installed, configure access to your application by setting up security groups and enabling HTTP/HTTPS access through the inbound rules.

Step 4: Publish Your .NET Application.

To publish the application, use Visual Studio’s publish wizard or use Azure DevOps pipeline to automate the deployment process.

Step 5: Test Your Application.

Verify that the application is running by navigating to the public IP address of the instance in a web browser.

Step 6: Automate Deployment Process.

Automating the deployment process using tools like Jenkins or AWS Code Deploy allows for continuous integration and delivery which improves productivity and reduces downtime.

Amazon EC2 provides highly scalable computing capacity in the cloud, which makes it an excellent platform for businesses of all sizes. EC2 instances can be used to host websites, run applications, process big data and stored in databases. However, companies must also be aware of the challenges associated with using AWS services.

We have now seen how to create an AWS EC2 instance, its usage, advantages, disadvantages, and how to deploy a .NET application in an AWS EC2 instance. Proper planning, implementation, and maintenance of your AWS infrastructure can lead to cost savings, improved efficiency, and business growth.

Azure Virtual machines:

Azure Virtual Machines (VMs) allow users to create and manage virtual machines in the cloud. These VMs can run various operating systems and are used for a variety of purposes, such as running applications, hosting websites, or providing infrastructure for testing and development.

Step 1: Create an Azure account.

To use Azure services, you need to have an Azure account. Visit azure.microsoft.com and click on the Start Free button. You will be prompted to enter your personal details and payment information.

Step 2: Select the Region.

After creating an Azure account, log in to the Azure portal. Then select the region where you want your virtual machine to be deployed. It’s important to choose a region that is close to your users.

Step 3: Create a Resource Group.

A Resource Group is a logical container that holds related resources for an Azure solution. To create a resource group, navigate to the Resource Group option in the Azure portal and click on Add. Enter the name, region, and subscription details.

Step 4: Create a Virtual Machine.

To create a virtual machine, follow the steps below.

a) Choose Image and Size:

Select the Image and size for your virtual machine based on your requirements. Azure offers a variety of pre-configured images to choose from.

b) Configure Basic Settings:

Provide relevant names for your virtual machine, username, and password. You can also enable extensions, boot diagnostics, and a public IP address.

c) Configure Disks:

Configure the storage options for your virtual machine. Azure offers multiple disk types for different workloads.

d) Configure Networking:

Configure the network settings for your virtual machine, including virtual network setup, subnet configuration, public IP address allocation, and network security group rules.

e) Review + Create:

Once all the required configurations are completed, review your settings and click on create to create your virtual machine.

Step 5: Connect and Configure Your Virtual Machine.

After creating your Azure Virtual machine, connect to it using Remote Desktop Protocol (RDP) or secure shell (SSH), depending on the virtual machine’s operating system. Then proceed to configure it according to your requirements, such as installing applications, setting up firewalls, and configuring virtual networking.

Usage of Azure Virtual Machines:

Azure VMs are used for various purposes, including hosting websites, running applications, providing infrastructure for testing and development, data storage, and backup.

Below listed are few advantages that make Azure Virtual Machines popular among businesses:

Advantages:

Scalability: Azure VMs can be scaled up or down based on demand without any downtime.

High Availability: Azure provides a Service Level Agreement (SLA) of 99.9% availability for VMs.

Security: Azure offers comprehensive security features to protect data and applications hosted on Virtual Machines.

Reliability: Virtual machines are designed for high availability and offer a 99.9% uptime Service Level Agreement (SLA).

Cost-Effective: With Azure Virtual machines, there are no upfront costs, long-term commitments, and you pay only for what you use.

Disadvantages:

Along with the advantages, Azure VMs have a few limitations as well. Few disadvantages are listed below:

Steep Learning Curve: The platform has a high learning curve, especially for beginners or companies unfamiliar with cloud infrastructure.

Complexity: Setting up a complex network requires knowledge of networking concepts.

Deploying .NET Application in Azure Virtual Machine:
Create an Azure virtual machine using CLI:

Install and configure the Azure CLI:

To install the Azure CLI, visit the Azure documentation page and follow the instructions for your operating system. Once installed, open a terminal window and run ‘az login’ to connect to your Azure account.

Create a resource group:
A Resource Group is a logical container that groups resources together for easy management. You can create a new resource group using the following command:

$ az group create --name MyResourceGroup --location eastus

Choose an image:

Determine which image you want to use as the basis for your instance. You can use one of the default Azure images or create your custom image.

Create a virtual network:

A Virtual Network is required by Azure to create a virtual machine. You can create a new virtual network using the following command:

$ az network vnet create --resource-group MyResourceGroup --name MyVnet --address-prefix 10.0.0.0/16 --subnet-name MySubnet --subnet-prefix 10.0.0.0/24

Create a public IP address:

You need a public IP address to access your virtual machine from the Internet. You can create a public IP address using the following command:

$ az network public-ip create --resource-group MyResourceGroup --name MyPublicIP --dns-name mypublicip

Configure inbound rules:

Inbound rules control the traffic that’s allowed to reach your instance. You can add inbound rules using the following command:

$ az network nsg rule create --resource-group MyResourceGroup --nsg-name MyNSG --name ssh --protocol tcp --priority 1000 --destination-port-range 22 --access allow

This example allows all IP addresses to connect to your instance over port 22.

Launch the instance:

Finally, launch the virtual machine using the following command:

$ az vm create --resource-group MyResourceGroup --name MyVM --image UbuntuLTS --admin-username azureuser --generate-ssh-keys --vnet-name MyVnet --subnet MySubnet --public-ip-address MyPublicIP --nsg MyNSG

Replace ‘UbuntuLTS’ with the ID of your chosen image.

To deploy a .NET application in an Azure Virtual Machine, follow the below steps:

Step 1: Create an Azure Virtual Machine.

Follow the steps and create an Azure Virtual Machine. Choose the image that is compatible with the version of the .NET framework you intend to use.

Step 2: Install IIS

IIS (Internet Information Services) is a web server that can be installed on the Windows Server Operating System to host web applications. You can install IIS from the Server Manager UI or PowerShell command-line.

Step 3: Configure Access to Your Application

Once IIS is installed, configure access to your application by setting up security groups and enabling HTTP/HTTPS access through the inbound rules.

Step 4: Publish Your .NET Application.

To publish the application, use Visual Studio’s publish wizard or use Azure DevOps pipeline to automate the deployment process.

Step 5: Test Your Application.

Verify that the application is running by navigating to the public IP address of the virtual machine in a web browser.

Step 6: Automate Deployment Process.

Automating the deployment process using tools like Jenkins or Azure DevOps allows for continuous integration and delivery which improves productivity and reduces downtime.

Azure provides highly scalable computing capacity in the cloud, which makes it an excellent platform for businesses of all sizes. Azure Virtual Machines can be used to host websites, run applications, process big data, and store data in databases. However, companies must also be aware of the challenges associated with using Azure services.

We have now seen how to create an Azure Virtual Machine, its usage, advantages, disadvantages, and how to deploy a .NET application in an Azure Virtual Machine. Proper planning, implementation, and maintenance of your infrastructure can lead to cost savings, improved efficiency, and business growth.

Comparison:
Azure and AWS are two of the most popular cloud services providers that offer a range of cloud-based services. A Virtual Machine (VM) in Azure is similar to an Elastic Compute Cloud (EC2) instance in AWS. Both Azure VMs and AWS EC2 instances provide on-demand computing, flexibility, scalability, and pay-as-you-go pricing models.

Computing Resources:

Azure Virtual Machines and AWS EC2 Instances provide users with the ability to configure CPU, memory, and storage resources based on their requirements. However, there are some differences between these two services.
In Azure, VMs can be configured with up to 128 vCPUs, while in EC2 you can configure up to 256 vCPUs.
Azure offers a premium SSD disk type that provides high IOPS at a lower cost compared to AWS EBS volumes.
AWS provides an additional compute resource option called Elastic GPU, which allows users to attach graphics acceleration to EC2 instances for performance-intensive workloads.

Operating Systems:

Both Azure Virtual Machines and AWS EC2 instances support a wide range of operating systems, including Linux and Windows. However, there are differences in how these services manage operating system images.
Microsoft Azure offers pre-configured images that are optimized for different workloads like SQL, Java or .NET applications.
Amazon Web Services, on the other hand, offers Amazon Machine Images (AMIs) for customers to launch EC2 instances. It also has an extensive marketplace where users can find and purchase pre-configured images.

Networking:

Azure and AWS both offer virtual network configurations that allow users to build complex networking architectures. However, there are differences in how they are implemented.

Azure’s networking architecture uses a more simplified approach called Azure Virtual Network (VNet). VNets are designed to work like traditional on-premises networks and provide connectivity between VMs within the same VNet. Traffic between VNets or public internet is routed through a virtual gateway.

AWS networking architecture allows users to define network security groups, subnets, and route tables based on their requirements. Users also could manipulate IP addresses in EC2 instances.

Pricing:

Both Azure Virtual Machines and AWS EC2 Instances offer pay-as-you-go pricing models. However, there are differences in how they are priced.

Azure offers discounts for users who pre-pay for their virtual machines or reserve instance capacity for one- or three-year terms.

AWS provides a more granular pricing model that allows users to choose different payment options for computing resources, storage, and data transfers.

Management Tools:
Azure and AWS offer several management tools that enable users to manage their virtual machines from a centralized location. However, there are some differences in the management tools they provide.

Azure provides the Azure portal, which allows users to manage services using a web-based interface.

AWS provides the AWS Management Console, which allows users to manage services using a web-based interface. It also provides command-line tools and APIs that allow access to advanced features.

Conclusion: If we are IAAS Azure VM and AWS EC2 instance it makes a big difference because we own all the controls from our side like VNet, Ip configuration and it provides security features. We need to be very careful if we are using IAAS there is a high chance of potential threats if we misconfigured some areas in IAAS.

If you have any doubts and require help for using IAAS please drop a comment. Happy to help.

Stay tuned!!!

Top comments (0)