diagrams Azure 节点全集:Microsoft Azure 架构图节点类参考与源码级使用指南
本文以 docs/nodes/azure.md 这份 Azure provider 节点类清单文档为主体,系统梳理 di/diagrams 项目中 diagrams.azure 包下的 16 个子模块、200 余个节点类及其图标资源;并结合 diagrams/azure/init.py、diagrams/azure/compute.py 等源码讲解节点类的继承结构、别名机制与自动生成的实现链路,帮助你在 Diagram as Code 中精确绘制 Azure 云架构。
一、azure 包在 di/diagrams 中的位置
di/diagrams 是一个 "Diagram as Code" 工具库:用 Python 代码描述系统架构,底层由 Graphviz 渲染成图片。每个云厂商/技术栈对应一个 provider 包,Azure 对应的就是 diagrams/azure/ 目录,其入口文件 diagrams/azure/init.py 定义了所有 Azure 节点的公共基类:
from diagrams import Node
class _Azure(Node):
_provider = "azure"
_icon_dir = "resources/azure"
fontcolor = "#ffffff"
三个要点(均有源码依据):
_provider = "azure":决定了节点的__repr__输出形态(<azure.compute.KubernetesServices>),也对应文档中diagrams.azure.<module>.<Class>的全限定名;_icon_dir = "resources/azure":节点图标实际存放在仓库的resources/azure/目录下的对应子目录(如resources/azure/compute/),渲染时由 diagrams/init.py 中Node._load_icon()拼出绝对路径resources/azure/<type>/<icon>写入 Graphviz 的image属性;fontcolor = "#ffffff":Azure 节点图标为彩色底图,因此文字标签使用白色字体。
每个子模块内部再定义一层类型基类。以 diagrams/azure/compute.py 为例:
# This module is automatically generated by autogen.sh. DO NOT EDIT.
from . import _Azure
class _Compute(_Azure):
_type = "compute"
_icon_dir = "resources/azure/compute"
class AppServices(_Compute):
_icon = "app-services.png"
即继承链为 Node -> _Azure -> _Compute -> AppServices,_type 与 _icon_dir 由中间层注入,叶子类只需声明 _icon。需要特别注意的是:该文件头部明确标注 由 autogen.sh 自动生成,禁止手工编辑(后文第五节展开说明)。
二、在代码中使用 Azure 节点
所有节点类必须在 Diagram 上下文中实例化——从 diagrams/init.py 的 Node.__init__ 源码可以看到,若未处于 with Diagram(...) 块内会直接抛出 EnvironmentError("Global diagrams context not set up")。节点之间通过 -(无向)、>>(前向箭头)、<<(反向箭头)以及列表广播三种方式连线,这些运算符重载同样定义在 diagrams/init.py 的 Node.__sub__ / __rshift__ 等方法中。
一个典型的 Azure 架构示例(类名均可在 docs/nodes/azure.md 清单中查到):
from diagrams import Cluster, Diagram, Edge
from diagrams.azure.compute import AKS, AppServices, VMLinux
from diagrams.azure.database import CosmosDb, CacheForRedis
from diagrams.azure.integration import APIManagement, ServiceBus
from diagrams.azure.network import ApplicationGateway
from diagrams.azure.security import KeyVaults
with Diagram("Azure Web Service", show=False, direction="LR"):
apim = APIManagement("api-gateway")
appgw = ApplicationGateway("front-end")
with Cluster("AKS Cluster"):
app = AppServices("web-app")
k8s = AKS("aks-pool")
cache = CacheForRedis("redis")
bus = ServiceBus("event-bus")
kv = KeyVaults("key-vault")
db = CosmosDb("cosmos-db")
appgw >> apim
apim >> [app, k8s]
app >> cache
app >> bus >> db
kv - Edge(label="secrets", style="dashed") - [app, k8s]
要点说明:
AKS、ACR、VMSS是别名,等价于KubernetesServices、ContainerRegistries、VMScaleSet(见下文第四节);show=False只保存文件不弹出查看器;direction支持TB/BT/LR/RL,outformat支持png/jpg/svg/pdf/dot(见 diagrams/init.py 中Diagram.__init__的参数校验);autolabel=True时节点标签会自动在自定义文本前加上类名前缀,便于在复杂图中辨识组件类型。
更多跨 provider 的连线与集群写法可参考 docs/getting-started/examples.md 中的 "Clustered Web Services"、"Event Processing" 等示例。
三、16 个子模块的节点类完整清单
docs/nodes/azure.md 文档按 provider 分类列出了 diagrams.azure.* 下的全部节点类。以下按原清单完整继承,并标注每个类对应的图标文件(与文档中 <img src> 路径一一对应,实际文件位于 resources/azure/<type>/ 下):
3.1 azure.analytics(分析,12 个)
| 节点类 | 图标文件 |
|---|---|
diagrams.azure.analytics.AnalysisServices |
analysis-services.png |
diagrams.azure.analytics.DataExplorerClusters |
data-explorer-clusters.png |
diagrams.azure.analytics.DataFactories |
data-factories.png |
diagrams.azure.analytics.DataLakeAnalytics |
data-lake-analytics.png |
diagrams.azure.analytics.DataLakeStoreGen1 |
data-lake-store-gen1.png |
diagrams.azure.analytics.Databricks |
databricks.png |
diagrams.azure.analytics.EventHubClusters |
event-hub-clusters.png |
diagrams.azure.analytics.EventHubs |
event-hubs.png |
diagrams.azure.analytics.Hdinsightclusters |
hdinsightclusters.png |
diagrams.azure.analytics.LogAnalyticsWorkspaces |
log-analytics-workspaces.png |
diagrams.azure.analytics.StreamAnalyticsJobs |
stream-analytics-jobs.png |
diagrams.azure.analytics.SynapseAnalytics |
synapse-analytics.png |
3.2 azure.compute(计算,30 个 + 3 个别名)
| 节点类 | 图标文件 |
|---|---|
diagrams.azure.compute.AppServices |
app-services.png |
diagrams.azure.compute.AutomanagedVM |
automanaged-vm.png |
diagrams.azure.compute.AvailabilitySets |
availability-sets.png |
diagrams.azure.compute.BatchAccounts |
batch-accounts.png |
diagrams.azure.compute.CitrixVirtualDesktopsEssentials |
citrix-virtual-desktops-essentials.png |
diagrams.azure.compute.CloudServicesClassic |
cloud-services-classic.png |
diagrams.azure.compute.CloudServices |
cloud-services.png |
diagrams.azure.compute.CloudsimpleVirtualMachines |
cloudsimple-virtual-machines.png |
diagrams.azure.compute.ContainerApps |
container-apps.png |
diagrams.azure.compute.ContainerInstances |
container-instances.png |
diagrams.azure.compute.ContainerRegistries(别名 ACR) |
container-registries.png |
diagrams.azure.compute.DiskEncryptionSets |
disk-encryption-sets.png |
diagrams.azure.compute.DiskSnapshots |
disk-snapshots.png |
diagrams.azure.compute.Disks |
disks.png |
diagrams.azure.compute.FunctionApps |
function-apps.png |
diagrams.azure.compute.ImageDefinitions |
image-definitions.png |
diagrams.azure.compute.ImageVersions |
image-versions.png |
diagrams.azure.compute.KubernetesServices(别名 AKS) |
kubernetes-services.png |
diagrams.azure.compute.MeshApplications |
mesh-applications.png |
diagrams.azure.compute.OsImages |
os-images.png |
diagrams.azure.compute.SAPHANAOnAzure |
sap-hana-on-azure.png |
diagrams.azure.compute.ServiceFabricClusters |
service-fabric-clusters.png |
diagrams.azure.compute.SharedImageGalleries |
shared-image-galleries.png |
diagrams.azure.compute.SpringCloud |
spring-cloud.png |
diagrams.azure.compute.VMClassic |
vm-classic.png |
diagrams.azure.compute.VMImages |
vm-images.png |
diagrams.azure.compute.VMLinux |
vm-linux.png |
diagrams.azure.compute.VMScaleSet(别名 VMSS) |
vm-scale-set.png |
diagrams.azure.compute.VMWindows |
vm-windows.png |
diagrams.azure.compute.VM |
vm.png |
diagrams.azure.compute.Workspaces |
workspaces.png |
3.3 azure.database(数据库,24 个)
BlobStorage、CacheForRedis、CosmosDb、DataExplorerClusters、DataFactory、DataLake、DatabaseForMariadbServers、DatabaseForMysqlServers、DatabaseForPostgresqlServers、ElasticDatabasePools、ElasticJobAgents、InstancePools、ManagedDatabases、SQLDatabases、SQLDatawarehouse、SQLManagedInstances、SQLServerStretchDatabases、SQLServers、SQLVM、SQL、SsisLiftAndShiftIr、SynapseAnalytics、VirtualClusters、VirtualDatacenter
对应图标文件见 docs/nodes/azure.md 该节,如 cosmos-db.png、sql-managed-instances.png、database-for-mysql-servers.png 等,位于 resources/azure/database/。
3.4 azure.devops(DevOps,9 个)
ApplicationInsights、Artifacts、Boards、Devops、DevtestLabs、LabServices、Pipelines、Repos、TestPlans
3.5 azure.general(通用/门户,26 个)
Allresources、Azurehome、Developertools、Helpsupport、Information、Managementgroups、Marketplace、Quickstartcenter、Recent、Reservations、Resource、Resourcegroups、Servicehealth、Shareddashboard、Subscriptions、Support、Supportrequests、Tag、Tags、Templates、Twousericon、Userhealthicon、Usericon、Userprivacy、Userresource、Whatsnew
3.6 azure.identity(身份,15 个)
AccessReview、ActiveDirectoryConnectHealth、ActiveDirectory、ADB2C、ADDomainServices、ADIdentityProtection、ADPrivilegedIdentityManagement、AppRegistrations、ConditionalAccess、EnterpriseApplications、Groups、IdentityGovernance、InformationProtection、ManagedIdentities、Users
3.7 azure.integration(集成,19 个)
APIForFhir、APIManagement、AppConfiguration、DataCatalog、EventGridDomains、EventGridSubscriptions、EventGridTopics、IntegrationAccounts、IntegrationServiceEnvironments、LogicAppsCustomConnector、LogicApps、PartnerTopic、SendgridAccounts、ServiceBusRelays、ServiceBus、ServiceCatalogManagedApplicationDefinitions、SoftwareAsAService、StorsimpleDeviceManagers、SystemTopic
3.8 azure.iot(IoT,10 个)
DeviceProvisioningServices、DigitalTwins、IotCentralApplications、IotHubSecurity、IotHub、Maps、Sphere、TimeSeriesInsightsEnvironments、TimeSeriesInsightsEventsSources、Windows10IotCoreServices
3.9 azure.migration(迁移,5 个)
DataBoxEdge、DataBox、DatabaseMigrationServices、MigrationProjects、RecoveryServicesVaults
3.10 azure.ml(机器学习,10 个)
AzureOpenAI、AzureSpeedToText、BatchAI、BotServices、CognitiveServices、GenomicsAccounts、MachineLearningServiceWorkspaces、MachineLearningStudioWebServicePlans、MachineLearningStudioWebServices、MachineLearningStudioWorkspaces
3.11 azure.mobile(移动,3 个)
AppServiceMobile、MobileEngagement、NotificationHubs
3.12 azure.monitor(监控,4 个)
ChangeAnalysis、Logs、Metrics、Monitor
3.13 azure.network(网络,28 个)
ApplicationGateway、ApplicationSecurityGroups、CDNProfiles、Connections、DDOSProtectionPlans、DNSPrivateZones、DNSZones、ExpressrouteCircuits、Firewall、FrontDoors、LoadBalancers、LocalNetworkGateways、NetworkInterfaces、NetworkSecurityGroupsClassic、NetworkWatcher、OnPremisesDataGateways、PrivateEndpoint、PublicIpAddresses、ReservedIpAddressesClassic、RouteFilters、RouteTables、ServiceEndpointPolicies、Subnets、TrafficManagerProfiles、VirtualNetworkClassic、VirtualNetworkGateways、VirtualNetworks、VirtualWans
3.14 azure.security(安全,7 个)
ApplicationSecurityGroups、ConditionalAccess、Defender、ExtendedSecurityUpdates、KeyVaults、SecurityCenter、Sentinel
3.15 azure.storage(存储,16 个)
ArchiveStorage、Azurefxtedgefiler、BlobStorage、DataBoxEdgeDataBoxGateway、DataBox、DataLakeStorage、GeneralStorage、NetappFiles、QueuesStorage、StorageAccountsClassic、StorageAccounts、StorageExplorer、StorageSyncServices、StorsimpleDataManagers、StorsimpleDeviceManagers、TableStorage
3.16 azure.web(Web,10 个)
APIConnections、AppServiceCertificates、AppServiceDomains、AppServiceEnvironments、AppServicePlans、AppServices、MediaServices、NotificationHubNamespaces、Search、Signalr
四、别名机制:ACR、AKS、VMSS
diagrams/azure/compute.py 文件末尾集中声明了别名:
# Aliases
ACR = ContainerRegistries
AKS = KubernetesServices
VMSS = VMScaleSet
从源码结构看,别名只是 Python 模块级的名字绑定(Name = Class),并不派生新类,因此 from diagrams.azure.compute import AKS 与 from diagrams.azure.compute import KubernetesServices 得到的是同一个类对象,图标、行为完全一致;文档 docs/nodes/azure.md 中也用 "ContainerRegistries, ACR (alias)" 的格式显式标注了这三对别名。在图例说明和代码评审中,建议统一使用别名写法(AKS/ACR/VMSS 是 Azure 社区最通行的缩写),以提升可读性。
五、模块与文档的自动生成链路
理解"哪些文件不能手改"对维护 Azure 节点集非常重要。autogen.sh 揭示了完整的生成链路:
- 图标预处理:Azure 图标源为 SVG,
autogen.sh中python -m scripts.resource svg2png azure调用 inkscape 将其转换为 PNG(脚本头部注释特别说明azure icon set is not latest version,即图标集版本滞后于 Azure 官方图标,属于已知限制);随后scripts.resource clean清理资源命名; - 模块与文档生成:
python -m scripts.generate azure由 scripts/generate.py 扫描resources/azure/下的图标文件,自动生成 diagrams/azure/ 各模块的节点类定义,以及 docs/nodes/azure.md 这份清单文档(这也是文档中每个节点"图标 + 类名"两行一组的固定排版来源); - 样式统一:最后用
black对所有diagrams/**/*.py统一格式化。
由此可以推断:diagrams/azure/*.py 与 docs/nodes/azure.md 是同一数据源(图标目录)的两个投影,二者内容必然一致;如需扩展 Azure 节点,正确路径是向 resources/azure/<type>/ 增加图标后重新运行 autogen.sh,而非手工编辑生成的代码与文档。
六、渲染细节与常见问题
结合 diagrams/init.py 中 Node 与 Diagram 的实现,使用 Azure 节点时有几个值得了解的实现细节:
- 节点高度自适应:
Node._height默认 1.9,若 label 含换行符会按padding = 0.4 * 换行行数增加高度,避免标签与图标重叠;有图标时节点属性会包含shape=none与image路径; - 多行标签:label 中可以直接使用
\n换行,如AKS("aks\naks-pool");配合Diagram(autolabel=True)可自动生成"类名\n自定义标签"的双行标签; - 连线方向:
>>生成dir=forward,<<生成dir=back,-生成dir=none,双向箭头用Edge(label=..., style="dashed")等属性定制(见 diagrams/init.py 中Edge.attrs); - 输出与清理:
Diagram.__exit__渲染完成后会删除中间.dot文件,只保留图片;outformat可以传列表以同时输出多种格式。
七、小结
| 主题 | 结论 | 依据 |
|---|---|---|
| 节点数量 | diagrams.azure 共 16 个子模块、230+ 节点类 |
docs/nodes/azure.md |
| 基类结构 | Node -> _Azure -> _<Type> -> 叶子类 |
diagrams/azure/init.py、diagrams/azure/compute.py |
| 别名 | ACR/AKS/VMSS 三个模块级别名 |
diagrams/azure/compute.py |
| 图标位置 | resources/azure/<type>/<icon>.png |
diagrams/init.py 中 _load_icon |
| 生成方式 | autogen.sh → scripts.resource → scripts.generate,模块与文档均自动生成,禁止手改 |
autogen.sh |
| 已知限制 | Azure 图标集非最新版本(脚本注释明示) | autogen.sh |
掌握以上清单与机制后,你可以直接以类名检索本文第三节定位节点,用第二节的示例骨架快速搭建任意 Azure 架构草图,并在图标不够新时通过第五节的生成链路自行补充资源。
atomcodeClaude Code 的开源替代方案。连接任意大模型,编辑代码,运行命令,自动验证 — 全自动执行。用 Rust 构建,极致性能。 | An open-source alternative to Claude Code. Connect any LLM, edit code, run commands, and verify changes — autonomously. Built in Rust for speed. Get StartedRust0623
Hy4-previewHy4 preview 是由腾讯混元团队研发的新一代混合专家(MoE)旗舰模型。模型总参数量 770B,每个 token 激活 49B,主干共包含78层,第一层采用标准 FFN,其余 77 层均为 MoE 结构,每层包含 256 个路由专家与 1 个共享专家,每个 token 激活 top-8 路由专家及共享专家。主干之外原生内置 1 层 MTP(总参数量 10B,激活 0.7B)以支持投机解码。Python00
GLM-5.3GLM-5.3 与 GLM-5.2 使用相同的基座模型——所有提升均来自后训练。与 GLM-5.2 相比,它在复杂编程和长程任务上的表现显著提升。Jinja00
GLM-5.3-FlashGLM-5.3-Flash (320B-A18B),是GLM-5系列的首个原生多模态模型。320B总参数,能力超过GLM-5.2Jinja00
Spark-X2.5-4BSpark-X2.5-4B 旨在让强大的 AI 更实用、更高效、更易获得。在广泛日常任务中表现强劲,涵盖对话、写作、翻译、推理、编码、工具调用以及智能体工作流,并在同等规模的开源模型中取得领先成绩。Spark-X2.5 将面向效率的架构与最高 1M tokens 的原生上下文窗口相结合,并支持 200 多种语言。Python00
Spark-X2.5-1.7BSpark-X2.5-1.7B 旨在让强大的 AI 更加实用、高效且易于获取。这些模型在广泛的日常任务中表现出色,涵盖对话、写作、翻译、推理、编程、工具调用和智能体工作流,并在同等规模的开源模型中取得领先结果。Spark-X2.5 将面向效率的架构与最高 1M tokens 的原生上下文窗口相结合,并支持 200 多种语言。Python00