简体   繁体   English

Web应用程序和移动应用程序与Azure中的相同数据库

[英]Web App and Mobile App with same database in Azure

My aim is to develop a web app and a mobile app that share data from the same database. 我的目标是开发一个Web应用程序和一个共享来自同一数据库的数据的移动应用程序。 What is the best way to achieve this (using azure)? 实现这一目标的最佳方法是什么(使用azure)?

I think I should: 我想我应该:

  • Create a Web App from Azure Portal with a SQL Database 使用SQL数据库从Azure门户创建Web应用程序
  • Create a Mobile App from Azure Portal with an existing Database (the one I created before) 使用现有数据库(我之前创建的数据库)从Azure门户创建移动应用程序

Then I'll develop my ASP.net MVC project, using Entity Framework to create the db Schema and I'll publish it in Azure. 然后我将开发我的ASP.net MVC项目,使用Entity Framework创建db Schema,我将在Azure中发布它。 Finally I'll develope my mobile app (in this case I would like to use Xamarin) and I'll access to the database (created before) using the code for Easy Tables. 最后,我将开发我的移动应用程序(在这种情况下,我想使用Xamarin),然后我将使用Easy Tables的代码访问数据库(之前创建)。

Is it right? 这样对吗? Or I'm thinking wrong and this isn't the best architecture to share the same database between a web app and a mobile app using Azure? 或者我认为错了,这不是使用Azure在Web应用程序和移动应用程序之间共享相同数据库的最佳架构?

This should be fine. 这应该没问题。 Keep in mind that the Azure Mobile Apps server will automatically add some system columns to your database tables (createdAt, updatedAt, deleted and version). 请记住,Azure Mobile Apps服务器会自动将一些系统列添加到数据库表(createdAt,updatedAt,deleted和version)。 Also, a limitation of Mobile Apps is that the primary key name must be called id . 此外,移动应用程序的限制是主键名称必须被称为id

如果您想开发网站和移动应用程序共享同一个数据库,那么这是一个不错的选择。

Azure Mobile Apps is a plain old ASP.NET application or Node.js application. Azure移动应用程序是一个简单的旧ASP.NET应用程序或Node.js应用程序。 Easy Tables is simply a projection of data from the Node.js version. Easy Tables只是Node.js版本数据的投影。 If you are using ASP.NET, then you don't get Easy Tables. 如果您使用的是ASP.NET,那么您就不会获得Easy Tables。

That being said, it is relatively easy to add Azure Mobile Apps SDK to an EXISTING web app. 话虽如此,将Azure Mobile Apps SDK添加到现有的Web应用程序相对容易。

1) Copy the code from App_Start\\Startup.MobileApp.cs and Startup.cs from a sample app to your ASP.NET app 1)将App_Start\\Startup.MobileApp.csStartup.cs的代码从示例应用程序复制到ASP.NET应用程序

2) Ensure all your models inherit from EntityData so that they are "mobile ready". 2)确保所有模型都从EntityData继承,以便它们“移动就绪”。 If your models already have an auto-incrementing Id column, then see https://shellmonger.com/2016/05/11/30-days-of-zumo-v2-azure-mobile-apps-day-19-asp-net-table-controllers/ for a workaround 如果您的模型已有自动递增Id列,请参阅https://shellmonger.com/2016/05/11/30-days-of-zumo-v2-azure-mobile-apps-day-19-asp- net-table-controllers /用于解决方法

3) Scaffold Azure Mobile Apps Table Controllers for your mobile database table projections. 3)用于移动数据库表投影的脚手架Azure移动应用程序表控制器。

You can use the same models across both MVC controllers and Mobile controllers. 您可以在MVC控制器和移动控制器上使用相同的模型。 If your app uses AJAX calls for getting data, you can replace those AJAX calls with the JavaScript SDK for Azure Mobile Apps so you don't have to duplicate things. 如果您的应用程序使用AJAX调用来获取数据,则可以使用适用于Azure移动应用程序的JavaScript SDK替换这些AJAX调用,这样您就不必复制内容。

The main place you are going to have to work on is integration of auth. 您将要处理的主要地方是auth的集成。 Most MVC applications use an Identity database because they have grown it from one of the existing MVC templates. 大多数MVC应用程序使用Identity数据库,因为它们是从一个现有的MVC模板中扩展出来的。 You are going to need to implement a custom mobile auth mechanism to re-use the database. 您将需要实现自定义移动身份验证机制来重用数据库。 You can find information about this on the azure.com HOWTO documentation. 您可以在azure.com HOWTO文档中找到相关信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Azure API应用程序与移动应用程序对Web应用程序 - Azure API App vs Mobile App vs Web App 适用于移动应用程序和Web管理员面板的Azure移动应用程序服务或Web应用程序服务 - Azure Mobile App Services or Web App Services for Mobile Applications and Web Admin Panel Azure-将.NET Web应用程序与Azure SQL数据库连接 - Azure - Connecting .NET web app with azure sql database 将Azure移动应用程序服务与现有SQL数据库一起使用 - Using Azure Mobile App service with existing SQL database 更新Azure移动应用Asp.Net后端数据库 - Update Azure mobile app Asp.Net backend database 验证Azure移动应用程序中的用户是否退出用户数据库 - Validating user in Azure Mobile App Against Exiting User Database 在Azure中部署ASP.NET MVC Web应用程序的数据库问题 - Database issues with deploying ASP.NET MVC web app in Azure Azure 移动应用后端/Azure AD B2C 和 aspnet 核心 Web 客户端 - Azure mobile app backend / Azure AD B2C and aspnet core web client 通过Azure移动应用程序(SQL-SSMS或EntityFramework)管理Azure SQL数据库? - Managing Azure SQL database from Azure Mobile App ( SQL-SSMS or EntityFramework)? 适用于移动和台式PC的Web应用 - Web app for mobile and desktop PC
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM