Web App and Mobile App with same database in Azure - asp.net

My aim is to develop a web app and a mobile app that share data from the same database.
What is the best way to achieve this (using azure)?
I think I should:
Create a Web App from Azure Portal with a SQL Database
Create a Mobile App from Azure Portal with an existing Database (the one I created before)
Then I'll develop my ASP.net MVC project, using Entity Framework to create the db Schema and I'll publish it in 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.
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?

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). Also, a limitation of Mobile Apps is that the primary key name must be called id.

If you want to develop the web site and mobile app share the same database, it is a good choice.

Azure Mobile Apps is a plain old ASP.NET application or Node.js application. Easy Tables is simply a projection of data from the Node.js version. If you are using ASP.NET, then you don't get Easy Tables.
That being said, it is relatively easy to add Azure Mobile Apps SDK to an EXISTING web app.
1) Copy the code from App_Start\Startup.MobileApp.cs and Startup.cs from a sample app to your ASP.NET app
2) Ensure all your models inherit from EntityData so that they are "mobile ready". 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
3) Scaffold Azure Mobile Apps Table Controllers for your mobile database table projections.
You can use the same models across both MVC controllers and Mobile controllers. 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.
The main place you are going to have to work on is integration of auth. Most MVC applications use an Identity database because they have grown it from one of the existing MVC templates. 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.

Related

Visibility of data with web api and xamarin.forms

I am creating small project in xamarin.form (to learn xamarin and mvvm pattern ), where my mobile application will be connect to SQL Server database. On every forum people suggest to use Web Api to get json's from database and next in xamarin application i go under link where is json, parse it and its done. I did an test project which is doing that and it works very well. Unfortunatelly after few days I realized that all data is visible.. If I enter under url/api/subject I get this data in json.
My question is. Should I connect from my xamarin application directly to SQL Database OR is there any way to not showing json's in browser?
To function correctly, many mobile applications are dependent on the cloud, and so integrating web services into mobile applications is a common scenario. The Xamarin platform supports consuming different web service technologies, and includes in-built and third-party support for consuming RESTful, ASMX, and Windows Communication Foundation (WCF) services.
This article discusses this topics.
For customers using Xamarin.Forms, there are complete examples using each of these technologies in the Xamarin.Forms Web Services documentation.
I recommend you learn more about REST architecture

Xamarin Forms with Azure web app and Azure SQL backend

I am evaluating Xamarin and I am hoping to clarify that I am on the correct path.
We would like to create a Xamarin forms app with offline sync. We are using azure to host the backend database. I have created an Azure web app that uses as Azure SQL database.
I have seen example using easy tables, which seems to create the API’s for you but I cannot find any examples where an Azure SQL database is used.
I have gone to the quick start blade of my azure web app, selected Xamarin.Forms, then chose the backend language of C# and downloaded the project. The project included the TodoItems table as an example. Am I correct in thinking that I need to replace this code with the model of the tables I have in my azure SQL database? And then add the changes back to the web app to expose the tables so that the xamarin forms app can use?
Or am I completely on the wrong track? Should I be using swagger (which I have no experience with) to create the API?
Thanks.
From How to: Define a table controller, you could find that Data Transfer Object (DTO) class that is used to define the table within the SQL database need to inherit from EntityData class. And deriving it from EntityData class is aimed at making it support the system properties. It seems that you have created some tables in your Azure SQL database, if you’d like to expose these existing SQL database tables that does not contain these system properties, please refer to “Using an existing SQL Table” in chapter 3.

Xamarin.Forms app SQL-server database options

I've been studying Xamarin.Forms with goal of building cross-platform mobile app in VisualStudio2015. I've got a perfectly acceptable public facing web site but native app(s) are what the boss thinks we need.
The current web app hosted on IIS 7.5 uses a separate project(DLL) for database access to an on-premises SQL Server 2008 instance. This VStudio project exposes domain objects to the calling ASP.NET webforms by executing various stored procedures using System.Data.SqlClient.
I know building the mobile native app itself with Xamarin.Forms is one part of the challenge but I am asking here for clarification about how to approach the database requirements:
Do I need to create some sort of web service that provides the same CRUD functions required by my current web site?
Xamarin documentation lists several options for consuming web services and the more I search and read about data access I conclude that a callable web service of some type is going to be required for my eventual native mobile app.
Is this assumption correct?
Yes. You generally want a webservice layer brokering requests between your mobile app (or any remote client) and your DB server. If you already have all your crud operations in a separate library that is utilized by your website, then a webservice would just be another set of endpoints that rely on the same CRUD library.

starting on a new project(C# /ASP.NET) , need some guidelines on the framework and infra for the same

so i am going to start on a website which is going to have
Main Website
Mobile Version
Android App
iPhone App
WP7 App
going to start on the website first using .Net Framework 4 , for database will be using the EF4. The website is expected to create lots of traffic.
i want to take advice on how to approach the development , currently evaluating following 2 options
1) Main Website and Mobile website versions talk directly to database and the mobile apps are built upon WCF / Odata .
2nd Option
First build up the WCF /OData webservices and then develop all Main Website / Mobile Website and apps using the data services ( will this make the website slow , assuming all will Database on one box and website + services on the other box)
please pour in your views on both options.
Thanks
I would choose the second option. Have a look at
Web Service Software Factory that will help you build web services correctly, and develop good practices.
ASP.NET MVC i recommend to use it for building web site, and your web services will serve as Model for site.
I would also put wcf services on the same server as database.
Regards, Sergiu.

What is the best architecture for building a .NET website that may also support a native mobile app in the future?

I am in the planning phases of building a new ASP.NET website. The website is really a transactional web application where the users will log in and perform basic CRUD data operations. For right now this website will be accessible through a traditional desktop browser and a mobile browser. For the mobile browser we will build a separate scaled down version of the site.
In the future we may decide to create native mobile applications for Android or iOS devices also.
So the question I have is what is the best way to design the system to easily support that? Here is what I am thinking. I am thinking of building out 3 tiers to the site. The back end will be the database - SQL Server 2008. We will use stored procedures for all data access. The middle tier will be a web services tier. This tier will be built using RESTful web services and will contain all of the business logic. These web services will provide access to the database. The front end will be built using ASP.NET. The front end will only contain presentation logic. These tiers will actually be deployed on physically separate servers.
Then I am thinking that when we decide to build a native Android or iOS app that we could build those apps to simply call the same RESTful web services that the main site is calling.
Does this seem like a reasonable approach? The only thing I can think of is that the way we are building it right now the web services would be behind the firewall and would not be accessible to the outside world. When we want to support a native mobile app then we would need to make the web services accessible to the outside world.
Any thoughts? Does this seem like a good approach for building a high availability, high usage web app that needs to support native mobile apps in the future?
Thanks,
Corey
I'm with Rober Harvey there. With ASP.NET MVC you can make the presentation site in no time, use as Models your web service; with the link that he gave you, set the site for mobile browsing, and use the web services for the mobile apps when you build them.
For me it looks like a good plan. Regarding the web services being public, you can protect yourself by implementing API keys in the web service, so only your apps can use it.

Resources