我在 中为移动应用程序设置了一个开发部署槽Azure App Services
,在这个槽中我想使用与主槽中不同Notification Hub
的槽。
一旦我Notification Hub
为开发槽选择了 a - 主槽的推送设置被清除,我无法再选择 a Notification Hu
b。
我已经将连接字符串设置为“插槽设置”并更改了特定Notification Hubs
.
Notification Hubs
不同的部署槽是否可以有不同的?
我不明白为什么不...
首先,您必须记住触发通知的代码是实际使用通知中心名称和通知中心连接字符串的代码。
让我们看一下为应用服务通知中心教程提出的代码。这是从应用服务中的插入发送通知的代码:
// 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);
现在让我们看一下这篇文章中关于如何使用部署槽中的环境变量的片段:
<td>ConnectionString: </td>
<td><%= Environment.GetEnvironmentVariable("SQLAZURECONNSTR_ConnectionString") %></td>
最后按照此处的建议,您可以使用CUSTOMCONNSTR_ 或APPSETTING_来获取通知中心名称和通知中心连接,具体取决于您的部署槽。