Azure 服務匯流排-常見問題 (常見問題) Azure Service Bus - Frequently asked questions (FAQ)

本文討論 Microsoft Azure 服務匯流排的一些常見問題解集。This article discusses some frequently asked questions about Microsoft Azure Service Bus. 您也可以造訪 Azure 支援常見問題集,以取得一般的 Azure 價格和支援資訊。You can also visit the Azure Support FAQs for general Azure pricing and support information.

關於 Azure 服務匯流排的一般問題General questions about Azure Service Bus

什麼是 Azure 服務匯流排?What is Azure Service Bus?

Azure 服務匯流排 是非同步訊息雲端平臺,可讓您在分離的系統之間傳送資料。Azure Service Bus is an asynchronous messaging cloud platform that enables you to send data between decoupled systems. Microsoft 以服務方式提供這項功能,這表示您不需要裝載您自己的硬體來使用它。Microsoft offers this feature as a service, which means that you don't need to host your own hardware to use it.

什麼是服務匯流排命名空間?What is a Service Bus namespace?

命名空間提供範圍容器,可在應用程式內定址服務匯流排資源。A namespace provides a scoping container for addressing Service Bus resources within your application. 必須建立命名空間才能使用服務匯流排,而且這也是開始使用的第一個步驟。Creating a namespace is necessary to use Service Bus and is one of the first steps in getting started.

什麼是 Azure 服務匯流排佇列?What is an Azure Service Bus queue?

服務匯流排佇列是訊息儲存所在的實體。A Service Bus queue is an entity in which messages are stored. 如果您有多個應用程式,或多個需要彼此通訊的分散式應用程式部分,佇列很有用。Queues are useful when you have multiple applications, or multiple parts of a distributed application that need to communicate with each other. 佇列和配送中心的類似之處在於,兩者都會接收多個產品 (訊息),再從該處送出。The queue is similar to a distribution center in that multiple products (messages) are received and then sent from that location.

什麼是 Azure 服務匯流排主題和訂用帳戶?What are Azure Service Bus topics and subscriptions?

主題可視覺化為佇列,而且在使用多個訂用帳戶時,主題會變成更豐富的訊息模型;基本上是一對多的通訊工具。A topic can be visualized as a queue and when using multiple subscriptions, it becomes a richer messaging model; essentially a one-to-many communication tool. 此發佈/訂閱模型 (或「pub/sub」) 可讓應用程式將訊息傳送至具有多個訂用帳戶的主題,以便讓多個應用程式接收該訊息。This publish/subscribe model (or pub/sub) enables an application that sends a message to a topic with multiple subscriptions to have that message received by multiple applications.

什麼是分割的實體?What is a partitioned entity?

傳統的佇列或主題由單一訊息代理程式處理並儲存在一個訊息存放區中。A conventional queue or topic is handled by a single message broker and stored in one messaging store. 只有在基本和標準通訊層、 分割的佇列或主題 中才支援,它是由多個訊息代理程式處理,並儲存在多個訊息存放區中。Supported only in the Basic and Standard messaging tiers, a partitioned queue, or topic is handled by multiple message brokers and stored in multiple messaging stores. 這項功能表示分割佇列或主題的整體輸送量不會再受到單一訊息代理程式或訊息存放區的效能所限制。This feature means that the overall throughput of a partitioned queue or topic is no longer limited by the performance of a single message broker or messaging store. 此外,訊息存放區暫時中斷也不會轉譯分割的佇列或主題無法使用。Also, a temporary outage of a messaging store doesn't render a partitioned queue or topic unavailable.

使用分割實體時無法確保順序。Ordering isn't ensured when using partitioned entities. 若分割無法使用,您仍可從其他分割傳送及接收訊息。In the event that a partition is unavailable, you can still send and receive messages from the other partitions.

Premium SKU 不再支援分割的實體。Partitioned entities are no longer supported in the Premium SKU.

Azure 服務匯流排將資料儲存在哪裡?Where does Azure Service Bus store data?

Azure 服務匯流排標準層會利用其後端儲存層的 Azure SQL Database。Azure Service Bus standard tier utilizes Azure SQL Database for its backend storage layer. 針對巴西南部和東南亞以外的所有區域,資料庫備份會裝載在不同的區域中, (通常是 Azure 配對的區域) 。For all regions except Brazil South and Southeast Asia, the database backup is hosted in a different region (usually the Azure paired region). 針對巴西南部和東南亞區域,資料庫備份會儲存在相同的區域中,以配合這些區域的資料存放區需求。For the Brazil south and Southeast Asia regions, database backups are stored in the same region to accommodate data-residency requirements for these regions.

Azure 服務匯流排 premium 層會將中繼資料和資料儲存在您選取的區域中。Azure Service Bus premium tier stores metadata and data in regions that you select. 針對 Azure 服務匯流排 premium 命名空間設定異地災難復原時,中繼資料會複製到您選取的次要區域。When geo-disaster recovery is set up for an Azure Service Bus premium namespace, the metadata is copied over to the secondary region that you select.

我需要在防火牆上開啟哪些連接埠?What ports do I need to open on the firewall?

您可以使用下列通訊協定搭配 Azure 服務匯流排來傳送和接收訊息:You can use the following protocols with Azure Service Bus to send and receive messages:

  • Advanced Message 佇列 Protocol 1.0 (AMQP) Advanced Message Queuing Protocol 1.0 (AMQP)
  • 使用 TLS (HTTPS) 的超文字傳輸通訊協定1。1Hypertext Transfer Protocol 1.1 with TLS (HTTPS)

請參閱下表,以瞭解您需要開啟的輸出 TCP 埠,以使用這些通訊協定與 Azure 服務匯流排通訊:See the following table for the outbound TCP ports you need to open to use these protocols to communicate with Azure Service Bus:

通訊協定Protocol PortPort 詳細資料Details
AMQPAMQP 56715671 使用 TLS AMQP。AMQP with TLS. 請參閱 AMQP 通訊協定指南See AMQP protocol guide
HTTPSHTTPS 443443 此埠用於 HTTP/REST API 和 AMQP over WebsocketThis port is used for the HTTP/REST API and for AMQP-over-WebSockets

當透過埠5671使用 AMQP 時,通常需要使用 HTTPS 埠來進行輸出通訊,因為用戶端 Sdk 會執行數個管理作業,並在使用) 透過 HTTPS 執行時從 Azure Active Directory (取得權杖。The HTTPS port is generally required for outbound communication also when AMQP is used over port 5671, because several management operations performed by the client SDKs and the acquisition of tokens from Azure Active Directory (when used) run over HTTPS.

正式的 Azure Sdk 通常會使用 AMQP 通訊協定來從服務匯流排傳送和接收訊息。The official Azure SDKs generally use the AMQP protocol for sending and receiving messages from Service Bus.

The AMQP-over-WebSockets protocol option runs over port TCP 443 just like the HTTP/REST API, but is otherwise functionally identical with plain AMQP. This option has somewhat higher initial connection latency because of extra handshake roundtrips and slightly more overhead as tradeoff for sharing the HTTPS port. If this mode is selected, TCP port 443 is sufficient for communication. The following options allow selecting the plain AMQP or AMQP WebSockets mode:

Language Option
.NET ServiceBusConnection.TransportType property with TransportType.Amqp or TransportType.AmqpWebSockets
Java com.microsoft.azure.servicebus.ClientSettings with com.microsoft.azure.servicebus.primitives.TransportType.AMQP or com.microsoft.azure.servicebus.primitives.TransportType.AMQP_WEB_SOCKETS
Node ServiceBusClientOptions has a webSocket constructor argument.
Python ServiceBusClient.transport_type with TransportType.Amqp or TransportType.AmqpOverWebSocket

.NET Framework 的舊版 WindowsAzure,可選擇使用舊版「服務匯流排訊息通訊協定」 (SBMP) ,也稱為「NetMessaging」。The older WindowsAzure.ServiceBus package for the .NET Framework has an option to use the legacy "Service Bus Messaging Protocol" (SBMP), also referred to as "NetMessaging". 此通訊協定使用 TCP 埠9350-9354。This protocol uses TCP ports 9350-9354. 此套件的預設模式是自動偵測這些埠是否可用於通訊,並且會透過埠443切換至具有 TLS 的 Websocket (如果不是這種情況)。The default mode for this package is to automatically detect whether those ports are available for communication and will switch to WebSockets with TLS over port 443 if that is not the case. 您可以覆寫此設定 Https ,並在設定上設定 connectivitymode.autodetect 來強制執行此模式,此 ServiceBusEnvironment.SystemConnectivity 設定會全域套用至應用程式。You can override this setting and force this mode by setting the Https ConnectivityMode on the ServiceBusEnvironment.SystemConnectivity setting, which applies globally to the application.

我需要在允許清單中新增哪些 IP 位址?What IP addresses do I need to add to allow list?

若要尋找要新增至連線允許清單的正確 IP 位址,請遵循下列步驟:To find the right IP addresses to add to allow list for your connections, follow these steps:

  1. 從命令提示字元執行下列命令:Run the following command from a command prompt:

    nslookup <YourNamespaceName>.servicebus.windows.net
    
  2. 記下 Non-authoritative answer 中傳回的 IP 位址。Note down the IP address returned in Non-authoritative answer.

如果您的命名空間使用 區域冗余 ,您需要執行一些額外的步驟:If you use the zone redundancy for your namespace, you need to do a few additional steps:

  1. 首先,在命名空間上執行 nslookup。First, you run nslookup on the namespace.

    nslookup <yournamespace>.servicebus.windows.net
    
  2. 記下 [非授權回答] 區段中的名稱,其採用下列其中一種格式:Note down the name in the non-authoritative answer section, which is in one of the following formats:

    <name>-s1.cloudapp.net
    <name>-s2.cloudapp.net
    <name>-s3.cloudapp.net
    
  3. 針對尾碼為 s1、s2 和 s3 的每個名稱執行 nslookup,以取得三個執行個體全都在三個可用性區域執行的 IP 位址。Run nslookup for each one with suffixes s1, s2, and s3 to get the IP addresses of all three instances running in three availability zones,

    注意

    命令傳回的 IP 位址 nslookup 不是靜態 ip 位址。The IP address returned by the nslookup command isn't a static IP address. 不過,它會保持不變,直到基礎部署被刪除或移至不同的叢集為止。However, it remains constant until the underlying deployment is deleted or moved to a different cluster.

哪裡可以找到用戶端在命名空間中傳送/接收訊息的 IP 位址?Where can I find the IP address of the client sending/receiving messages to/from a namespace?

我們不會記錄在您的命名空間中傳送或接收訊息之用戶端的 IP 位址。We don't log the IP addresses of clients sending or receiving messages to/from your namespace. 重新產生金鑰,如此一來,所有現有的用戶端就無法驗證及審核 azure 角色型存取控制 (AZURE RBAC) ) 設定,以確保只有允許的使用者或應用程式可以存取命名空間。Regenerate keys so that all existing clients will fail to authenticate and review Azure role-based access control (Azure RBAC)) settings to ensure that only allowed users or applications have access to the namespace.

如果您使用 premium 命名空間,請使用 IP 篩選虛擬網路服務端點私人端點 來限制對命名空間的存取。If you're using a premium namespace, use IP filtering, virtual network service endpoints, and private endpoints to limit access to the namespace.

最佳作法Best practices

Azure 服務匯流排的最佳做法有哪些?What are some Azure Service Bus best practices?

請參閱使用服務匯流排的效能改進最佳作法 - 這篇文章說明如何在交換訊息時將效能最佳化。See Best practices for performance improvements using Service Bus – this article describes how to optimize performance when exchanging messages.

建立實體前的須知事項為何?What should I know before creating entities?

佇列和主題的下列屬性是不可變的。The following properties of a queue and topic are immutable. 當您布建實體時,請考慮這項限制,因為這些屬性無法在不建立新的取代實體的情況下修改。Consider this limitation when you provision your entities, as these properties can't be modified without creating a new replacement entity.

  • 資料分割Partitioning
  • 工作階段Sessions
  • 重複偵測Duplicate detection
  • 快速實體Express entity

定價Pricing

本節提供服務匯流排價格結構的一些常見問題解答。This section answers some frequently asked questions about the Service Bus pricing structure.

服務匯流排定價與計費一文說明服務匯流排中的計費計量。The Service Bus pricing and billing article explains the billing meters in Service Bus. 如需服務匯流排價格選項的特定資訊,請參閱服務匯流排價格詳細資料For specific information about Service Bus pricing options, see Service Bus pricing details.

您也可以造訪 Azure 支援常見問題集,以取得一般 Azure 價格資訊。You can also visit the Azure Support FAQs for general Azure pricing information.

服務匯流排的收費方式為何?How do you charge for Service Bus?

如需服務匯流排價格的完整資訊,請參閱服務匯流排價格詳細資料For complete information about Service Bus pricing, see Service Bus pricing details. 除了註明的價格,您還需支付您的應用程式佈建所在資料中心外部的輸出相關資料傳輸費用。In addition to the prices noted, you are charged for associated data transfers for egress outside of the data center in which your application is provisioned.

何種服務匯流排用法需支付資料傳輸費用?What usage of Service Bus is subject to data transfer? 什麼不是?What isn't?

指定的 Azure 區域內的任何資料傳輸都是免費提供,以及任何輸入的資料傳輸。Any data transfer within a given Azure region is provided at no charge, as well as any inbound data transfer. 區域外部的資料傳送需要出口流量費用,可以在這裡找到。Data transfer outside a region is subject to egress charges, which can be found here.

服務匯流排是否會收取儲存體費用?Does Service Bus charge for storage?

否。No. 服務匯流排不會收取儲存體費用。Service Bus doesn't charge for storage. 不過,配額會限制每個佇列/主題可保存的最大資料量。However, there's a quota limiting the maximum amount of data that can be persisted per queue/topic. 請參閱下一個常見問題。See the next FAQ.

我有服務匯流排標準命名空間。I have a Service Bus Standard namespace. 為什麼我會在資源群組 ' $system ' 下看見費用?Why do I see charges under resource group '$system'?

Azure 服務匯流排最近升級計費元件。Azure Service Bus recently upgraded the billing components. 由於這項變更,如果您有服務匯流排標準命名空間,您可能會在資源群組 ' $system ' 下看到資源 '/subscriptions/<azure_subscription_id>/resourceGroups/$system/providers/Microsoft.ServiceBus/namespaces/$system ' 的明細專案。Because of this change, if you have a Service Bus Standard namespace, you may see line items for the resource '/subscriptions/<azure_subscription_id>/resourceGroups/$system/providers/Microsoft.ServiceBus/namespaces/$system' under resource group '$system'.

這些費用代表每個已布建服務匯流排標準命名空間的 Azure 訂用帳戶的基本費用。These charges represent the base charge per Azure subscription that has provisioned a Service Bus Standard namespace.

請務必注意,這些費用不是新的,也就是它們也存在於先前的計費模型中。It's important to note that these charges aren't new, that is, they existed in the previous billing model too. 唯一的變更是它們現在列在 [$system] 下。The only change is that they're now listed under '$system'. 這是因為新計費系統中的條件約束,會將訂用帳戶層級費用(而不是系結至特定資源)在「$system」資源識別碼下進行分組。It's done because of constraints in the new billing system that groups subscription level charges, not tied to a specific resource, under the '$system' resource ID.

配額Quotas

如需服務匯流排限制和配額的清單,請參閱服務匯流排配額概觀For a list of Service Bus limits and quotas, see the Service Bus quotas overview.

如何處理大小超過 1 MB 的訊息?How to handle messages of size > 1 MB?

「服務匯流排」訊息服務 (佇列和主題/訂用帳戶) 可讓應用程式傳送大小最大達 256 KB (標準層) 或 1 MB (進階層) 的訊息。Service Bus messaging services (queues and topics/subscriptions) allow application to send messages of size up to 256 KB (standard tier) or 1 MB (premium tier). 如果您正在處理大小超過 1 MB 的訊息,請使用 此 blog 文章中所述的宣告檢查模式。If you're dealing with messages of size greater than 1 MB, use the claim check pattern described in this blog post.

疑難排解Troubleshooting

在從另一個訂用帳戶中刪除命名空間之後,我為何無法重新建立它?Why am I not able to create a namespace after deleting it from another subscription?

在您從訂用帳戶刪除命名空間之後,必須先等候 4 個小時的時間,才能在另一個訂用帳戶中以相同的名稱重新建立它。When you delete a namespace from a subscription, wait for 4 hours before recreating it with the same name in another subscription. 否則,您可能會收到下列錯誤訊息︰Namespace already existsOtherwise, you may receive the following error message: Namespace already exists.

Azure 服務匯流排 API 所產生的例外狀況有哪些,其建議的動作為何?What are some of the exceptions generated by Azure Service Bus APIs and their suggested actions?

如需可能的服務匯流排例外狀況,請參閱例外狀況概觀For a list of possible Service Bus exceptions, see Exceptions overview.

什麼是共用存取簽章,何種語言可支援產生簽章?What is a Shared Access Signature and which languages support generating a signature?

共用存取簽章是以 SHA-256 安全雜湊或 URI 為基礎的驗證機制。Shared Access Signatures are an authentication mechanism based on SHA-256 secure hashes or URIs. 如需如何在 Node.js、PHP、JAVA、Python 和 c # 中產生您自己的簽章的詳細資訊,請參閱 共用存取 簽章文章。For information about how to generate your own signatures in Node.js, PHP, Java, Python, and C#, see the Shared Access Signatures article.

訂用帳戶和命名空間管理Subscription and namespace management

如何將命名空間移轉到另一個 Azure 訂用帳戶?How do I migrate a namespace to another Azure subscription?

您可以使用 Azure 入口網站或 PowerShell 命令,將命名空間從一個 Azure 訂用帳戶移到另一個訂用帳戶。You can move a namespace from one Azure subscription to another, using either the Azure portal or PowerShell commands. 若要執行此作業,命名空間必須已在使用中。To execute the operation, the namespace must already be active. 執行命令的使用者必須同時是來源和目標訂用帳戶上的系統管理員。The user executing the commands must be an administrator on both the source and target subscriptions.

入口網站Portal

若要使用 Azure 入口網站將「服務匯流排」移到另一個訂用帳戶,請依照這裡的指示操作。To use the Azure portal to migrate Service Bus namespaces to another subscription, follow the directions here.

PowerShellPowerShell

下列 PowerShell 命令序列會將命名空間從一個 Azure 訂用帳戶移到另一個訂用帳戶。The following sequence of PowerShell commands moves a namespace from one Azure subscription to another. 若要執行這項作業,命名空間必須已經是作用中,而且執行 PowerShell 命令的使用者必須是來源與目標訂用帳戶的系統管理員。To execute this operation, the namespace must already be active, and the user running the PowerShell commands must be an administrator on both the source and target subscriptions.

# Create a new resource group in target subscription
Select-AzSubscription -SubscriptionId 'ffffffff-ffff-ffff-ffff-ffffffffffff'
New-AzResourceGroup -Name 'targetRG' -Location 'East US'

# Move namespace from source subscription to target subscription
Select-AzSubscription -SubscriptionId 'aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa'
$res = Find-AzResource -ResourceNameContains mynamespace -ResourceType 'Microsoft.ServiceBus/namespaces'
Move-AzResource -DestinationResourceGroupName 'targetRG' -DestinationSubscriptionId 'ffffffff-ffff-ffff-ffff-ffffffffffff' -ResourceId $res.ResourceId

是否可以停用服務匯流排命名空間上的 TLS 1.0 或1.1?Is it possible to disable TLS 1.0 or 1.1 on Service Bus namespaces?

否。No. 無法停用服務匯流排命名空間上的 TLS 1.0 或1.1。It's not possible to disable TLS 1.0 or 1.1 on Service Bus namespaces. 在連接到服務匯流排的用戶端應用程式中,使用 TLS 1.2 或更新版本。In your client applications connecting to Service Bus, use TLS 1.2 or above. 如需詳細資訊,請參閱 強制搭配 Azure 服務匯流排使用 TLS 1.2-Microsoft Tech 社區For more information, see Enforcing TLS 1.2 use with Azure Service Bus - Microsoft Tech Community.

後續步驟Next steps

若要深入了解服務匯流排,請參閱下列文章:To learn more about Service Bus, see the following articles: