nor0x
nor0x

Reputation: 1213

Azure App Services different Notifications Hubs in Deployment Slots

I set up a development deployment slot for a mobile app in Azure App Services, in this slot I want to use a different Notification Hub as in the main slot.

Once I select a Notification Hub for the development slot - the push settings for the main slot are cleared and I cannot select a Notification Hub anymore.

I already set the Connection strings as "Slot Settings" and changed the URLs for the specific Notification Hubs. enter image description here

Is it possible to have different Notification Hubs for different deployment slots?

Upvotes: 0

Views: 189

Answers (1)

Bruno Medina
Bruno Medina

Reputation: 681

I don't see why not...

First, you have to remember that the code that triggers the notification is the one that actually uses the Notification Hub Name and the Notification Hub Connection string.

Let's take a look at the code proposed for the Notification Hub Tutorial on App Services. This is the code that sends a notification from an insert in the App Service:

// Get the Notification Hubs credentials for the Mobile App.
string notificationHubName = settings.NotificationHubName;
string notificationHubConnection = settings.Connections[MobileAppSettingsKeys.NotificationHubConnectionString].ConnectionString;

// Create a new Notification Hub client.
NotificationHubClient hub = NotificationHubClient
.CreateClientFromConnectionString(notificationHubConnection, notificationHubName);

And now please lets take a look at this snippet taken from this post on how to use environment variable from the deployment slots:

<td>ConnectionString: </td>  
<td><%= Environment.GetEnvironmentVariable("SQLAZURECONNSTR_ConnectionString") %></td> 

Finally as suggested here, then you could use either CUSTOMCONNSTR_ or APPSETTING_ to obtain the Notification Hub name and the notification hub connection that depends on your deployment slot.

Upvotes: 1

Related Questions