Search code examples
azureazure-notificationhub

Azure Notifcation Hub CreateOrUpdateInstallationAsync not failing but Installation not being created


I have an ASP.NET Web Api that is registering Android and iOS installations in our Azure Notification Hub. It creates a HubClient using a connection string

this.azureHub = NotificationHubClient.CreateClientFromConnectionString(
    "Endpoint=sb://OUR-HUB-NS.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedAccessKey=tK/SEXXXXXXXXXXX/7LUtvRoNt+HjToFmP+T++yW5g=",
    "OUR-HUB");

We then create an installation using this code

try
{
    await azureHub.CreateOrUpdateInstallationAsync(installation, token);
}
catch(Exception e)
{
    this.logger.LogError(e, "CreateOrUpdateInstallationAsync failed with" + e.Message);
    return false;
}

return true;

When I had the NoticationHubClient incorrectly configured I was getting 401 errors and if I pass in nonsense for the installation data I will get a 400. Currently the call does not throw an error so I asm going to assume what I am passing is correct and it can successfully connect to the hub. However registrations are not being created. If i try and get the installation after it is created with

GetInstallationAsync(installation.InstallationId)

I get an error saying the installation cannot be found and if I try and get all registrations i get an empty list

var registrations = await azureHub.GetAllRegistrationsAsync(0);

Further confirmation that my installations are not being created is that if I use the "Test Send" in Azure Portal I get "Message was successfully sent, but there were no matching targets." for either Apple or Android platform

What is happening to my registration?


Solution

  • I recreated the Notification Hub with a different name, in the same namespace and everything just started working.

    I then recreated the non-working hub in Azure Portal and it now all works.

    All I can say is that I had previously deleted the hub using the OSS Service Bus Explorer and perhaps that deleted the hub in a way that Azure didn't like.

    Not the answer I was expecting.