简体   繁体   English

适用于移动应用程序和Web管理员面板的Azure移动应用程序服务或Web应用程序服务

[英]Azure Mobile App Services or Web App Services for Mobile Applications and Web Admin Panel

I need advice as i am new in .net and azure, i am creating a architecture for a project which has its mobile application, web based admin panel and Website. 我需要一些建议,因为我是.net和Azure的新手,我正在为一个具有移动应用程序,基于Web的管理面板和网站的项目创建体系结构。

I am planning to host every thing in Azure. 我计划在Azure中托管所有内容。 I am creating application in Xamarin. 我正在Xamarin中创建应用程序。 Application needs to have Push Notification, Offline Sync etc, features provided by Mobile App Services (Controller inherited from TableController). 应用程序需要具有推送通知,脱机同步等功能,这些功能由移动应用程序服务(继承自TableController的控制器)提供。

I want to create 1 database which will be used by all 3 modules. 我想创建1个数据库,供所有3个模块使用。 I have already created a Mobile App Service and Database. 我已经创建了一个移动应用服务和数据库。 Mobile application is using it as it was supposed to. 移动应用程序正在按预期使用它。 Now i want to create a website and Web based admin panel and use the same database. 现在,我想创建一个网站和基于Web的管理面板,并使用相同的数据库。 Is this possible ? 这可能吗 ?

What is the best way? 什么是最好的方法? Should i create a web project and perform operations on data via REST API? 我应该创建一个Web项目并通过REST API对数据执行操作吗? and use this API for Mobile Apps and Web based Backend? 并将此API用于移动应用程序和基于Web的后端?

I am really confused between different services from azure and which one to use. 我真的很困惑,天蓝色的不同服务和使用哪一项。 Should i use .Net Core or .Net. 我应该使用.Net Core还是.Net。 I need to know the best way to do it. 我需要知道最好的方法。

Edit 1 : 编辑1:

So far this is what i have done and i need to know if this will work fine in future when project get complex. 到目前为止,这是我所做的,我需要知道当项目变得复杂时,将来是否可以正常使用。 I created database and back end via Azure Mobile App. 我创建数据库并通过Azure移动应用程序后端。 Now i have created a .net MVC website and used RestSharp for CRUD operations in it. 现在,我已经创建了一个.net MVC网站,并将RestSharp用于其中的CRUD操作。 I have used the following code to perform the operations. 我已使用以下代码执行操作。 Note the /tables/ part in the request url. 请注意请求网址中的/ tables /部分。

        var client = new RestClient("http://xxxxxxx.azurewebsites.net");
        var request = new RestRequest("/tables/request?ZUMO-API-VERSION=2.0.0", Method.POST);

        string data = "{\"createdFor\":\"535862cf-e2b3-41de-99f9-88c47a77750c\",\"status\":\"IN_PROCESS\",\"createdBy\":\"7108147e-c11c-4d78-ac3d-d5d6c5eb78d0\",\"description\":\"Master room 5 door produces strange sound when opened or closed\",\"title\":\"Door Sounds Strange\"}";
        request.AddHeader("Accept", "application/json");
        request.Parameters.Clear();
        request.AddParameter("application/json", data, ParameterType.RequestBody);

        var result = client.Execute(request);
        Console.WriteLine("Content " + result.Content);

Get and post operations works fine. 获取和发布操作效果很好。 Is this a good way? 这是个好方法吗?

Thanks in advance 提前致谢

As the official document mentions about Mobile App Features : 正如官方文档中提到的有关移动应用功能

  • Authentication and Authorization ( AAD,Facebook, Google, Twitter and Microsoft Account,Custom authentication ) 身份验证和授权AAD,Facebook, Google, Twitter and Microsoft Account,Custom authentication
  • Data Store (SQL Database, Azure Table Storage,etc) 数据存储 (SQL数据库,Azure表存储等)
  • Offline Sync 离线同步
  • Push Notifications (Client SDKS seamlessly integrate with the registration capabilities of Azure Notification Hubs) 推送通知 (客户端SDKS与Azure通知中心的注册功能无缝集成)
  • Client SDKs (A complete set of Client SDKs that cover native development, cross-platform development,etc) 客户端SDK (涵盖本地开发,跨平台开发等的一整套客户端SDK)

Per my understanding, if the build-in features provided by mobile app could totally meet your requirement, then Mobile App is better for you and it would save your time. 据我了解,如果移动应用程序提供的内置功能完全可以满足您的要求,那么移动应用程序将更适合您,并且可以节省您的时间。 For Web API application, you need to do all stuff by yourself. 对于Web API应用程序,您需要自己做所有事情。

Now i want to create a website and Web based admin panel and use the same database. 现在,我想创建一个网站和基于Web的管理面板,并使用相同的数据库。 Is this possible ? 这可能吗 ?

I assumed that you could create a Azure Mobile App application (Mobile App) and a web application (Azure Web App) under your solution, and you could extract the DbContext related classes into a shared class library. 我假定您可以在解决方案下创建一个Azure移动应用程序应用程序(Mobile App)和一个Web应用程序(Azure Web App),并且可以将与DbContext相关的类提取到共享类库中。

Should i use .Net Core or .Net. 我应该使用.Net Core还是.Net。 I need to know the best way to do it. 我需要知道最好的方法。

For choosing between .NET Core and .NET Framework, you could refer to the official document about choosing-core-framework-server . 有关在.NET Core和.NET Framework之间进行选择的信息,请参考有关choice-core-framework-server的官方文档。

UPDATE: 更新:

Can you please take a look at edit 1, and suggest if this is the right way or it can create a problem. 您能否看一下编辑1,并建议这是正确的方法还是会造成问题。

Your code would work fine, since the mobile client SDK just wraps the common processing as your provided. 您的代码可以正常工作,因为移动客户端SDK只会包装您提供的通用处理程序。

Note: 注意:

For accessing only by authenticated user, you need to add x-zumo-auth header with the authenticationToken after you logged. 要仅由经过身份验证的用户访问,需要在登录后添加带有authenticationToken x-zumo-auth标头。

Additionally, for your MVC application to retrieve the data from your mobile app (need authentication), you need to log with your mobile app and retrieve the authenticationToken for your subsequent requests against your mobile app. 此外,为了使MVC应用程序能够从移动应用程序中检索数据(需要身份验证),您需要登录移动应用程序并检索authenticationToken以用于针对移动应用程序的后续请求。 At this point, except for Custom authentication , otherwise you could only leverage Client-managed authentication and use JavaScript client library for Azure Mobile Apps in your MVC application for logging to mobile app and retrieve the authenticationToken , then you could send request from your front-end or pass the token to your back-end. 此时,除了自定义身份验证外 ,否则您只能利用客户端管理的身份验证,并在MVC应用程序为Azure移动应用程序使用JavaScript客户端库登录到移动应用程序并检索authenticationToken ,然后您可以从前端发送请求结束或将令牌传递到您的后端。 For SPA, you could use both Client-managed authentication and Server-managed authentication . 对于SPA,可以同时使用客户端管理的身份验证服务器管理的身份验证

Moreover, Adrian hall has wrote some useful tutorials about developing against azure mobile app, you could refer to Adrian hall's book . 此外,阿德里安·霍尔(Adrian Hall)写了一些有关针对azure移动应用程序进行开发的有用教程,您可以参考阿德里安·霍尔的书

UPDATE2: UPDATE2:

For custom authentication using an Identity Database , you just pass the username and password to your mobile app, then it would validate the user info and generate the authenticationToken . 对于使用身份数据库的自定义身份验证,只需将用户名和密码传递给您的移动应用程序,然后它将验证用户信息并生成authenticationToken While for Auth0, you firstly login with Auth0 provider, then pass the token to your mobile app. 对于Auth0,您首先要使用Auth0提供程序登录,然后将令牌传递给您的移动应用。

My mobile application has its own signing up and sign in option with username and password. 我的移动应用程序具有自己的使用用户名和密码的注册和登录选项。

For the connection Username-Password-Authentication from Auth0, it would manage the users for you, while using an Identity Database, the users would be stored in your storage and you need to manage them by yourself. 对于Auth0中的Username-Password-Authentication连接,它将为您管理用户,而使用Identity Database时,用户将存储在您的存储中,并且您需要自己进行管理。

Per my understanding, both approaches could implement the custom authentication for you, but you need to choose the better one that matches your scenario. 据我了解,这两种方法都可以为您实现自定义身份验证,但是您需要选择与您的方案相匹配的更好的身份验证。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM