Showing posts with label Azure. Show all posts
Showing posts with label Azure. Show all posts

Saturday, June 21, 2025

How to create Ubuntu 22.0.4 Virtual Machine (VM) in Azure? | Create Ubuntu 22.0.4 VM in Azure | How to connect to Azure VM from your local machine

 How to Create Ubuntu 22.0.4 Virtual Machines(VM) in Azure portal? Creating Virtual Machine is easy and straight forward in Azure Cloud. Let us see how to do that in Azure portal. 

Pre-requisites:

  • Azure account subscription, click here if you dont have one.
Watch Steps in YouTube channel:


Steps to create Ubuntu 22.0.4 Virtual Machine in Azure
 
1. Login to Azure portal, go to https://portal.azure.com/
2. Click on Virtual Machines.

3. Click on Add virtual machine.

 

4. Now enter the details as below or give values per your subscription and requirements. Select Ubuntu 22.0.4 VM



5. choose authentication type as SSH public key, enter azureuser as user name, enter key pair name.
This step will eventually create SSH keys and allow you to download in your machine.



6. Under Networking


Go with Allow selected ports - SSH port 22
And also select Delete public IP and NIC when VM is deleted option


7. Click on Review, it may take a few mins to finish the validations. If all good, it should pass the validations. Click on Create.

8.  Now download the SSH keys and save it locally.
 

9. Once created, Click on virtual machines.

10. You should see the new VM is running like below:


How to connect to Azure VM from your local machine?



11. Now select that instance, click on connect


Then choose SSH 


12. Copy the value as it shows below in your local terminal(iTerm for Apple laptop) or Git bash for Windows laptop.

13. Make sure your SSH keys is not accessible by others, by executing the below command:

chmod 400 myUbuntuVM_key.pem
14. Now ssh into VM from your local machine using the key

ssh -i myUbuntuVM_key.pem azureuser@your_ip_address


Now it should show you that you are connected to Azure.



Wednesday, March 20, 2024

How to Setup Self-Hosted Linux Docker Build Agent in Azure DevOps | How to configure Self-Hosted Linux Docker Agents in Azure Pipelines | Create Custom Build Agents in Azure DevOps

 Let us learn how to configure a self-hosted agent using Docker in Azure DevOps pipelines.

What is an Agent?

An agent is computing infrastructure with installed agent software that runs one job at a time.To build your code or deploy your software using Azure Pipelines, you need at least one agent. As you add more code and people, you'll eventually need more.

When your pipeline runs, the system begins one or more jobs. 


In Azure pipelines, there are two types of build agents:

  1. Microsoft-hosted agents - This is a service totally managed by Microsoft and it's cleared on every execution of the pipeline (on each pipeline execution, you have a fresh new environment).
  2. Self-hosted agents - This is a service that you can to set up and manage by yourself. This can be a custom virtual machine on Azure or a custom on-premise machine inside your infrastructure. In a self-hosted agent, you can install all the software you need for your builds, and this is persisted on every pipeline execution. A self-hosted agent can be on Windows, Linux, macOS, or in a Docker container.

You can set up a self-hosted agent in Azure Pipelines to run inside a Windows Server Core (for Windows hosts), or Ubuntu container (for Linux hosts) with Docker. We will learn in this article on how to host Ubuntu Docker container on Linux machines.

Pre-requisites:
How to configure Self-hosted docker build agent?

1. Go to Azure DevOps dashboard - https://dev.azure.com/
2. Select your project dashboard
3. Go to your project settings
4. Click on Agent pools


Create a new Agent pool name

Enter name as myAgentPool or any name
Make sure you select Grant access permission to all pipelines



Login to Azure VM where the docker build agents will be running.

Step #1 - Install Docker CLI so we can build docker image

sudo apt update && sudo apt install docker.io -y

Step #2 - Add logged in user to docker group
sudo usermod -a -G docker $USER

Step #3 - Clone repo which has Dockerfile

git clone https://github.com/akannan1087/ado-docker-agent-repo.git

Sample dockerfile is here.. please feel free to add any software in the docker agent.
FROM ubuntu:22.04

RUN apt update -y && apt upgrade -y && apt install curl git jq libicu70 maven -y

# Also can be "linux-arm", "linux-arm64".
ENV TARGETARCH="linux-x64"

WORKDIR /azp/

COPY ./start.sh ./
RUN chmod +x ./start.sh

# Create agent user and set up home directory
RUN useradd -m -d /home/agent agent
RUN chown -R agent:agent /azp /home/agent

USER agent
# Another option is to run the agent as root.
# ENV AGENT_ALLOW_RUNASROOT="true"

ENTRYPOINT ./start.sh

Step #4 - change directory
cd ado-docker-agent-repo/azp-agent-in-docker/

Step #5 - Build the Docker image
sudo docker build --tag "azp-agent:linux" --file Dockerfile .

Step #6: Run the agent as a container
Run the below command:

sudo docker run -e AZP_URL="https://dev.azure.com/your_org_name" -e AZP_TOKEN="XXXX" -e AZP_POOL=myAgentPool -e AZP_AGENT_NAME="myLinuxDockerBuildAgent" --name "azp-agent" azp-agent:linux

that's it, docker agent is successfully started.

Step #7: Verify if docker agent is running or not
Run the below command:
sudo docker ps


Check the status of build Agent
Click on agentPool name, click on Agents

This confirms that Build agent is successfully configured in Azure DevOps and is available to run builds.

How to use the Docker build agent in your pipelines?

Please use the docker agent in the classic pipeline like below: select the agentPool


run the job. now you can see the jobs under myAgentPool--> Jobs
 

Here is the sample pipeline YAML code for automating Maven build for a Java project:

trigger:
- main
pool:
name: myAgentPool
stages:
- stage: Build
displayName: Build stage
jobs:
- job: MavenPackageAndPublishArtifacts
displayName: Maven Package and Publish Artifacts
steps:
- task: Maven@3
displayName: 'Maven Package'
inputs:
mavenPomFile: 'MyWebApp/pom.xml'

References:

Watch steps in YouTube channel:

Tuesday, August 22, 2023

How to create Red Hat Linux Virtual Machine (VM) in Azure? | Create Red Hat Linux VM in Azure | How to connect to Azure VM from your local machine

How to Create Red Hat Linux Virtual Machines(VM) in Azure Cloud? 

Creating Virtual Machine is easy and straight forward in Azure Cloud. Let us see how to do that in Azure portal. 

Watch Steps in YouTube channel:

Pre-requisites:

  • Azure account subscription, click here if you don't have one.
  • SSH client such as Git bash, putty or iTerm(mac os)
Steps to create Red Hat Linux Virtual Machine in Azure
 
1. Login to Azure portal, go to https://portal.azure.com/
2. Click on Virtual Machines.

3. Click on Add/Create virtual machine. 

 

Enter resource group name, select region.



4. Select security type as Standard
5. Now enter the details as below or give values per your subscription and requirements. Select Red Hat Enterprise Linux 8.x VM from the drop down.


6. choose authentication type as SSH public key, enter azureuser as user name, enter key pair name.
This step will eventually create SSH keys and allow you to download in your machine.



7. Under Networking



Go with Allow selected ports - SSH port 22
And also select Delete public IP and NIC when VM is deleted option


8. Under Monitoring, disable Boot diagnostics

9. Click on Review, it may take a few mins to finish the validations. If all good, it should pass the validations. Click on Create.

10.  Now download the SSH keys and save it locally.
 

11. Once created, Click on virtual machines.

12. You should see the new VM is running like below:


How to connect to Azure VM from your local machine?



1. Now select that instance, click on connect


2.Then choose SSH 


3. Enter ssh key name in private key path 
4. Copy the value as it shows below in your local terminal(iTerm for Apple laptop) or Git bash for Windows laptop.

5. Make sure your SSH keys is not accessible by others, by executing the below command:

chmod 400 myUbuntuVM_key.pem
6. Now ssh into VM from your local machine using the key

ssh -i myUbuntuVM_key.pem azureuser@your_ip_address


Now it should show you that you are connected to Azure.

Saturday, August 19, 2023

How to connect to Azure Virtual Machine from your local machine? | Connect to Azure VM from your local machine | Connect to Azure VM from your local machine

Let's learn how to connect to a Virtual machine running in Azure cloud from your local machine. Your local machine can be a Windows laptop or MacBook laptop.




Pre-requisites:

1. Keys(for e.g., yourkey.pem) already downloaded in your local machine, preferably in downloads folder.
2. Azure VM is up and running
3. SSH client - for Windows laptop, you need to install an SSH client such as Git bash or putty. You can download Git from this URL - https://git-scm.com/downloads. For Apple laptop you need to download iTerm from here.

Steps to connect to your Azure VM instance:

1. Go to Azure console --> https://portal.azure.com
2. Click on Virtual machines, click on VM
3. Click on connect





Choose Native SSH




Enter SSH key name in step # 3 in the screen


4. copy the values from step # 4

 
Copy the url from SSH which looks like below:

For e.g.
ssh -i myAzVMKey.pem azureuser@104.43.214.12

Watch steps in YouTube channel:

Windows Laptop instructions
5. Go to your local machine, Open Git Bash in Windows


make sure you are in downloads directory where your keys got downloaded. Type the below commands:

type below commands: 
pwd
this should tell you which directory you are and then navigate to downloads dir.

cd  ~/downloads 


Now copy the value from Example in the above screen

ssh -i myAzVMKey.pem azureuser@104.43.214.12

and then type enter, say yes and enter
now you should be in Azure cloud, screen should show something like this, It means you are successfully connected to VM instance running on Azure cloud. 


Mac Book Laptop or iMac Instructions

Open iTerm window, type the below command to go to downloads directory.
cd downloads


For few Mac laptops, it may add .txt in the end of pem file. in that case you need to remove .txt in the end


ssh -i myAzVMKey.pem azureuser@104.43.214.12

pwd
and then execute below command to make sure the keys have only read permissions.

chmod 400 *.pem

6. Paste the url from example highlighted above in step # 4.
ssh -i myAzVMKey.pem azureuser@104.43.214.12
7. type yes when it is asking to connect.
8. now you should be in Azure cloud, screen should show something like this, It means you are successfully connected to VM instance running on Azure cloud. 




 

Master DevSecOps and Multi Cloud Computing Course by Coach AK | DevSecOps and Cloud Computing Online Classes | May 2026 Schedule

   Live Hands-On Bootcamp - May 2026 🚀 Supercharge your DevOps career with real-world skills! 🔥 What You’ll Learn 👉 Master leading DevSec...