ARTICLE DETAIL

资讯详情

深耕网站视觉设计与运营推广的一线实战洞察。

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

diagrams Azure 节点全集:Microsoft Azure 架构图节点类参考与源码级使用指南 diagrams Azure 节点全集Microsoft Azure 架构图节点类参考与源码级使用指南【免费下载链接】diagrams:art: Diagram as Code for prototyping cloud system architectures项目地址: https://gitcode.com/GitHub_Trending/di/diagrams本文以 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 #ffffffAzure 节点图标为彩色底图因此文字标签使用白色字体。每个子模块内部再定义一层类型基类。以 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, showFalse, directionLR): 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(labelsecrets, styledashed) - [app, k8s]要点说明AKS、ACR、VMSS是别名等价于KubernetesServices、ContainerRegistries、VMScaleSet见下文第四节showFalse只保存文件不弹出查看器direction支持TB/BT/LR/RLoutformat支持png/jpg/svg/pdf/dot见 diagrams/init.py 中Diagram.__init__的参数校验autolabelTrue时节点标签会自动在自定义文本前加上类名前缀便于在复杂图中辨识组件类型。更多跨 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.AnalysisServicesanalysis-services.pngdiagrams.azure.analytics.DataExplorerClustersdata-explorer-clusters.pngdiagrams.azure.analytics.DataFactoriesdata-factories.pngdiagrams.azure.analytics.DataLakeAnalyticsdata-lake-analytics.pngdiagrams.azure.analytics.DataLakeStoreGen1data-lake-store-gen1.pngdiagrams.azure.analytics.Databricksdatabricks.pngdiagrams.azure.analytics.EventHubClustersevent-hub-clusters.pngdiagrams.azure.analytics.EventHubsevent-hubs.pngdiagrams.azure.analytics.Hdinsightclustershdinsightclusters.pngdiagrams.azure.analytics.LogAnalyticsWorkspaceslog-analytics-workspaces.pngdiagrams.azure.analytics.StreamAnalyticsJobsstream-analytics-jobs.pngdiagrams.azure.analytics.SynapseAnalyticssynapse-analytics.png3.2 azure.compute计算30 个 3 个别名节点类图标文件diagrams.azure.compute.AppServicesapp-services.pngdiagrams.azure.compute.AutomanagedVMautomanaged-vm.pngdiagrams.azure.compute.AvailabilitySetsavailability-sets.pngdiagrams.azure.compute.BatchAccountsbatch-accounts.pngdiagrams.azure.compute.CitrixVirtualDesktopsEssentialscitrix-virtual-desktops-essentials.pngdiagrams.azure.compute.CloudServicesClassiccloud-services-classic.pngdiagrams.azure.compute.CloudServicescloud-services.pngdiagrams.azure.compute.CloudsimpleVirtualMachinescloudsimple-virtual-machines.pngdiagrams.azure.compute.ContainerAppscontainer-apps.pngdiagrams.azure.compute.ContainerInstancescontainer-instances.pngdiagrams.azure.compute.ContainerRegistries别名ACRcontainer-registries.pngdiagrams.azure.compute.DiskEncryptionSetsdisk-encryption-sets.pngdiagrams.azure.compute.DiskSnapshotsdisk-snapshots.pngdiagrams.azure.compute.Disksdisks.pngdiagrams.azure.compute.FunctionAppsfunction-apps.pngdiagrams.azure.compute.ImageDefinitionsimage-definitions.pngdiagrams.azure.compute.ImageVersionsimage-versions.pngdiagrams.azure.compute.KubernetesServices别名AKSkubernetes-services.pngdiagrams.azure.compute.MeshApplicationsmesh-applications.pngdiagrams.azure.compute.OsImagesos-images.pngdiagrams.azure.compute.SAPHANAOnAzuresap-hana-on-azure.pngdiagrams.azure.compute.ServiceFabricClustersservice-fabric-clusters.pngdiagrams.azure.compute.SharedImageGalleriesshared-image-galleries.pngdiagrams.azure.compute.SpringCloudspring-cloud.pngdiagrams.azure.compute.VMClassicvm-classic.pngdiagrams.azure.compute.VMImagesvm-images.pngdiagrams.azure.compute.VMLinuxvm-linux.pngdiagrams.azure.compute.VMScaleSet别名VMSSvm-scale-set.pngdiagrams.azure.compute.VMWindowsvm-windows.pngdiagrams.azure.compute.VMvm.pngdiagrams.azure.compute.Workspacesworkspaces.png3.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.devopsDevOps9 个ApplicationInsights、Artifacts、Boards、Devops、DevtestLabs、LabServices、Pipelines、Repos、TestPlans3.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、Whatsnew3.6 azure.identity身份15 个AccessReview、ActiveDirectoryConnectHealth、ActiveDirectory、ADB2C、ADDomainServices、ADIdentityProtection、ADPrivilegedIdentityManagement、AppRegistrations、ConditionalAccess、EnterpriseApplications、Groups、IdentityGovernance、InformationProtection、ManagedIdentities、Users3.7 azure.integration集成19 个APIForFhir、APIManagement、AppConfiguration、DataCatalog、EventGridDomains、EventGridSubscriptions、EventGridTopics、IntegrationAccounts、IntegrationServiceEnvironments、LogicAppsCustomConnector、LogicApps、PartnerTopic、SendgridAccounts、ServiceBusRelays、ServiceBus、ServiceCatalogManagedApplicationDefinitions、SoftwareAsAService、StorsimpleDeviceManagers、SystemTopic3.8 azure.iotIoT10 个DeviceProvisioningServices、DigitalTwins、IotCentralApplications、IotHubSecurity、IotHub、Maps、Sphere、TimeSeriesInsightsEnvironments、TimeSeriesInsightsEventsSources、Windows10IotCoreServices3.9 azure.migration迁移5 个DataBoxEdge、DataBox、DatabaseMigrationServices、MigrationProjects、RecoveryServicesVaults3.10 azure.ml机器学习10 个AzureOpenAI、AzureSpeedToText、BatchAI、BotServices、CognitiveServices、GenomicsAccounts、MachineLearningServiceWorkspaces、MachineLearningStudioWebServicePlans、MachineLearningStudioWebServices、MachineLearningStudioWorkspaces3.11 azure.mobile移动3 个AppServiceMobile、MobileEngagement、NotificationHubs3.12 azure.monitor监控4 个ChangeAnalysis、Logs、Metrics、Monitor3.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、VirtualWans3.14 azure.security安全7 个ApplicationSecurityGroups、ConditionalAccess、Defender、ExtendedSecurityUpdates、KeyVaults、SecurityCenter、Sentinel3.15 azure.storage存储16 个ArchiveStorage、Azurefxtedgefiler、BlobStorage、DataBoxEdgeDataBoxGateway、DataBox、DataLakeStorage、GeneralStorage、NetappFiles、QueuesStorage、StorageAccountsClassic、StorageAccounts、StorageExplorer、StorageSyncServices、StorsimpleDataManagers、StorsimpleDeviceManagers、TableStorage3.16 azure.webWeb10 个APIConnections、AppServiceCertificates、AppServiceDomains、AppServiceEnvironments、AppServicePlans、AppServices、MediaServices、NotificationHubNamespaces、Search、Signalr四、别名机制ACR、AKS、VMSSdiagrams/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 图标源为 SVGautogen.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 * 换行行数增加高度避免标签与图标重叠有图标时节点属性会包含shapenone与image路径多行标签label 中可以直接使用\n换行如AKS(aks\naks-pool)配合Diagram(autolabelTrue)可自动生成类名\n自定义标签的双行标签连线方向生成dirforward生成dirback-生成dirnone双向箭头用Edge(label..., styledashed)等属性定制见 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.pngdiagrams/init.py 中_load_icon生成方式autogen.sh→scripts.resource→scripts.generate模块与文档均自动生成禁止手改autogen.sh已知限制Azure 图标集非最新版本脚本注释明示autogen.sh掌握以上清单与机制后你可以直接以类名检索本文第三节定位节点用第二节的示例骨架快速搭建任意 Azure 架构草图并在图标不够新时通过第五节的生成链路自行补充资源。【免费下载链接】diagrams:art: Diagram as Code for prototyping cloud system architectures项目地址: https://gitcode.com/GitHub_Trending/di/diagrams创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表