移动服务配置:MS_NotificationHubConnectionString 包含无效设置密钥 "entitypath"

Mobile Service Configuration: MS_NotificationHubConnectionString Contains Invalid Setting Key "entitypath"

我正在尝试创建新的 Azure 移动服务,但是在尝试调用自定义 API 时,它会在服务日志中生成以下错误。

An error occurred creating push for user scripts: azure.notificationHubService could not be created. HubName: "servicenamehub" ConnectionString "Endpoint=sb://servicenamehub-ns.servicebus.windows.net/; SharedAccessKeyName=DefaultFullSharedAccessSignature; SharedAccessKey={accesskey};EntityPath=servicenamehub": Error from create-Error: Invalid connection string setting key "entitypath".

错误似乎只在调用 API 时产生,而不是在调用 table 时产生。

MS_NotificationHubConnectionString 是存储此连接字符串的位置,但它是与服务中心一起自动生成的,不是服务配置中的 editable。

EntityPath 密钥没有出现在我的任何旧服务的 MS_NotificationHubConnectionString 中。移动服务有一个 JavaScript 后端。

如何防止此错误或从连接字符串中删除 EntityPath 键?

目前,这里有一个解决方法:我们登录移动服务后端的 Kudu 控制台站点,修改脚本中的 MS_NotificationHubConnectionString,这将直接在源代码中创建通知中心服务。

  1. 登录 Kudu 控制台站点,其 url 应为 https://<your_mobile_service_name>.scm.azure-mobile.net/DebugConsole
  2. 在页面的文件系统列表中,进入路径D:\home\site\wwwroot\node_modules\azure-mobile-services\runtime\push,编辑文件pushadapter.js
  3. 将以下代码添加到此脚本第 22 行附近函数 PushAdapter 的开头:

    var string = options.MS_NotificationHubConnectionString; var index = string.indexOf('EntityPath'); options.MS_NotificationHubConnectionString = index>0?string.slice(0,string.indexOf('EntityPath')-1):string;

如有任何疑问,请随时告诉我。