- create resourse group
- create ubuntu virtual machine
- connect using ssh
- install nginx
- open port 80 in nsg
- access the website using PUBLIC IP
- ssh azureuser@PUBLIC_IP
- sudo apt update
- sudo apt install nginx -y
- sudo systemctl status nginx
- curl localhost :check_mark:
:check_mark:
-today i have praactised manging azure resources using cli instead of azure portal the goal was to understand to deploy
-
azure cli installation
-
azure cli login
-
creating resource groups
-
connecting a virtual machine
-
opening port 80 for web traffic
-
installing nginx
-
installing docker
i used command curl -sL https://aka.ms/InstallAzureCLIeb | sudo bash
az vm create
--resource-group devops-rg
--name devops-vm
--image Ubuntu2204
--size Standard_B2as_v2
--admin-username azureuser
--generate-ssh-keys
--location centralindiaaz vm open-port
--resource-group devops-rg
--name devops-vm
--port 80
sudo apt update sudo apt install nginx -y sudo systemctl start nginx
with the help of ip address we can browse and it willl show nginx is installed
:check_mark:
- docker run -d -p 8000:80 nginx
- docker ps
- docker ps -a
- docker stop
- docker start
- docker rm
- docker container prune
- learn docker volume and networking
- Docker container
- Port mapping
- Running Nginx in container
Example:
Host Port β Container Port
8000:80
Access in browser:
:check_mark:
git init git status git add git commit git log git remote add origin git branch -M main git push
Concept learned:
- Local repository
- Remote repository
- Git commit history
- Uploading project to GitHub
Learn how to build a custom Docker image using a Dockerfile and run a container.
- Created a project directory
- Added a simple HTML webpage
- Wrote a Dockerfile using nginx base image
- Built a Docker image
- Ran a container using the image
- Accessed the application through the browser
docker build -t rahul-nginx . docker run -d -p 8080:80 rahul-nginx docker ps curl localhost:8080 :check_mark:
Successfully created a custom nginx container serving a personal HTML page.
instaled python3 in the ubuntu terminal in virtual environment python3 -m venv myenv
Variables store values.
name = "Rahul"
age = 40
print(f"My name is {name} and my age is {age}")Used to repeat an action for each item in a list.
servers = ["web1", "web2", "db1"]
for server in servers:
print(f"Checking server {server}")π» For Loop (for item in list) Used to repeat an action for each item in a list.
servers = ["web1", "web2", "db1"]
Today I practiced Python dictionaries and loops, which are useful for handling server data in DevOps.
server = {"name": "web1", "ip": "10.0.0.1", "status": "running"}
print(server["name"])
print(server["ip"])servers = ["web1", "web2", "db1"]
for s in servers:
print("Checking server:", s)servers = [
{"name": "web1", "ip": "10.0.0.1"},
{"name": "web2", "ip": "10.0.0.2"}
]
for server in servers:
print(server["name"], server["ip"])In DevOps we often read files like:
- server lists
- deployment logs
Python helps automate these tasks.
file = open("servers.txt", "w")
file.write("web1\n")
file.write("web2\n")
file.write("db1\n")
file.close()Explanation:
"w"β write mode (creates file or overwrites)\nβ new line- This creates a file called servers.txt
Output file:
web1
web2
db1
Used to add new content without deleting existing data.
Example:
file = open("example.txt", "a")
file.write("\nNew line added")
file.close()
Mode: "a" β append (adds content to the end)
Summary
r β read file
w β write file (overwrite)
a β append to file
- git init β start repo
- git clone β copy repo
- git status β check changes
- git add . β stage files
- git commit -m "msg" β save
- git push β upload
- git pull β get latest
mkdir demo cd demo git init
echo "hello" > file.txt git add . git commit -m "first commit"
Connect GitHub repo and run: git push
Flow: Code β Add β Commit β Push
-
Forgot git add before commit
-
Wrong commit message
-
Tried running git without initializing repo
env_name = "prod"
cpu_readings = [55, 23, 87, 12, 67]
print("Environment:", env_name)
# SORTING
cpu_readings.sort()
print("Sorted CPU readings:", cpu_readings)
# LOOP
for value in cpu_readings:
if value > 70:
print("High:", value)
else:
print("OK:", value)
Environment: prod
Sorted CPU readings: [12, 23, 55, 67, 87]
OK: 12
OK: 23
OK: 55
OK: 67
High: 87
βοΈ
Docker runs applications in containers with all dependencies. Images are blueprints, containers are running instances. Pulled nginx image and ran it using docker run. Used docker ps to check and docker stop to stop containers. Learned basic Docker workflow.
nano docker-notes.md
-
docker is an islolated container where we can build or run apps
-
docker is like a seprate room and isolated without your main computer
-
docker pull <image>- Download an image from Docker Hub -
docker run -it ubuntu bash- Run and enter a container -
docker ps -a- List all containers -
docker rm $(docker ps -aq)- Delete all containers -
docker rmi $(docker images -q)- Delete all images -
docker build -t my-flask-app .- Build image from Dockerfile -
docker run -p 5000:5000 my-flask-app- Run app on port 5000 -
with the help of chatgpt i pasted python code for learing purpose
-
what is a gpg keys its an software to verify wheather the application is legit or not











