Azure Mobile App Services or Web App Services for Mobile Applications and Web Admin Panel - asp.net

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.
I am planning to host every thing in Azure. I am creating application in Xamarin. Application needs to have Push Notification, Offline Sync etc, features provided by Mobile App Services (Controller inherited from TableController).
I want to create 1 database which will be used by all 3 modules. 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. Is this possible ?
What is the best way? Should i create a web project and perform operations on data via REST API? and use this API for Mobile Apps and Web based Backend?
I am really confused between different services from azure and which one to use. Should i use .Net Core or .Net. I need to know the best way to do it.
Edit 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. Now i have created a .net MVC website and used RestSharp for CRUD operations in it. I have used the following code to perform the operations. Note the /tables/ part in the request url.
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)
Data Store (SQL Database, Azure Table Storage,etc)
Offline Sync
Push Notifications (Client SDKS seamlessly integrate with the registration capabilities of Azure Notification Hubs)
Client SDKs (A complete set of Client SDKs that cover native development, cross-platform development,etc)
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.
Now i want to create a website and Web based admin panel and use the same database. 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.
Should i use .Net Core or .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.
UPDATE:
Can you please take a look at edit 1, and suggest if this is the right way or it can create a problem.
Your code would work fine, since the mobile client SDK just wraps the common processing as your provided.
Note:
For accessing only by authenticated user, you need to add x-zumo-auth header with the authenticationToken after you logged.
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. 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. For SPA, you could use both Client-managed authentication and Server-managed authentication.
Moreover, Adrian hall has wrote some useful tutorials about developing against azure mobile app, you could refer to Adrian hall's book.
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. While for Auth0, you firstly login with Auth0 provider, then pass the token to your mobile app.
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.
Per my understanding, both approaches could implement the custom authentication for you, but you need to choose the better one that matches your scenario.

Related

Protect API for Mobile app behind Authentication

I am building a react native mobile application, and I'm using the expo Google and Apple sign in libraries to provide authentication. Both libraries use firebase to authenticate, but my database is hosted elsewhere (heroku while in development, but probably migrating to digital ocean in the future). How can I protect my API using the access tokens I receive from the Google and Apple sign in utilities on my non-firebase server? All the code samples I've seen use firebase as the backend. I want to make sure that all the API calls are authenticated, and that the proper storing/refreshing techniques are used on the client, while maintaining the "persistent session" UX for users so they don't have to sign in every time they open the application.
I feel like I should know this, and I have a few ideas, but really don't want to get this aspect of the application wrong.

Microsoft.Azure.Mobile.Client.SQLiteStore LoginAsync returns "code":404

I have upgraded my Xamarin.Forms app from Microsoft.WindowsAzure.Mobile.SQLStore to Microsoft.Azure.Mobile.Client.SQLiteStore. My authentication is implemented like this:
public async Task<MobileServiceUser> Authorize(MobileServiceAuthenticationProvider provider, IMobileServiceClient client)
{
return await client.LoginAsync(AppDelegate.MainView.RootViewController, provider);
}
But the authentication dialog displays the following message now:
{"code":404 "error":"Error: Not Found" }
I use Google, Microsoft and Facebook authentication. This authentication worked perfectly fine before I upgraded. I tried to go through this documentation but it is based on some sample project that I cannot recreate. Any ideas why this isn't working anymore?
I use Google, Microsoft and Facebook authentication. This authentication worked perfectly fine before I upgraded.
Per my understanding, your mobile backend is hosted by Azure Mobile Services (with the URL like: service.azure-mobile.net).
Microsoft.Azure.Mobile.Client.SQLiteStore has the dependencies of Microsoft.Azure.Mobile.Client which is used to connect to Azure Mobile Apps. After you upgraded from Microsoft.WindowsAzure.Mobile.SQLStore to Microsoft.Azure.Mobile.Client.SQLiteStore, then Microsoft.Azure.Mobile.Client would be installed automatically.
For MobileServiceClient from Microsoft.Azure.Mobile.Client, the LoginAsync method with the specific provider would send the request as follows:
http(s)://{your-mobile-backend-URL}/.auth/login/{provider-name}
{"code":404 "error":"Error: Not Found" }
In summary, if you want to use Microsoft.Azure.Mobile.Client.SQLiteStore, then your mobile backend need to be hosted by Azure Mobile Apps which you could think of it as Azure Mobile Services V2. Additionally, you could leverage fiddler to collect the network traces when handling login operation for troubleshooting this issue. Also, you could refer to Migrate your existing Azure Mobile Service to Azure App Service.
UPDATE:
I checked the source code about Microsoft.Azure.Mobile.Client and found the LoginAsyncOverride method under MobileServiceTokenAuthentication.cs. You could specify MobileServiceClient.LoginUriPrefix to override the login prefix specified by LoginAsyncUriFragment field configured as /.auth/login from MobileServiceAuthentication.cs.
For mobile service backend and using mobile app client SDK, I assumed that you could leverage the following code:
MobileServiceClient client = new MobileServiceClient("https://{your-app-name}.azure-mobile.net/")
{
LoginUriPrefix = "/login"
};
var user=await client.LoginAsync(MobileServiceAuthenticationProvider.Facebook,false);
Note: I just tested the login operation, you need to check with your mobile client and verify whether the related operations could work as expected. Additionally, I would still recommend that you could try to upgrade your mobile service to azure mobile app for more powerful features. You could refer to Mobile Services vs. App Service for more details.

Adding an asp.net MVC page along with Azure Mobile services

I have backend(e.g. https://api.myapp.com) based on the Azure Mobile services(AMS), now I need
1. add one or two apis that doesn't require to be on AMS e.g. an heartbeat controller to check that service is online or not, that doesn't require Zumo Auth
2. an ASP.net MVC page(e.g. https://www.myapp.com) that explains about the application
Can I use the existing AMS to do this, I tried to add plain asp.net web api, but getting error that end point doesn't exist
Are you truly using Azure Mobile Services and not Azure Mobile Apps? You generally cannot have a custom domain on Azure Mobile Services. Since you mention ZUMO Auth 2, I'm assuming you mean App Service Auth and thus Azure Mobile Apps.
I'd recommend taking a look at Azure Functions for any APIs that do not require ZUMO. However, you can just add a custom API to your service. I cover all the options for you in my book - http://aka.ms/zumobook - chapter 4.
As to a service controller for checking heartbeat. If the intent is to ensure that the service is alive, then just create an unauthenticated custom API that tests the database connectivity (maybe does an SQL command to get the count of rows in your main table) and returns success or failure. You can then use Azure Functions, Azure Scheduler or OMS to do a query of that custom API.

IBM-Bluemix Push migration

I have a Push-Notification service set up that I had to migrate (because IBM is closing the old service).
I used the original app and just opened a new Push-Service.
Now, when I try to test the installation with the REST-API online, it tells me that the app secret isn't valid.
Do I have to open a new app as well? (besides, I can't find the app-secret in the new interface)
What happens to the old mobile apps. Does the service run side by side for a while?
The app-secret value for the new push service is the VCAP credential, not an overall application secret like it was with the old services. The new services are more decoupled and thus only push requires the secret value at this time (added to prevent malicious usage of the REST API) and it is located in a different spot than in the old services.
Here are the steps to grab the app secret from your new push service instance (taken from: https://console.ng.bluemix.net/docs/services/mobilepush/t_restapi.html). Note where it says to click Show Credentials this is in reference to the new push service instance tile on your application dashboard's Connections tab.
With that said I highly recommend migrating completely from your app using the old services (Push, Mobile Data, Mobile Application Security) to a new app using nothing but the new services (Push Notifications, Cloudant NoSQLDB, Mobile Client Access). The services are not intended to work together cross-generation, and should be taken wholesale.

Paypal - Flex : Integrate app-in billing

I'm trying to integrate an app-in billing into a flex mobile application.
I found this page : http://www.adobe.com/devnet/flex/articles/flex_paypal.html
It seems to work but, for security purposes (store Paypal credentials), I had to install a web app on my web server.
I had a look on the libraries (MPL) for android and ios SDKs, they don't seem to call a web server.
Does someone know if there's a way to avoid installing this server?
The linked article is an excellent treatment of integrating PayPal's Adaptive Payments product from the perspective of a Flex/AIR single-page web app. However, this product (Adaptive Payments) would not be recommended for use in a mobile app rather than a browser due to the different security features of apps (with embedded minibrowsers) vs. browser environments.
The MPL libraries have also been deprecated in favor of PayPal's newest mobile SDKs. See:
https://developer.paypal.com/docs/integration/mobile/mobile-sdk-overview/
I would recommend looking into using either these newest PayPal SDKs, or mobile Braintree SDKs that combine PayPal and Braintree card acceptance in a single SDK, as the most secure & having the best mobile user experiences (and the most likely to be supported well into the future).
These SDKs do not require you to have a web server that hosts any pages for user interaction (e.g. a page that redirects a user to PayPal, or one that handles a redirection back). They provide libraries for the secure collection & validation of the user's credentials from inside your app.
That said, you still need to maintain the security of your PayPal API credentials access. The latest SDKs (as referenced above) allow you to generate access tokens for a particular device while keeping your account credentials secure on your server. But you do need that server, and your mobile app will need to communicate with it to become authenticated to make calls to PayPal on your behalf; otherwise your full PayPal API credentials would have to be sent to every device on which your app is installed, which would not be wise.

Resources