c# - 本地计算机上的 Azure 移动服务 Nodejs 推送时出错

标签 c# android azure xamarin xamarin.android

我正在学习 Azure 的移动快速入门教程 (Xamarin.Android),并且能够运行 Facebook 身份验证和推送通知。

现在,我想知道如何拥有本地开发环境或如何让移动应用服务 (Nodejs) 在我的本地计算机上运行(而不是在 Azure 云上)。我遵循了这个教程: https://shellmonger.com/2016/04/01/30-days-of-zumo-v2-azure-mobile-apps-day-2-local-development/

但是,在我打开应用程序后,事情就崩溃了。请参阅下面的屏幕截图: enter image description here

错误:

Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException: Cannot PUT /push/installations/cc69e3d2-5d18-4077-a23a-56a845a73698

一些注释:

- 如果我将其连接到 Azure 云上的远程应用服务,此应用程序将正常工作。

- 是的,我在本地计算机中克隆了应用程序服务器 (nodejs) - 安装了所需的模块,并且正在正常运行(屏幕截图) enter image description here

// This is a base-level Azure Mobile App SDK.
var express = require('express'),
    azureMobileApps = require('azure-mobile-apps');

// Set up a standard Express app
var app = express();

// If you are producing a combined Web + Mobile app, then you should handle
// anything like logging, registering middleware, etc. here

// Configuration of the Azure Mobile Apps can be done via an object, the
// environment or an auxiliary file.  For more information, see
// http://azure.github.io/azure-mobile-apps-node/global.html#configuration
var mobileApp = azureMobileApps({
    // Explicitly enable the Azure Mobile Apps home page
    homePage: true,
    // Explicitly enable swagger support. UI support is enabled by
    // installing the swagger-ui npm module.
    // swagger: true,
    // App will use MS_SqliteFilename or MS_TableConnectionString to choose the SQLite or SQL data provider
    data: {
        dynamicSchema: true
    }
});

// Import the files from the tables directory to configure the /tables endpoint
mobileApp.tables.import('./tables');

// Import the files from the api directory to configure the /api endpoint
mobileApp.api.import('./api');

// Initialize the database before listening for incoming requests
// The tables.initialize() method does the initialization asynchronously
// and returns a Promise.
mobileApp.tables.initialize()
    .then(function () {
        app.use(mobileApp);    // Register the Azure Mobile Apps middleware
        app.listen(process.env.PORT || 3000);   // Listen for requests
    });

- 是的,我将移动应用程序客户端所需的 ApplicationURL 更改为我在本地运行的应用程序 URL(屏幕截图)

enter image description here

...

const string applicationURL = @"http://192.168.1.221:3000";

const string localDbFilename = "newlocalstore.db";

protected override async void OnCreate(Bundle bundle)
{
    base.OnCreate(bundle);

    // Set our view from the "main" layout resource
    SetContentView(Resource.Layout.Activity_To_Do);

    CurrentPlatform.Init();
    ...

- 最后,我的 IP 地址已在 MS SQL Server 的防火墙设置中列入白名单。所以这不应该是一个问题,因为我也能够完全启动我的本地应用程序服务(nodejs)。

你认为是什么原因导致了这个错误?

最佳答案

当您在本地运行时,您必须提供所需的所有连接字符串 - 包括在云中自动为您生成的连接字符串。在这种情况下,您尚未在本地定义通知中心连接字符串。 环境。

转到 Kudu ( https://yoursite.scm.azurewebsites.net ) 并查看连接字符串的环境变量。当你寻找它们时,它们是相当明显的。确保将所有连接字符串定义为相同的环境变量。

关于c# - 本地计算机上的 Azure 移动服务 Nodejs 推送时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39778724/

相关文章:

java - 还有什么方法可以使 Google map 类中的变量不为空呢?

android - 抽屉导航未从自定义菜单按钮打开

android - 在某些设备上,选项菜单不会出现在操作栏中

Azure 广告 B2C 与 Keycloak

azure - Windows Azure 平台如何扩展实例并平衡工作负载?

c# - 委托(delegate)、操作和传递 lambda 表达式作为委托(delegate)参数

c# - 使用属性扩展密封类

c# - 使用健康监控的 ASP.NET Web 应用程序日志记录不起作用

c# - DocumentDB 属性绑定(bind)如何响应节流?

asp.net - Azure 网站 - 将存储 (blob) 和 ftp 附加到该存储