我正在学习 Azure 的移动快速入门教程 (Xamarin.Android),并且能够运行 Facebook 身份验证和推送通知。
现在,我想知道如何拥有本地开发环境或如何让移动应用服务 (Nodejs) 在我的本地计算机上运行(而不是在 Azure 云上)。我遵循了这个教程: https://shellmonger.com/2016/04/01/30-days-of-zumo-v2-azure-mobile-apps-day-2-local-development/
但是,在我打开应用程序后,事情就崩溃了。请参阅下面的屏幕截图:
错误:
Microsoft.WindowsAzure.MobileServices.MobileServiceInvalidOperationException: Cannot PUT /push/installations/cc69e3d2-5d18-4077-a23a-56a845a73698
一些注释:
- 如果我将其连接到 Azure 云上的远程应用服务,此应用程序将正常工作。
- 是的,我在本地计算机中克隆了应用程序服务器 (nodejs) - 安装了所需的模块,并且正在正常运行(屏幕截图)
// 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(屏幕截图)
...
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/