首页
/ diagrams Azure 节点全集:Microsoft Azure 架构图节点类参考与源码级使用指南

diagrams Azure 节点全集:Microsoft Azure 架构图节点类参考与源码级使用指南

2026-09-05 14:39:35作者:冯梦姬Eddie

本文以 docs/nodes/azure.md 这份 Azure provider 节点类清单文档为主体,系统梳理 di/diagrams 项目中 diagrams.azure 包下的 16 个子模块、200 余个节点类及其图标资源;并结合 diagrams/azure/init.pydiagrams/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.pyNode._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.pyNode.__init__ 源码可以看到,若未处于 with Diagram(...) 块内会直接抛出 EnvironmentError("Global diagrams context not set up")。节点之间通过 -(无向)、>>(前向箭头)、<<(反向箭头)以及列表广播三种方式连线,这些运算符重载同样定义在 diagrams/init.pyNode.__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]

要点说明:

  • AKSACRVMSS 是别名,等价于 KubernetesServicesContainerRegistriesVMScaleSet(见下文第四节);
  • show=False 只保存文件不弹出查看器;direction 支持 TB/BT/LR/RLoutformat 支持 png/jpg/svg/pdf/dot(见 diagrams/init.pyDiagram.__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 个)

BlobStorageCacheForRedisCosmosDbDataExplorerClustersDataFactoryDataLakeDatabaseForMariadbServersDatabaseForMysqlServersDatabaseForPostgresqlServersElasticDatabasePoolsElasticJobAgentsInstancePoolsManagedDatabasesSQLDatabasesSQLDatawarehouseSQLManagedInstancesSQLServerStretchDatabasesSQLServersSQLVMSQLSsisLiftAndShiftIrSynapseAnalyticsVirtualClustersVirtualDatacenter

对应图标文件见 docs/nodes/azure.md 该节,如 cosmos-db.pngsql-managed-instances.pngdatabase-for-mysql-servers.png 等,位于 resources/azure/database/

3.4 azure.devops(DevOps,9 个)

ApplicationInsightsArtifactsBoardsDevopsDevtestLabsLabServicesPipelinesReposTestPlans

3.5 azure.general(通用/门户,26 个)

AllresourcesAzurehomeDevelopertoolsHelpsupportInformationManagementgroupsMarketplaceQuickstartcenterRecentReservationsResourceResourcegroupsServicehealthShareddashboardSubscriptionsSupportSupportrequestsTagTagsTemplatesTwousericonUserhealthiconUsericonUserprivacyUserresourceWhatsnew

3.6 azure.identity(身份,15 个)

AccessReviewActiveDirectoryConnectHealthActiveDirectoryADB2CADDomainServicesADIdentityProtectionADPrivilegedIdentityManagementAppRegistrationsConditionalAccessEnterpriseApplicationsGroupsIdentityGovernanceInformationProtectionManagedIdentitiesUsers

3.7 azure.integration(集成,19 个)

APIForFhirAPIManagementAppConfigurationDataCatalogEventGridDomainsEventGridSubscriptionsEventGridTopicsIntegrationAccountsIntegrationServiceEnvironmentsLogicAppsCustomConnectorLogicAppsPartnerTopicSendgridAccountsServiceBusRelaysServiceBusServiceCatalogManagedApplicationDefinitionsSoftwareAsAServiceStorsimpleDeviceManagersSystemTopic

3.8 azure.iot(IoT,10 个)

DeviceProvisioningServicesDigitalTwinsIotCentralApplicationsIotHubSecurityIotHubMapsSphereTimeSeriesInsightsEnvironmentsTimeSeriesInsightsEventsSourcesWindows10IotCoreServices

3.9 azure.migration(迁移,5 个)

DataBoxEdgeDataBoxDatabaseMigrationServicesMigrationProjectsRecoveryServicesVaults

3.10 azure.ml(机器学习,10 个)

AzureOpenAIAzureSpeedToTextBatchAIBotServicesCognitiveServicesGenomicsAccountsMachineLearningServiceWorkspacesMachineLearningStudioWebServicePlansMachineLearningStudioWebServicesMachineLearningStudioWorkspaces

3.11 azure.mobile(移动,3 个)

AppServiceMobileMobileEngagementNotificationHubs

3.12 azure.monitor(监控,4 个)

ChangeAnalysisLogsMetricsMonitor

3.13 azure.network(网络,28 个)

ApplicationGatewayApplicationSecurityGroupsCDNProfilesConnectionsDDOSProtectionPlansDNSPrivateZonesDNSZonesExpressrouteCircuitsFirewallFrontDoorsLoadBalancersLocalNetworkGatewaysNetworkInterfacesNetworkSecurityGroupsClassicNetworkWatcherOnPremisesDataGatewaysPrivateEndpointPublicIpAddressesReservedIpAddressesClassicRouteFiltersRouteTablesServiceEndpointPoliciesSubnetsTrafficManagerProfilesVirtualNetworkClassicVirtualNetworkGatewaysVirtualNetworksVirtualWans

3.14 azure.security(安全,7 个)

ApplicationSecurityGroupsConditionalAccessDefenderExtendedSecurityUpdatesKeyVaultsSecurityCenterSentinel

3.15 azure.storage(存储,16 个)

ArchiveStorageAzurefxtedgefilerBlobStorageDataBoxEdgeDataBoxGatewayDataBoxDataLakeStorageGeneralStorageNetappFilesQueuesStorageStorageAccountsClassicStorageAccountsStorageExplorerStorageSyncServicesStorsimpleDataManagersStorsimpleDeviceManagersTableStorage

3.16 azure.web(Web,10 个)

APIConnectionsAppServiceCertificatesAppServiceDomainsAppServiceEnvironmentsAppServicePlansAppServicesMediaServicesNotificationHubNamespacesSearchSignalr

四、别名机制:ACR、AKS、VMSS

diagrams/azure/compute.py 文件末尾集中声明了别名:

# Aliases

ACR = ContainerRegistries
AKS = KubernetesServices
VMSS = VMScaleSet

从源码结构看,别名只是 Python 模块级的名字绑定(Name = Class),并不派生新类,因此 from diagrams.azure.compute import AKSfrom diagrams.azure.compute import KubernetesServices 得到的是同一个类对象,图标、行为完全一致;文档 docs/nodes/azure.md 中也用 "ContainerRegistries, ACR (alias)" 的格式显式标注了这三对别名。在图例说明和代码评审中,建议统一使用别名写法(AKS/ACR/VMSS 是 Azure 社区最通行的缩写),以提升可读性。

五、模块与文档的自动生成链路

理解"哪些文件不能手改"对维护 Azure 节点集非常重要。autogen.sh 揭示了完整的生成链路:

  1. 图标预处理:Azure 图标源为 SVG,autogen.shpython -m scripts.resource svg2png azure 调用 inkscape 将其转换为 PNG(脚本头部注释特别说明 azure icon set is not latest version,即图标集版本滞后于 Azure 官方图标,属于已知限制);随后 scripts.resource clean 清理资源命名;
  2. 模块与文档生成python -m scripts.generate azurescripts/generate.py 扫描 resources/azure/ 下的图标文件,自动生成 diagrams/azure/ 各模块的节点类定义,以及 docs/nodes/azure.md 这份清单文档(这也是文档中每个节点"图标 + 类名"两行一组的固定排版来源);
  3. 样式统一:最后用 black 对所有 diagrams/**/*.py 统一格式化。

由此可以推断:diagrams/azure/*.pydocs/nodes/azure.md 是同一数据源(图标目录)的两个投影,二者内容必然一致;如需扩展 Azure 节点,正确路径是向 resources/azure/<type>/ 增加图标后重新运行 autogen.sh,而非手工编辑生成的代码与文档。

六、渲染细节与常见问题

结合 diagrams/init.pyNodeDiagram 的实现,使用 Azure 节点时有几个值得了解的实现细节:

  • 节点高度自适应Node._height 默认 1.9,若 label 含换行符会按 padding = 0.4 * 换行行数 增加高度,避免标签与图标重叠;有图标时节点属性会包含 shape=noneimage 路径;
  • 多行标签:label 中可以直接使用 \n 换行,如 AKS("aks\naks-pool");配合 Diagram(autolabel=True) 可自动生成"类名\n自定义标签"的双行标签;
  • 连线方向>> 生成 dir=forward<< 生成 dir=back- 生成 dir=none,双向箭头用 Edge(label=..., style="dashed") 等属性定制(见 diagrams/init.pyEdge.attrs);
  • 输出与清理Diagram.__exit__ 渲染完成后会删除中间 .dot 文件,只保留图片;outformat 可以传列表以同时输出多种格式。

七、小结

主题 结论 依据
节点数量 diagrams.azure 共 16 个子模块、230+ 节点类 docs/nodes/azure.md
基类结构 Node -> _Azure -> _<Type> -> 叶子类 diagrams/azure/init.pydiagrams/azure/compute.py
别名 ACR/AKS/VMSS 三个模块级别名 diagrams/azure/compute.py
图标位置 resources/azure/<type>/<icon>.png diagrams/init.py_load_icon
生成方式 autogen.shscripts.resourcescripts.generate,模块与文档均自动生成,禁止手改 autogen.sh
已知限制 Azure 图标集非最新版本(脚本注释明示) autogen.sh

掌握以上清单与机制后,你可以直接以类名检索本文第三节定位节点,用第二节的示例骨架快速搭建任意 Azure 架构草图,并在图标不够新时通过第五节的生成链路自行补充资源。

登录后查看全文
热门项目推荐
相关项目推荐

项目优选

收起
kernelkernel
deepin linux kernel
C
33
18
ops-transformerops-transformer
本项目是CANN提供的transformer类大模型算子库,实现网络在NPU上加速计算。
C++
1.12 K
2.72 K
kernelkernel
openEuler内核是openEuler操作系统的核心,既是系统性能与稳定性的基石,也是连接处理器、设备与服务的桥梁。
C
528
588
ops-nnops-nn
本项目是CANN提供的神经网络类计算算子库,实现网络在NPU上加速计算。
C++
906
1.83 K
pytorchpytorch
作为 Ascend for PyTorch 社区的核心组件,TorchNPU 是昇腾专为 PyTorch 打造的深度学习适配插件,使 PyTorch 框架能够直接调用昇腾 NPU,为开发者提供昇腾 AI 处理器的超强算力。
Python
854
1.34 K
docsdocs
暂无描述
Markdown
891
5.78 K
jiuwenswarmjiuwenswarm
JiuwenSwarm 是一款基于openJiuwen开发的智能AI Agent,它能够将大语言模型的强大能力,通过你日常使用的各类通讯应用,直接延伸至你的指尖。
Python
3.53 K
1.01 K
ops-mathops-math
本项目是CANN提供的数学类基础计算算子库,实现网络在NPU上加速计算。
C++
1.34 K
1.45 K
cann-learning-hubcann-learning-hub
CANN 学习中心仓,支持在线互动运行、边学边练,提供教程、示例与优化方案,一站式助力昇腾开发者快速上手。
Jupyter Notebook
987
506
AscendNPU-IRAscendNPU-IR
AscendNPU-IR是基于MLIR(Multi-Level Intermediate Representation)构建的,面向昇腾亲和算子编译时使用的中间表示,提供昇腾完备表达能力,通过编译优化提升昇腾AI处理器计算效率,支持通过生态框架使能昇腾AI处理器与深度调优
C++
540
384