Azure Service Groups 概述(public preview)

发布: (2025年12月3日 GMT+8 04:38)
4 min read
原文: Dev.to

Source: Dev.to

概览

在 Azure 租户中,管理组用于组织订阅、定义访问控制并应用策略。当单个工作负载的资源跨多个订阅部署时,管理会变得更加复杂。Azure Service Groups 通过允许您在不移动资源的情况下对资源进行分组来解决此问题。

Service Group 是一种逻辑容器,可跨订阅和资源组对资源进行分组,同时保持每个资源位于其原始订阅中。它可以在管理组层级内进行管理,并存储用于标识工作负载、跟踪状态和管理流程的元数据。

使用场景

  • 网络团队 – 对跨多个订阅的网关、负载均衡器和其他网络服务进行分组。为团队成员分配 Service Group Reader 角色,以便他们可以查看该组及其子资源。
  • 清单与监控 – 获取组内资源的清单、问题列表、应用映射、可用性测试(当链接了 Application Insights 时)以及针对 VM 和 AKS 的监控建议。

命名与层级

  • 每个 Service Group 需要一个唯一的全局名称(最长 250 个字符),类似于存储账户名称。
  • Service Group 形成层级结构:您可以在顶层(租户根 Service Group 下)创建 Service Group,或作为另一个 Service Group 的子项创建。

使用 Bicep 创建 Service Group

您可以通过 Azure 门户或 Azure REST API 创建 Service Group 并关联资源。目前尚无专用的 PowerShell cmdlet 或 Azure CLI 命令。

param serviceGroupId string
param parentServiceGroupId string
param serviceGroupName string 
param storageAccountName string

resource serviceGroup 'Microsoft.Management/serviceGroups@2024-02-01-preview' = {
  scope: tenant()
  name: serviceGroupId
  properties: {
    displayName: serviceGroupName
    parent: {
      resourceId: '/providers/Microsoft.Management/serviceGroups/${parentServiceGroupId}'
    }
  }
}

resource storageAccount 'Microsoft.Storage/storageAccounts@2025-06-01' existing = {
  name: storageAccountName
}

resource rel1 'Microsoft.Relationships/serviceGroupMember@2023-09-01-preview' = {
  scope: storageAccount
  name: 'childResource1'
  properties: {
    targetId: serviceGroup.id
  }
}
  • serviceGroup 资源在租户级别创建 Service Group。
  • rel1 资源使用 Microsoft.Relationships/serviceGroupMember 将现有存储账户链接到 Service Group。

使用 ARM 模板创建 Service Group

如果需要使用资源 ID 指定范围,可以使用 ARM 模板:

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "storageAccountName": { "type": "string" },
    "storageAccountRG":   { "type": "string" },
    "storageAccountSubID":{ "type": "string" },
    "targetServiceGroupResourceID": { "type": "string" }
  },
  "resources": [
    {
      "type": "Microsoft.Relationships/serviceGroupMember",
      "apiVersion": "2023-09-01-preview",
      "name": "[concat('rel-', parameters('storageAccountName'))]",
      "scope": "[resourceId(parameters('storageAccountSubID'), parameters('storageAccountRG'), 'Microsoft.Storage/storageAccounts/', parameters('storageAccountName'))]",
      "properties": {
        "targetId": "[parameters('targetServiceGroupResourceID')]"
      }
    }
  ],
  "outputs": {}
}

预览通知

Service Groups 目前处于公开预览阶段。API 和工具在正式发布前可能会发生变化,但该功能值得在中大型 Azure 租户中进行评估。

Back to Blog

相关文章

阅读更多 »

Friday Five — 2025年12月5日

https://www.redhat.com/rhdc/managed-files/styles/default_800/private/number-1.png.webp?itok=pDWx13kK Red Hat 将在 AWS 上提供增强的 AI 推理