Azure 中继常见问题解答Azure Relay FAQs

本文解答一些关于 Azure 中继的常见问题 (FAQ)。This article answers some frequently asked questions (FAQs) about Azure Relay. 若要了解一般的 Azure 定价和支持信息,请参阅 Azure 支持常见问题解答For general Azure pricing and support information, see the Azure Support FAQs.


本文进行了更新,以便使用新的 Azure PowerShell Az 模块。This article has been updated to use the new Azure PowerShell Az module. 你仍然可以使用 AzureRM 模块,至少在 2020 年 12 月之前,它将继续接收 bug 修补程序。You can still use the AzureRM module, which will continue to receive bug fixes until at least December 2020. 若要详细了解新的 Az 模块和 AzureRM 兼容性,请参阅新 Azure Powershell Az 模块简介To learn more about the new Az module and AzureRM compatibility, see Introducing the new Azure PowerShell Az module. 有关 Az 模块安装说明,请参阅安装 Azure PowerShellFor Az module installation instructions, see Install Azure PowerShell.

一般问题General questions

什么是 Azure 中继?What is Azure Relay?

Azure 中继服务可以帮助你以更安全的方式将企业网络中驻留的服务公开给公有云,从而改进混合应用程序的使用。The Azure Relay service facilitates your hybrid applications by helping you more securely expose services that reside within a corporate enterprise network to the public cloud. 可以在不打开防火墙连接的情况下公开服务,不需对企业网络基础结构进行干预性更改。You can expose the services without opening a firewall connection, and without requiring intrusive changes to a corporate network infrastructure.

什么是中继命名空间?What is a Relay namespace?

命名空间是一个范围容器,可用于对应用程序中的中继资源进行寻址。A namespace is a scoping container that you can use to address Relay resources within your application. 必须创建命名空间才能使用中继。You must create a namespace to use Relay. 这是入门的开始步骤之一。This is one of the first steps in getting started.

服务总线中继服务发生了什么情况?What happened to Service Bus Relay service?

旧称“服务总线中继服务”现在称为 Azure 中继The previously named Service Bus Relay service is now called Azure Relay. 可以继续照常使用此服务。You can continue to use this service as usual. 混合连接功能是一种更新版的服务,从 Azure BizTalk 服务移植过来。The Hybrid Connections feature is an updated version of a service that's been transplanted from Azure BizTalk Services. 将继续支持 WCF 中继和混合连接。WCF Relay and Hybrid Connections both continue to be supported.


本部分回答了一些关于中继定价结构的常见问题。This section answers some frequently asked questions about the Relay pricing structure. 若要了解一般的 Azure 定价信息,还可以参阅 Azure 支持常见问题解答You also can see the Azure Support FAQs for general Azure pricing information. 有关中继定价的完整信息,请参阅服务总线定价详细信息For complete information about Relay pricing, see Service Bus pricing details.

如何对混合连接和 WCF 中继收费?How do you charge for Hybrid Connections and WCF Relay?

有关中继定价的完整信息,请参阅服务总线定价详细信息页上的混合连接和 WCF 中继表。For complete information about Relay pricing, see the Hybrid Connections and WCF Relays table on the Service Bus pricing details page. 除该页上标示的价格外,还需为在其中部署应用程序的数据中心之外的相关数据输出支付费用。In addition to the prices noted on that page, you are charged for associated data transfers for egress outside of the datacenter in which your application is provisioned.

使用混合连接时怎样计费?How am I billed for Hybrid Connections?

以下是三种示例计费方案,适用于混合连接:Here are three example billing scenarios for Hybrid Connections:

  • 应用场景 1:Scenario 1:
    • 有一个侦听器,例如一个混合连接管理器实例,在安装后已持续运行一整月。You have a single listener, such as an instance of the Hybrid Connections Manager installed and continuously running for the entire month.
    • 在该月通过连接发送了 3 GB 的数据。You send 3 GB of data across the connection during the month.
    • 总费用是 5 美元。Your total charge is $5.
  • 应用场景 2:Scenario 2:
    • 有一个侦听器,例如一个混合连接管理器实例,在安装后已持续运行一整月。You have a single listener, such as an instance of the Hybrid Connections Manager installed and continuously running for the entire month.
    • 在该月通过连接发送了 10 GB 的数据。You send 10 GB of data across the connection during the month.
    • 总费用是 7.50 美元。Your total charge is $7.50. 其中 5 美元是针对连接和第一个 5 GB 的收费,另外 2.50 美元是针对其余 5 GB 数据的收费。That's $5 for the connection and first 5 GB + $2.50 for the additional 5 GB of data.
  • 应用场景 3:Scenario 3:
    • 有两个混合连接管理器实例(A 和 B),在安装后已持续运行一整月。You have two instances, A and B, of the Hybrid Connections Manager installed and continuously running for the entire month.
    • 在该月通过连接 A 发送了 3 GB 的数据。You send 3 GB of data across connection A during the month.
    • 在该月通过连接 B 发送了 6 GB 的数据。You send 6 GB of data across connection B during the month.
    • 总费用是 10.50 美元。Your total charge is $10.50. 其中 5 美元是针对连接 A 的收费,5 美元是针对连接 B 的收费,还有 0.50 美元是针对连接 B 额外的 1 GB 数据的收费。That's $5 for connection A + $5 for connection B + $0.50 (for the sixth gigabyte on connection B).

请注意,示例中所使用的价格仅适用于混合连接预览期。Note that the prices used in the examples are applicable only during the Hybrid Connections preview period. 在公开发布混合连接后,价格可能会变化。Prices are subject to change upon general availability of Hybrid Connections.

如何计算中继小时数?How are hours calculated for Relay?

WCF 中继仅适用于标准层命名空间。WCF Relay is available only in Standard tier namespaces. 其他中继的定价和连接配额保持不变。Pricing and connection quotas for relays otherwise have not changed. 这意味着中继将继续根据消息数(而不是操作数)和中继小时数计费。This means that relays continue to be charged based on the number of messages (not operations) and relay hours. 有关详细信息,请参阅定价详细信息页上的混合连接和 WCF 中继表。For more information, see the "Hybrid Connections and WCF Relays" table on the pricing details page.

如果将多个侦听器连接到特定中继,会怎么样?What if I have more than one listener connected to a specific relay?

在某些情况下,单个中继可能会有多个连接的侦听器。In some cases, a single relay might have multiple connected listeners. 当至少有一个中继侦听器连接到中继时,该中继都就会被视为“打开”状态。A relay is considered open when at least one relay listener is connected to it. 将侦听器添加到打开的中继时,会增加中继小时数。Adding listeners to an open relay results in additional relay hours. 连接到中继的中继发送方(调用消息或将消息发送至中继的客户端)数量不会对中继小时数的计算产生影响。The number of relay senders (clients that invoke or send messages to relays) that are connected to a relay does not affect the calculation of relay hours.

如何计算 WCF 中继的消息数?How is the messages meter calculated for WCF Relays?

这仅适用于 WCF 中继。对于混合连接来说,消息不收费。(This applies only to WCF relays. Messages are not a cost for Hybrid Connections.)

一般情况下,会使用与上述相同的用于中转实体(队列、主题和订阅)的方法来计算中继的可计费消息。In general, billable messages for relays are calculated by using the same method that is used for brokered entities (queues, topics, and subscriptions), described previously. 但是,有一些明显的区别。However, there are some notable differences.

向 Azure 中继发送消息被视为“完全通过”式发送,发送到接收消息的中继侦听器。Sending a message to a Azure Relay is treated as a "full through" send to the relay listener that receives the message. 不会将其视为一个先发送到 Azure 中继然后再传递给中继侦听器的操作。It is not treated as a send operation to the Azure Relay, followed by a delivery to the relay listener. 针对中继侦听器的请求-应答模式服务调用(最大 64 KB)将生成两条可计费消息:一条用于请求的可计费消息,一条用于应答(假设响应也是 64 KB 或更小)的可计费消息。A request-reply style service invocation (of up to 64 KB) against a relay listener results in two billable messages: one billable message for the request and one billable message for the response (assuming the response is also 64 KB or smaller). 这不同于使用队列在客户端和服务之间进行协调。This is different than using a queue to mediate between a client and a service. 如果使用队列在客户端和服务之间进行协调,则同一请求-答复模式要求先将请求发送到队列,然后再将其从队列交付到服务,或者取消其排队。If you use a queue to mediate between a client and a service, the same request-reply pattern requires a request send to the queue, followed by a dequeue/delivery from the queue to the service. 随后就是将响应发送至另一队列,再从该队列交付至客户端,或者取消排队。This is followed by a response send to another queue, and a dequeue/delivery from that queue to the client. 如果始终使用同一大小作为假设吞吐量(最高 64 KB),则此中介型队列模式会生成 4 条计费消息。Using the same size assumptions throughout (up to 64 KB), the mediated queue pattern results in 4 billable messages. 收费的消息数两倍于使用中继实现同一模式时的消息数。You'd be billed for twice the number of messages to implement the same pattern that you accomplish by using relay. 当然,使用队列来实现此模式好处更多,例如持久性和负载分级。Of course, there are benefits to using queues to achieve this pattern, such as durability and load leveling. 这些好处可能产生额外费用。These benefits might justify the additional expense.

使用 netTCPRelay WCF 绑定打开的中继不将消息视为单条消息,而视为流经系统的数据流。Relays that are opened by using the netTCPRelay WCF binding treat messages not as individual messages, but as a stream of data flowing through the system. 使用此绑定时,只有发送方和侦听器可以识别发送和接收的单条分帧消息。When you use this binding, only the sender and listener have visibility into the framing of the individual messages sent and received. 对于使用 netTCPRelay 绑定的中继,所有数据都会被视为用于计算可计费消息的数据流。For relays that use the netTCPRelay binding, all data is treated as a stream for calculating billable messages. 在这种情况下,服务总线每隔 5 分钟计算一次通过单个中继发送或接收的数据总量。In this case, Service Bus calculates the total amount of data sent or received via each individual relay on a 5-minute basis. 然后会将该数据总量除以 64 KB,得出该中继在该时段的计费消息数。Then, it divides that total amount of data by 64 KB to determine the number of billable messages for that relay during that time period.


配额名称Quota name 作用域Scope 注释Notes ValueValue
中继上的并发侦听器数Concurrent listeners on a relay 实体Entity 系统会拒绝后续的附加连接请求,且调用代码会收到异常。Subsequent requests for additional connections are rejected and an exception is received by the calling code. 2525
服务命名空间中所有中继终结点的并发中继连接数Concurrent relay connections per all relay endpoints in a service namespace 命名空间Namespace - 5,0005,000
每个服务命名空间的中继终结点数Relay endpoints per service namespace 命名空间Namespace - 10,00010,000
NetOnewayRelayBindingNetEventRelayBinding 中继的消息大小Message size for NetOnewayRelayBinding and NetEventRelayBinding relays 命名空间Namespace 会拒绝超过这些配额的传入消息,且调用代码会收到异常。Incoming messages that exceed these quotas are rejected and an exception is received by the calling code. 64 KB64 KB
HttpRelayTransportBindingElementNetTcpRelayBinding 中继的消息大小Message size for HttpRelayTransportBindingElement and NetTcpRelayBinding relays 命名空间Namespace 对消息大小没有限制。No limit on message size. 无限制Unlimited

中继是否具有任何使用率配额?Does Relay have any usage quotas?

默认情况下,对于任何云服务,Azure 都会设置一个聚合的每月使用率配额,此配额基于客户的所有订阅进行计算。By default, for any cloud service, Azure sets an aggregate monthly usage quota that is calculated across all of a customer's subscriptions. 我们了解,有时候,你的需求可能会超过这些限制。We understand that at times your needs might exceed these limits. 你可以随时联系客户服务人员,以便我们了解你的需求并相应地调整这些限制。You can contact customer service at any time, so we can understand your needs and adjust these limits appropriately. 对于服务总线,聚合的使用率配额为如下所示:For Service Bus, the aggregate usage quotas are as follows:

  • 50 亿条消息5 billion messages
  • 200 万个中继小时2 million relay hours

虽然我们保留禁用超过单月使用率配额的帐户的权利,但仍然会在采取任何措施前发送电子邮件通知并会多次尝试与客户联系。Although we reserve the right to disable an account that exceeds its monthly usage quotas, we provide e-mail notification, and we make multiple attempts to contact the customer before taking any action. 超过这些配额的客户仍需负责支付超额部分的费用。Customers that exceed these quotas are still responsible for excess charges.

命名限制Naming restrictions

中继命名空间名称的长度必须介于 6 到 50 个字符之间。A Relay namespace name must be between 6 and 50 characters in length.

订阅和命名空间管理Subscription and namespace management

如何将命名空间迁移到另一个 Azure 订阅中?How do I migrate a namespace to another Azure subscription?

可以使用 Azure 门户或 PowerShell 命令,将命名空间从一个 Azure 订阅移到另一个订阅。To move a namespace from one Azure subscription to another subscription, you can either use the Azure portal or use PowerShell commands. 若要将命名空间移到另一个订阅,该命名空间必须处于活动状态。To move a namespace to another subscription, the namespace must already be active. 运行这些命令的用户必须是源订阅和目标订阅的管理员用户。The user running the commands must be an Administrator user on both the source and target subscriptions.

Azure 门户Azure portal

要使用 Azure 门户将 Azure 中继命名空间从一个订阅迁移到另一个订阅,请参阅将资源移到新的资源组或订阅To use the Azure portal to migrate Azure Relay namespaces from one subscription to another subscription, see Move resources to a new resource group or subscription.


若要使用 PowerShell 将命名空间从一个 Azure 订阅移到另一个订阅,请使用以下命令序列。To use PowerShell to move a namespace from one Azure subscription to another subscription, use the following sequence of commands. 若要执行此操作,该命名空间必须已经处于活动状态,并且运行 PowerShell 命令的用户必须同时是源和目标订阅上的管理员用户。To execute this operation, the namespace must already be active, and the user running the PowerShell commands must be an Administrator user on both the source and target subscriptions.

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

# Move the namespace from the source subscription to the 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


Azure 中继 API 所生成的异常有哪些,可以采用哪些建议操作?What are some of the exceptions generated by Azure Relay APIs, and suggested actions you can take?

有关常见异常以及可以采用的建议操作的说明,请参阅中继异常For a description of common exceptions and suggested actions you can take, see Relay exceptions.

什么是共享访问签名?哪些语言可以用来生成签名?What is a shared access signature, and which languages can I use to generate a signature?

共享访问签名 (SAS) 是基于 SHA–256 安全哈希或 URI 的身份验证机制。Shared Access Signatures (SAS) are an authentication mechanism based on SHA-256 secure hashes or URIs. 有关如何在 Node.js、PHP、Python、Java、C 和 C# 中生成自有签名的信息,请参阅使用共享访问签名进行服务总线身份验证For information about how to generate your own signatures in Node.js, PHP, Python, Java, C, and C#, see Service Bus authentication with shared access signatures.

是否可以仅允许某些中继终结点?Is it possible to allow only some relay endpoints?

是的。Yes. 中继客户端使用完全限定的域名连接到 Azure 中继服务。The relay client makes connections to the Azure Relay service by using fully qualified domain names. 客户可以在支持 DNS 允许列表的防火墙上为 * 添加一个条目。Customers can add an entry for * on firewalls that support DNS approval listing.

后续步骤Next steps