Azure App Services部署槽中的不同通知中心

时间:2016-02-16 13:24:28

标签: azure azure-mobile-services azure-notificationhub azure-app-service-plans

我在Azure App Services中为移动应用设置了一个开发部署广告位,在此广告位中我想使用与主广告位中不同的Notification Hub

为开发槽选择Notification Hub后,主插槽的推送设置已清除,我无法再选择Notification Hu b。

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

是否可以为不同的部署位置使用不同的Notification Hubs

1 个答案:

答案 0 :(得分:1)

我不知道为什么不......

首先,您必须记住触发通知的代码实际上是使用通知中心名称和通知中心连接字符串的代码。

让我们看一下Notification Hub Tutorial on App Services的建议代码。这是从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);

现在请让我们看一下从post获取的关于如何使用部署插槽中的环境变量的代码片段:

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

最后根据建议here,您可以使用 CUSTOMCONNSTR _ APPSETTING _ 来获取通知中心名称和取决于您的部署的通知中心连接槽。

相关问题