你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

更新事件中心

汇报事件中心。 更新事件中心时,只能更改此处列出的属性。 尝试更改任何其他属性都会导致错误。 可以更改但未指定的属性将设置为其默认值。

属性

属性名称 随 API 版本一起提供 默认 属性说明
MessageRetentionInDays 2014-01 0 MessageRetentionInDays

请求

方法 请求 URI
PUT https://{serviceNamespace}.servicebus.windows.net/{eventHubPath}

请求标头

有关所有与事件中心相关的请求使用的标头和参数,请参阅 通用参数和标头

其他请求标头

请求头 必需或可选 说明
If-Match 必需 将此标头设置为“*”以更新事件中心。 必须在更新的事件中心上提供所有所需的属性值;未提供的任何值都设置为服务默认值。 如果缺少此标头,则更新调用将返回一个错误,指示此事件中心已存在。

请求正文

在内容中嵌入了描述的 Atom 条目。 例如:

<entry xmlns='http://www.w3.org/2005/Atom'>  
  <content type='application/xml'>  
    {EventHubDescription}  
  </content>  
</entry>  

响应

响应包括 HTTP 状态代码、一组响应标头和响应正文。

响应代码

代码 说明
200 成功。
400 请求错误。
401 授权失败。
409 由于缺少 If-Match 标头而发生冲突。
500 内部错误。

响应正文

如果请求成功,响应正文将包含事件中心说明。 将会返回从 PUT 请求丢失的属性,具有默认值。 如果请求不成功,则正文包含错误代码和错误消息。

元素名称 说明
AuthorizationRules 授权规则。
MessageRetentionInDays 要为此事件中心保留事件的天数。
Status 事件中心的当前状态 (启用或禁用) 。
CreatedAt 创建事件中心的确切时间。
UpdatedAt 事件中心的确切更新时间。
PartitionCount 事件中心上的当前分区数。
PartitionIds 为事件中心创建的分区的标识符。

示例

请求

备注

还可以将 Azure Active Directory 令牌用于 授权 标头,如 通用参数和标头中所述。 例如:Authorization: Bearer <Azure AD token>

PUT https://your-namespace.servicebus.windows.net/your-event-hub?timeout=60&api-version=2014-01 HTTP/1.1  
Authorization: SharedAccessSignature sr=your-namespace.servicebus.windows.net&sig=tYu8qdH563Pc96Lky0SFs5PhbGnljF7mLYQwCZmk9M0%3d&se=1403736877&skn=RootManageSharedAccessKey  
Content-Type: application/atom+xml;type=entry;charset=utf-8  
Host: your-namespace.servicebus.windows.net
If-Match: *
Content-Length: 264  
Expect: 100-continue  
Connection: Keep-Alive  
  
<entry xmlns='http://www.w3.org/2005/Atom'>  
  <content type='application/xml'>  
    <EventHubDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">  
      <MessageRetentionInDays>3</MessageRetentionInDays>  
    </EventHubDescription>  
  </content>  
</entry>  

响应

HTTP/1.1 201 Created  
Transfer-Encoding: chunked  
Content-Type: application/atom+xml;type=entry;charset=utf-8  
Server: Microsoft-HTTPAPI/2.0  
Date: Wed, 25 Jun 2014 22:43:27 GMT  
  
<entry xmlns="http://www.w3.org/2005/Atom">  
  <id>https://your-namespace.servicebus.windows.net/your-event-hub?timeout=60&api-version=2014-01</id>  
  <title type="text">your-event-hub</title>  
  <published>2014-06-25T22:43:16Z</published>  
  <updated>2014-06-25T22:43:27Z</updated>  
  <author>  
     <name>your-namespace</name>  
  </author>  
  <link rel="self" href="https://your-namespace.servicebus.windows.net/your-event-hub?timeout=60&api-version=2014-01"/>  
  <content type="application/xml">  
    <EventHubDescription xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">  
        <MessageRetentionInDays>3</MessageRetentionInDays>  
    </EventHubDescription>  
  </content>  
</entry>