I've been working with Azure Notification Hubs for awhile. However, I created a new Notification Hub for a new project and I've noticed some very odd behavior. Whenever I create a registration its ExpirationDate
is set to 12/31/9999 7:59:59
.
So, for some, I suppose this may be a benefit, but I'd like to expire mine after a certain period of inactivity. I looked through the RegistrationDescription object and found an ExpirationTime but it's read only...
How do I set this? Is this just a bug in Azure? Maybe a flag I'm missing from Azure configuration?
You can do that, but on hub level, not on registration level. Check out Improved Per Message Telemetry and device expiry for Notification Hubs blog post:
To take advantage of this expiry change, simply update your notification hub’s Time To Live property. This can be done through REST or our .NET SDK:
var namespaceManager = NamespaceManager.CreateFromConnectionString("connectionstring"); NotificationHubDescription hub = namespaceManager.GetNotificationHub("foo"); hub.RegistrationTtl = TimeSpan.MaxValue; namespaceManager.UpdateNotificationHub(hub);
To do that via the REST API, check out Update Notification Hub method, which takes NotificationHubDescription body, which has a RegistrationTtl
node in it. That should be a REST equivalent of the SDK code snippet above.