0

我为Azure App Services中的移动应用程序设置了开发部署插槽,在此插槽中,我想使用与主插槽中不同的Notification HubAzure应用服务部署插槽中的不同通知集线器

一旦我为开发槽选择Notification Hub - 主槽的推送设置被清除,我不能再选择Notification Hu b。

我已经将连接字符串设置为“插槽设置”并更改了特定Notification Hubs的URL。 enter image description here

对于不同的部署槽是否可以有不同的Notification Hubs

回答

1

我不明白为什么不......

首先,你要记住,触发该通知的代码是实际使用的通知中心的名称和通知集线器连接字符串中的一个。

让我们来看看为Notification Hub Tutorial on App Services提出的代码。这是从应用服务的插件发送通知的代码:

// 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); 

现在,请让我们来看看这个段从这个post如何使用环境变量从部署插槽采取:

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

最后的建议here,那么你可以使用任何CUSTOMCONNSTR_APPSETTING_以获得通知中心名称和通知集线器连接的是DEP结束于您的部署插槽。