在 Azure 服務匯流排基本或標準中啟用資料分割

服務匯流排分割區可讓佇列和主題 (或傳訊實體) 分割到多個訊息代理程式。 資料分割表示分割實體的整體輸送量不會再受到單一訊息代理程式的效能所限制。 此外,例如升級期間,暫時中斷訊息代理程式也不會讓分割的佇列或主題無法使用。 分割的佇列和主題可以包含所有進階的服務匯流排功能,例如支援交易和工作階段。 如需詳細資訊,請參閱分割的佇列和主題。 本文說明為服務匯流排佇列或主題啟用重複訊息偵測的不同方式。

重要

  • 基本標準 SKU 中的所有佇列與主題在建立實體時均可使用資料分割。
  • 您無法為任何現有的佇列或主題變更資料分割選項。 您只能在建立佇列或主題時設定選項。
  • 標準層命名空間中,您可以建立 1、2、3、4 或 5 GB 大小的服務匯流排佇列和主題 (預設值為 1 GB)。 啟用分割時,服務匯流排會根據您所指定的大小,以每 GB 建立 16 個複本 (16 個資料分割)。 因此,如果您建立 5 GB 大小的佇列,每 GB 有 16 個資料分割,則佇列大小上限會變成 (5 * 16) = 80 GB。

使用 Azure 入口網站

在Azure 入口網站中建立佇列時,請選取 [啟用資料分割],如下圖所示。

Enable partitioning at the time of the queue creation

在Azure 入口網站中建立主題時,請選取 [啟用資料分割],如下圖所示。

Enable partitioning at the time of the topic creation

使用 Azure CLI

若要建立已啟用資料分割的佇列,請使用 az servicebus queue create 命令,並將 --enable-partitioning 設為 true

az servicebus queue create \
    --resource-group myresourcegroup \
    --namespace-name mynamespace \
    --name myqueue \
    --enable-partitioning true

若要建立已啟用資料分割的主題,請使用 az servicebus topic create 命令,並將 --enable-partitioning 設為 true

az servicebus topic create \
    --resource-group myresourcegroup \
    --namespace-name mynamespace \
    --name mytopic \
    --enable-partitioning true

使用 Azure PowerShell

若要建立已啟用資料分割的佇列,請使用 New-AzServiceBusQueue 命令,並將 -EnablePartitioning 設為 $True

New-AzServiceBusQueue -ResourceGroup myresourcegroup `
    -NamespaceName mynamespace `
    -QueueName myqueue `
    -EnablePartitioning $True

若要建立已啟用資料分割的主題,請使用 New-AzServiceBusTopic 命令,並將 -EnablePartitioning 設為 true

New-AzServiceBusTopic -ResourceGroup myresourcegroup `
    -NamespaceName mynamespace `
    -Name mytopic `
    -EnablePartitioning $True

使用 Azure Resource Manager 範本

若要建立已啟用資料分割的佇列,請在佇列屬性區段中將 enablePartitioning 設定為 true。 如需詳細資訊,請參閱 Microsoft.ServiceBus 命名空間/佇列範本參考

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "serviceBusNamespaceName": {
      "type": "string",
      "metadata": {
        "description": "Name of the Service Bus namespace"
      }
    },
    "serviceBusQueueName": {
      "type": "string",
      "metadata": {
        "description": "Name of the Queue"
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    }
  },
  "resources": [
    {
      "type": "Microsoft.ServiceBus/namespaces",
      "apiVersion": "2018-01-01-preview",
      "name": "[parameters('serviceBusNamespaceName')]",
      "location": "[parameters('location')]",
      "sku": {
        "name": "Standard"
      },
      "properties": {},
      "resources": [
        {
          "type": "Queues",
          "apiVersion": "2017-04-01",
          "name": "[parameters('serviceBusQueueName')]",
          "dependsOn": [
            "[resourceId('Microsoft.ServiceBus/namespaces', parameters('serviceBusNamespaceName'))]"
          ],
          "properties": {
            "enablePartitioning": true
          }
        }
      ]
    }
  ]
}

若要建立已啟用重複偵測的主題,請在主題屬性區段中將 enablePartitioning 設定為 true。 如需詳細資訊,請參閱 Microsoft.ServiceBus 命名空間/主題範本參考

{
  "$schema": "https://schema.management.azure.com/schemas/2019-04-01/deploymentTemplate.json#",
  "contentVersion": "1.0.0.0",
  "parameters": {
    "service_BusNamespace_Name": {
      "type": "string",
      "metadata": {
        "description": "Name of the Service Bus namespace"
      }
    },
    "serviceBusTopicName": {
      "type": "string",
      "metadata": {
        "description": "Name of the Topic"
      }
    },
    "location": {
      "type": "string",
      "defaultValue": "[resourceGroup().location]",
      "metadata": {
        "description": "Location for all resources."
      }
    }
  },
  "resources": [
    {
      "apiVersion": "2018-01-01-preview",
      "name": "[parameters('service_BusNamespace_Name')]",
      "type": "Microsoft.ServiceBus/namespaces",
      "location": "[parameters('location')]",
      "sku": {
        "name": "Standard"
      },
      "properties": {},
      "resources": [
        {
          "apiVersion": "2017-04-01",
          "name": "[parameters('serviceBusTopicName')]",
          "type": "topics",
          "dependsOn": [
            "[resourceId('Microsoft.ServiceBus/namespaces/', parameters('service_BusNamespace_Name'))]"
          ],
          "properties": {
            "enablePartitioning": true
          }
        }
      ]
    }
  ]
}

下一步

請以您所選擇的語言嘗試各式範例,以探索 Azure 服務匯流排的功能。

請在下方尋找舊版 .NET 和 JAVA 用戶端程式庫的範例:

在 2026 年 9 月 30 日,我們將淘汰不符合 Azure SDK 準則的 Azure 服務匯流排 SDK 程式庫 WindowsAzure.ServiceBus、Microsoft.Azure.ServiceBus 和 com.microsoft.azure.servicebus。 我們也將結束 SBMP 通訊協定的支援,因此您將無法在 2026 年 9 月 30 日之後再使用此通訊協定。 請在該日期之前移轉至最新的 Azure SDK 程式庫,該程式庫提供重要的安全性更新和改進的功能。

雖然較舊的程式庫仍可在 2026 年 9 月 30 日之後使用,但這些程式庫將無法繼續收到 Microsoft 的官方支援和更新。 如需詳細資訊,請參閱支援淘汰公告