azure - 如何修改 Azure 事件中心中的消息保留期?

标签 azure azure-eventhub

在寻找更改事件中心实例保留期的方法(无需删除并重新创建它)时,我发现 Material 非常匮乏。 有引用文献表明这是可能的 - 包括 Microsoft 博客条目,此处:https://techcommunity.microsoft.com/t5/messaging-on-azure-blog/data-retention-in-event-hubs/ba-p/370660 (并跟进 Stack Overflow 中的帖子,但没有实际示例说明如何执行此操作!)

我希望从 1 天增加到 7 天,但在 Azure 门户中似乎无法做到这一点,而且没有文档,我不知道如何做到这一点。 看起来应该是修改ARM模板中的“messageRetentionInDays”项,并以更新模式重新部署(而不是拆卸+重新部署)的情况。 但是,由于没有文档,也没有其他人确认,我不想进行实验。

我错过了任何想法/文档,或者您自己的经验吗?

最佳答案

更新保留期的方法有很多种。 ARM/Bicep 是一个绝佳的选择,否则还有:

Azure CLI

az eventhubs eventhub update --resource-group myresourcegroup --namespace-name mynamespace --name myeventhub --message-retention 3

( doc )

休息 API

例如,您可以利用其余 API 来更新事件中心

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>  

( doc )

Powershell

$loggingEventHub = Get-AzEventHub -ResourceGroupName $ehResourceGroup -Namespace $ehNameSpace -Name $ehName

$loggingEventHub.MessageRetentionInDays = 5

Set-AzEventHub -ResourceGroupName $ehResourceGroup -Namespace $ehNameSpace -Name $ehName -InputObject $loggingEventHub

( doc )

关于azure - 如何修改 Azure 事件中心中的消息保留期?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/75513835/

相关文章:

azure - Remove-AzureRmResource 请求的资源不支持http方法 'DELETE'

azure - Azure 事件中心是否限制主题数量?

azureservicebus - Azure 事件中心 : recommended values for PartitionManagerOptions

architecture - 如何处理事件驱动架构中缺乏无限保留的问题?

azure - 监视 Azure 事件中心

maven - 如何在java azure函数中添加依赖JAR

Azure - ARM 模板部署

azure - 通过 Powershell Runbook 从 ARM 模板部署 Azure VM,无需下载模板

powershell - 使用 Powershell 在 Azure 中创建 VM

azure - 使用 Azure 时序见解资源管理器中的时序表达式语法获取两个日期之间的差异(以秒为单位)