Skip to main content

Windows Azure Mobile Services supports Android

I have a great news for people that develop application for mobile devices. Windows Azure Mobile Services officially support Android. Until now we had support for Windows 8, Windows Phone 8 and iOS.
From this perspective, in this moment Windows Azure Mobile Services support the most commons operating systems for mobile devices. You can use the same Mobile Service endpoint for different clients. This means that you can have only one Mobile Service that can be used by a Windows Phone 8, a iOS, Windows 8 and Android application in the same time.
If is your first time when you hear about Mobile Services you should know that is a service that provide support to create the backend of your application. Storage, tables, authentications, custom scripts, batch operation and many more are supported by default. This means that you can focus on your client application without worrying about the backend. Everting is exposed as a REST API and can be accessed directly using REST API of using client SDK (Windows 8, Windows Phone 8, iOS and Android).
When you create a new mobile service, you will be able to download a project that is already setup for your client. Depending on your client (Windows 8, Windows Phone 8, iOS or Android) different project can be downloaded. Because of this you can start using and integrate the Mobile Services without losing time on setup.
One thing that I really enjoy on Mobile Services is the SDK support for different environments. Even if Mobile Services endpoints can be accessed using REST calls, Azure team created SDKs for each environment. In this case, we have an Android SDK that can be downloaded from here (https://go.microsoft.com/fwLink/p/?LinkID=280125).
The first step to be able to use Mobile Services is to create a “MobileServiceClient” instance. This will be used to access all the services available on Mobile Services. When you create a new instance of this class, you will need to specify the url of your mobile service and the application key. All this information are available on Windows Azure portal or on the default application that can be downloaded when you create a new Mobile Service. Warning, don’t share your application key – using this key anybody can access your services.
MobileServiceClient mobileClient = new MobileServiceClient(“mobileSericeUrl”,”applicationKey”,this);
If you want to access a specific table from the backend you can use “getTable” method. The only thing that you need to know is the name of table:
… = mobileClient.getTable(“myTable”);
All the CRUD operation are supported over this table (insert, update, delete and select). In the next example we can see how you can select the rows from a table that have a column equal with a specific value:
myTable.where().field(“name”).eq(“tom”)
  .execute(new TableQueryCallback<MyItem>() {
public void onCompleted(List<MyItem> result, int count, Exception exception, ServiceFilterResponse response) {
// custom code
}
});
As we can see, it is pretty simple to access any kind of resources from Mobile Services. On the backend we can define custom scripts that can run before a CRUD operation is execute over the tables. This custom scripts are defined in JavaScript.
The authentication of the user is already supported. Different identity are supported like Google, Facebook, Microsoft account, Twitter. Before using them we need to configure the identity provider on the backend. Is pretty simple, we only need to add the key and secret key for each identify provider.  For this, Windows Azure team created a page where we can add this information.
After we make this configuration we can specify for each CRUD operation over each table what kind user can access it. On the client when we want to request the user to login we need to call the login method of MobileServiceClient and specify what kind of identity we want to use.
mobileClient.login(MobileServiceAuthenticationProvider.Google, new UserAuthenticationCallback() {
new UserAuthenticationCallback() {
  …
}
  });
From the moment when a user is authenticated, every time when a request is made to Mobile Serivces, the user identity information will be send.
What I liked when Mobile Services were launched was the support for push notification not only for Windows 8 and Windows Phone 8, but also for iOS. Of course we have support for Android application also.
To be able to use push notification on Android devices you will need to use Google apis to push data. After you create an account, you will need to enter the api key in the push tab of Mobile Services portal. On the client application you can use your Google apis as you normally do.
From Mobile Services backend you will be able to send push notification from different location. For example we can send a push notification to our client when someone insert an item in table.
function insert(item, user, request) {
    request.execute({
        success: function() {
            request.respond();
            push.gcm.send(item.channel, “New data available”, {
                success: function(response) {
        // …
                }, error: function(error) {
  // …
                }
            });
        }
    });
}
As we can see, from now we can create Android application that use Windows Azure Mobile Services very simple. From now, when we need to create a backend for a mobile application that have support for different platform we should really take into account Windows Azure Mobile Services.

Comments

  1. i am getting following exception .
    com.microsoft.windowsazure.mobileservice exception

    how i will solve the problem please tell me

    ReplyDelete

Post a Comment

Popular posts from this blog

How to check in AngularJS if a service was register or not

There are cases when you need to check in a service or a controller was register in AngularJS.
For example a valid use case is when you have the same implementation running on multiple application. In this case, you may want to intercept the HTTP provider and add a custom step there. This step don’t needs to run on all the application, only in the one where the service exist and register.
A solution for this case would be to have a flag in the configuration that specify this. In the core you would have an IF that would check the value of this flag.
Another solution is to check if a specific service was register in AngularJS or not. If the service was register that you would execute your own logic.
To check if a service was register or not in AngularJS container you need to call the ‘has’ method of ‘inhector’. It will return TRUE if the service was register.
if ($injector.has('httpInterceptorService')) { $httpProvider.interceptors.push('httpInterceptorService&#…

ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded

Today blog post will be started with the following error when running DB tests on the CI machine:
threw exception: System.InvalidOperationException: The Entity Framework provider type 'System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer' registered in the application config file for the ADO.NET provider with invariant name 'System.Data.SqlClient' could not be loaded. Make sure that the assembly-qualified name is used and that the assembly is available to the running application. See http://go.microsoft.com/fwlink/?LinkId=260882 for more information. at System.Data.Entity.Infrastructure.DependencyResolution.ProviderServicesFactory.GetInstance(String providerTypeName, String providerInvariantName) This error happened only on the Continuous Integration machine. On the devs machines, everything has fine. The classic problem – on my machine it’s working. The CI has the following configuration:

TeamCity.NET 4.51EF 6.0.2VS2013
It seems that there …

Run native .NET application in Docker (.NET Framework 4.6.2)

Scope
The main scope of this post is to see how we can run a legacy application written in .NET Framework in Docker.

Context
First of all, let’s define what is a legacy application in our context. By a legacy application we understand an application that runs .NET Framework 3.5 or higher in a production environment where we don’t have any more the people or documentation that would help us to understand what is happening behind the scene.
In this scenarios, you might want to migrate the current solution from a standard environment to Docker. There are many advantages for such a migration, like:

Continuous DeploymentTestingIsolationSecurity at container levelVersioning ControlEnvironment Standardization
Until now, we didn’t had the possibility to run a .NET application in Docker. With .NET Core, there was support for .NET Core in Docker, but migration from a full .NET framework to .NET Core can be costly and even impossible. Not only because of lack of features, but also because once you…