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結束於您的部署插槽。