Search code examples
azureazure-notificationhub

How to update the Registration Time To Live for an Azure Notification Hub?


I have a Notification Hub in Azure. After creation the Registration TTL is set to forever. I would like to limit it to 90 days.

I have tried to update the Registration TTL on Azure Portal, Azure CLI and via the C# SDK: NotificationHubCreateOrUpdateParameters() to update the RegistrationTtl without success. It seems to me that this was working few years ago but not now.


Solution

  • I will answer my own question because I have found a way to update the RegistrationTtl:

    var namespaceManager = NamespaceManager.CreateFromConnectionString("connectionstring");
    NotificationHubDescription hub = namespaceManager.GetNotificationHub("foo");
    hub.RegistrationTtl = TimeSpan.MaxValue;
    namespaceManager.UpdateNotificationHub(hub);
    

    https://azure.microsoft.com/en-us/blog/push-notification-hub-telemetry-expiry-update/