Skip to content

Commit 38adb3d

Browse files
committed
Deploy Golang on the Microsoft Azure Cobalt 100 processors
Signed-off-by: odidev <[email protected]>
1 parent e5c3ba3 commit 38adb3d

File tree

14 files changed

+673
-0
lines changed

14 files changed

+673
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
title: Run Golang on the Microsoft Azure Cobalt 100 processors
3+
4+
minutes_to_complete: 40
5+
6+
who_is_this_for: This Learning Path is designed for software developers looking to migrate their Golang workloads from x86_64 to Arm-based platforms, specifically on the Microsoft Azure Cobalt 100 processors.
7+
8+
learning_objectives:
9+
- Start an Azure Arm64 virtual machine using Azure console, with Ubuntu as the base image.
10+
- Learn how to create an Azure Linux 3.0 Docker container.
11+
- Deploy the Golang on an Azure Linux 3.0 Arm64-based Docker container and an Azure Linux 3.0 custom-image-based Azure virtual machine.
12+
- Test and Benchmark Golang in both containerized and virtual machine environments.
13+
14+
prerequisites:
15+
- A [Microsoft Azure](https://azure.microsoft.com/) account with access to Cobalt 100 based instances (Dpsv6).
16+
- A machine with [Docker](/install-guides/docker/) installed.
17+
- Basic understanding of Linux command line.
18+
- Familiarity with the [Golang](https://go.dev/) and deployment practices on Arm64 platforms.
19+
20+
author: Jason Andrews
21+
22+
### Tags
23+
skilllevels: Advanced
24+
subjects: Performance and Architecture
25+
cloud_service_providers: Microsoft Azure
26+
27+
armips:
28+
- Neoverse
29+
30+
tools_software_languages:
31+
- Golang
32+
- Docker
33+
- go test -bench
34+
35+
operatingsystems:
36+
- Linux
37+
38+
further_reading:
39+
- resource:
40+
title: Effective Go Benchmarking
41+
link: https://go.dev/doc/effective_go#testing
42+
type: Guide
43+
- resource:
44+
title: Testing and Benchmarking in Go
45+
link: https://pkg.go.dev/testing
46+
type: Official Documentation
47+
- resource:
48+
title: Using go test -bench for Benchmarking
49+
link: https://pkg.go.dev/cmd/go#hdr-Testing_flags
50+
type: Reference
51+
52+
53+
### FIXED, DO NOT MODIFY
54+
# ================================================================================
55+
weight: 1 # _index.md always has weight of 1 to order correctly
56+
layout: "learningpathall" # All files under learning paths have this same wrapper
57+
learning_path_main_page: "yes" # This should be surfaced when looking for related content. Only set for _index.md of learning path content.
58+
---
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
# ================================================================================
3+
# FIXED, DO NOT MODIFY THIS FILE
4+
# ================================================================================
5+
weight: 21 # Set to always be larger than the content in this path to be at the end of the navigation.
6+
title: "Next Steps" # Always the same, html page title.
7+
layout: "learningpathall" # All files under learning paths have this same wrapper for Hugo processing.
8+
---
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
title: "Cobalt 100 Arm-based processor and Golang"
3+
4+
weight: 2
5+
6+
layout: "learningpathall"
7+
---
8+
9+
## Cobalt 100 Arm-based processor
10+
11+
Azure’s Cobalt 100 is built on Microsoft's first-generation, in-house Arm-based processor: the Cobalt 100. Designed entirely by Microsoft and based on Arm’s Neoverse N2 architecture, this 64-bit CPU delivers improved performance and energy efficiency across a broad spectrum of cloud-native, scale-out Linux workloads. These include web and application servers, data analytics, open-source databases, caching systems, and more. Running at 3.4 GHz, the Cobalt 100 processor allocates a dedicated physical core for each vCPU, ensuring consistent and predictable performance.
12+
13+
To learn more about Cobalt 100, refer to the blog [Announcing the preview of new Azure virtual machine based on the Azure Cobalt 100 processor](https://techcommunity.microsoft.com/blog/azurecompute/announcing-the-preview-of-new-azure-vms-based-on-the-azure-cobalt-100-processor/4146353).
14+
15+
## Azure Linux 3.0
16+
17+
Azure Linux 3.0 is Microsoft's in-house, lightweight Linux distribution optimized for running cloud-native workloads on Azure. Designed with performance, security, and reliability in mind, it is fully supported by Microsoft and tailored for containers, microservices, and Kubernetes. With native support for Arm64 (AArch64) architecture, Azure Linux 3.0 enables efficient execution of workloads on energy-efficient Arm-based infrastructure, making it a powerful choice for scalable and cost-effective cloud deployments.
18+
19+
## Golang
20+
Golang (or Go) is an open-source programming language developed by Google, designed for simplicity, efficiency, and scalability. It provides built-in support for concurrency, strong typing, and a rich standard library, making it ideal for building reliable, high-performance applications.
21+
22+
Go is widely used for cloud-native development, microservices, system programming, DevOps tools, and distributed systems. Learn more from the [Go official website](https://go.dev/) and its [official documentation](https://go.dev/doc/).
Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
---
2+
title: Golang Baseline Testing
3+
weight: 6
4+
5+
### FIXED, DO NOT MODIFY
6+
layout: learningpathall
7+
---
8+
9+
10+
### Baseline testing of Golang Web Page on Azure Arm64
11+
This guide demonstrates how to test your Go installation on Azure Arm64 by creating and running a simple Go web server that serves a styled HTML page.
12+
13+
**1. Create Project Directory**
14+
15+
First, create a new folder called goweb to hold your project and move inside it:
16+
17+
```console
18+
mkdir goweb && cd goweb
19+
```
20+
This makes a directory named goweb and then changes into it.
21+
22+
**2. Create HTML Page with Bootstrap Styling**
23+
24+
Next, create a file named `index.html` using the nano editor:
25+
26+
```console
27+
nano index.html
28+
```
29+
30+
Paste the following HTML code inside. This builds a simple, styled web page with a header, a welcome message, and a button using Bootstrap.
31+
32+
```html
33+
<!DOCTYPE html>
34+
<html lang="en">
35+
<head>
36+
<meta charset="UTF-8">
37+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
38+
<title>Go Web on Azure ARM64</title>
39+
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet">
40+
<style>
41+
body {
42+
background: linear-gradient(135deg, #6dd5fa, #2980b9);
43+
color: white;
44+
min-height: 100vh;
45+
display: flex;
46+
align-items: center;
47+
justify-content: center;
48+
text-align: center;
49+
}
50+
.card {
51+
background: rgba(255, 255, 255, 0.9);
52+
color: #333;
53+
border-radius: 20px;
54+
box-shadow: 0 4px 15px rgba(0,0,0,0.2);
55+
}
56+
</style>
57+
</head>
58+
<body>
59+
<div class="container">
60+
<div class="card p-5">
61+
<h1 class="mb-3"> Go Web on Azure Arm64</h1>
62+
<p class="lead">This page is powered by Golang running on the Microsoft Azure Cobalt 100 processors.</p>
63+
<a href="/api/hello" class="btn btn-primary mt-3">Test API Endpoint</a>
64+
</div>
65+
</div>
66+
</body>
67+
</html>
68+
```
69+
**3. Create Golang Web Server**
70+
71+
Now create the Go program that will serve this web page:
72+
73+
```console
74+
nano main.go
75+
```
76+
Paste the code below. This sets up a very basic web server that serves files from the current folder, including the **index.html** you just created. When it runs, it will print a message showing the server address.
77+
78+
```go
79+
package main
80+
import (
81+
"encoding/json"
82+
"log"
83+
"net/http"
84+
"time"
85+
)
86+
func main() {
87+
// Serve index.html for root
88+
http.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
89+
if r.URL.Path == "/" {
90+
http.ServeFile(w, r, "index.html")
91+
return
92+
}
93+
http.FileServer(http.Dir(".")).ServeHTTP(w, r)
94+
})
95+
// REST API endpoint for JSON response
96+
http.HandleFunc("/api/hello", func(w http.ResponseWriter, r *http.Request) {
97+
w.Header().Set("Content-Type", "application/json")
98+
json.NewEncoder(w).Encode(map[string]string{
99+
"message": "Hello from Go on Azure ARM64!",
100+
"time": time.Now().Format(time.RFC1123),
101+
})
102+
})
103+
log.Println("Server running on http://0.0.0.0:80")
104+
log.Fatal(http.ListenAndServe(":80", nil))
105+
}
106+
```
107+
108+
**4. Run on the Web Server**
109+
110+
Run your Go program with:
111+
112+
```console
113+
go run main.go
114+
```
115+
116+
This compiles and immediately starts the server. If successful, you’ll see the message:
117+
118+
```output
119+
2025/08/19 04:35:06 Server running on http://0.0.0.0:80
120+
```
121+
**5. Allow HTTP Traffic in Firewall**
122+
123+
On Azure Linux 3.0 virtual machines, firewalld runs by default as an additional layer of firewall control. By default, it allows only SSH (22) and a few core services.
124+
So even if Azure allows HTTP port 80 (port 80 is added to inbound ports during VM creation), your VM’s firewalld may still block it until you run:
125+
126+
```console
127+
sudo firewall-cmd --permanent --add-service=http
128+
sudo firewall-cmd --reload
129+
```
130+
131+
You can verify that HTTP is now allowed by listing active services:
132+
133+
```console
134+
sudo firewall-cmd --list-services
135+
```
136+
137+
Example output:
138+
139+
```output
140+
dhcpv6-client http https mdns ssh
141+
```
142+
143+
If firewall-cmd is not found, ensure your $PATH includes standard directories:
144+
145+
```console
146+
export PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
147+
```
148+
So now, when you type firewall-cmd, the shell searches through the updated $PATH, finds /usr/bin/firewall-cmd, and executes it.
149+
150+
However, if you are working inside an Azure Linux 3.0 Docker container hosted on an Ubuntu virtual machine, you must bind the container’s port 80 to the VM’s port 80 and then allow HTTP traffic through the Ubuntu VM’s firewall.
151+
152+
Create the Docker container as follows:
153+
```console
154+
sudo docker run -it --rm -p 80:80 mcr.microsoft.com/azurelinux/base/core:3.0
155+
```
156+
This command maps container port 80 to the Ubuntu VM’s port 80. The Golang installation steps inside the Azure Linux 3.0 container remain the same as described above.
157+
158+
Now, to allow HTTP in the firewall on your Ubuntu virtual machine, run as follows:
159+
160+
```console
161+
sudo ufw allow 80/tcp
162+
sudo ufw enable
163+
```
164+
165+
**6. Open in Browser**
166+
167+
Run the following command to print your VM’s public URL, then open it in a browser:
168+
169+
```console
170+
echo "http://$(curl -s ifconfig.me)/"
171+
```
172+
When you visit this link, you should see the styled HTML page being served directly by your Go application.
173+
174+
You should see the Golang web page confirming a successful installation of Golang.
175+
176+
![golang](images/go-web.png)
177+
178+
Now, your Golang instance is ready for further benchmarking and production use.

0 commit comments

Comments
 (0)