如何部署和配置 Azure Monitor
发布: (2026年1月2日 GMT+8 03:31)
3 分钟阅读
原文: Dev.to
Source: Dev.to
准备 Azure 环境
-
创建资源组
- 搜索 Resource Groups → Create
- 名称:
rg-alpha - 地区: East US
- 点击 Review + create → Create
此资源组将容纳 Azure Monitor 将要监视的所有资源。
创建安全组(可选 – 实验室使用)
- 搜索 Azure Active Directory / Entra ID → Groups → New group
- 组类型: Security
- 名称:
App Log Examiners - 点击 Create
部署要监视的虚拟机
部署 Windows 虚拟机 (WS‑VM1)
-
搜索 Virtual Machines → Create
-
基础信息
- 名称:
WS-VM1 - 地区: East US
- 镜像: Windows Server 2022 Datacenter
- 大小: Standard_D4s_v3
- 管理员用户名:
prime - 密码: 你的安全密码
- 入站端口: RDP (3389)
- 名称:
-
点击 Create 并等待部署完成。
-
部署完成后,选择 Go to resource → Networking。
- 编辑默认的 RDP 规则:将 Source 设置为 My IP address 并 Save。
- 添加入站规则:
- Source: Any
- Destination port ranges:
310 - Protocol: TCP
- Action: Allow
- Name:
AllowAnyHTTPInbound
-
通过 RDP 连接:
- 选择 Connect → Native RDP → Download RDP file。
- 在 Windows Security 对话框中,选择 More choices → Use a different account。
- 用户名:
.\prime - 密码: 你的安全密码 → OK。
-
在虚拟机内部,打开 Windows PowerShell (Admin) 并运行:
Install-WindowsFeature Web-Server -IncludeAllSubFeature -IncludeManagementTools cd C:\inetpub\wwwroot Invoke-WebRequest https://raw.githubusercontent.com/Azure-Samples/html-docs-hello-world/master/index.html -OutFile index.html
部署 Linux 虚拟机 (Linux‑VM2)
- 搜索 Virtual Machines → Create
- 基础信息
- 名称:
Linux-VM2 - 资源组:
rg-alpha - 可用性选项: No infrastructure redundancy required
- 镜像: Ubuntu Server 20.04 LTS
- 大小: Standard_D2s_v3
- 架构: x64
- 用户名:
prime - 密码: 你的安全密码
- 名称:
- 点击 Review + create → Create。
- 部署完成后,打开 Settings 下的 Extensions + Applications。
- 添加 Network Watcher Agent for Linux 扩展:Add → Next → Review + create → Create。
部署带 SQL 数据库的 Web 应用
- 打开模板仓库。
- 点击 Deploy to Azure。
- 如有提示,请使用具有全局管理员权限的账户登录。
- 在 Basics 页面,选择 Edit template。
- 在编辑器中,删除 158‑174 行(包括这两行),并删除 157 行末尾的逗号。点击 Save。
- 在 Basics 页面提供所需参数,然后点击 Next。
- 审核配置并点击 Create。
- 部署完成后,选择 Go to resource group 查看新创建的 Web 应用和 SQL 数据库。