The Case of REST & Azure Resource Manager APIs

There are two kinds of people in this world. One who love ready made SDKs and then there are others who love to work on pure REST APIs. I’m from the 1st category. :)

The reason behind using SDKs is they include pure abstracted API calls. For example, if you use Active Directory Authentication Library (ADAL), it has AcquireTokenAsync method. This method, if you call, takes just couple of lines of code and makes your life much more easier.

However, behind the scenes, this method does a lot of stuff. For example, in case of Windows apps: calling WebAuthenticationBroker, launching Web UI, handling app navigation, etc. Similarly, it does same thing, in iOS and Android. But that entire code base is repetitive in every app which is going to use Active Directory for login. Now, one may ask, why so many calls are made just to authenticate and acquire token or as we progress through this blog post, why so many calls are required to perform basic operations. The answer lies in purity of REST APIs. And ADAL makes life easier here by providing one method doing all this for you while abstracting all the details.

When I was working on my blog post Monitor Azure Resource Usage and Predict Expenses, there was no SDK available for Azure Resource Manager (ARM) and the old API was not an ideal way to handle Resource Management APIs.

So, I had to write an app from scratch to get ARM working in my sample and here my friend Gaurav Mantri (@gmantri) helped me a lot. Gaurav founded Cloud Portam, which helps to manage resources in Azure like Storage, Search, etc… Thanks to him, I could understand the flow and I’m going to put it here on this blog post.

Step 1: Authenticate with Common

ARM allows you to manage resources within subscription and subscription is now part of your Active Directory. So, the first thing that you need to do is to authenticate with right Active Directory. This is simple if you’ve just one subscription and one Active Directory in your subscription, but if you’ve multiple subscriptions/active directories, you may want to iterate through them and get separate access tokens. To avoid this, first we hit the ‘common’ endpoint and then get the Tenants available.

Step 2: Get Tenants

As a user, your user account may be associated with multiple active directories. A tenant is nothing but an active directory to which you have access. Here, in this step we get all active directories first by calling below method. Later on we’ll try to fetch subscription (if available) from each directory.

Step 3: Get Subscriptions

Once we get tenants, each tenant may have subscription on which we may want perform some actions. To do so, we pass each tenant ID from GetTenants() to this method and acquire new token silently (without login prompt)

Step 4: Call ARM APIs

In order to perform management operations on an Azure Subscription, a user must be authenticated and authorized. Authentication part is handled by Azure Active Directory. There is a one to many relationship between an Azure AD and Azure Subscription. i.e. an Azure AD can be used as an authentication store for many Azure Subscriptions however authentication for an Azure Subscription can happen only with a single Azure AD. Once a user is authenticated with an Azure AD, next step is to find out a list of Azure Subscriptions the logged in user has access to. This is what we’re doing in this step. What a user can do in each of these subscriptions (i.e. the authorization part) can be accomplished by using Azure Resource Manager (ARM) API’s Role-based access control (RBAC).

Now you can replace your code in Step 4 to manage or monitor resources in your Azure subscription, but the flow will not change. The entire list of APIs covering resources and possible operations on them is available here

I hope this post will helps you to understand the model behind ARM API calls.

Mayur Tendulkar

Plugin 03: Phone Calling

In continuation to blog posts in this series on plugins, today we’ll cover a plugin to make phone calls.

As we understood before, all platforms support phone calling (just like emailing, texting, etc…) and Xamarin makes it easier with one common language – C#. However, developers still need to learn

In case of Windows Phone, one can initiate a phone call by using following code. In this case, Windows Phone has special class which allow developers to perform this task.

Screenshot 2015-02-23 10.53.12

In case of Android, developers can use ‘Intent’ and ‘URI activation’ to start a new phone call.

Screenshot 2015-02-23 10.56.09

In case of iOS, same concept of URI activation can be applied. As shown below in the code, developers can create a URI with telephone number and it will launch default application to make a phone call.

Screenshot 2015-02-23 11.13.09

Now, in case of Xamarin.Forms developers can use same Messaging Plugin for Xamarin and Windows plugin to implement phone functionality across the platforms.

Screenshot 2015-02-23 12.31.23

This way, developers can utilize the power of plugins to write one code which can work across different platforms, without bothering about underlying APIs.

Mayur Tendulkar

Don’t Re-Invent the Wheel: Use Components or Plugins In Your Apps

Xamarin provides native, cross-platform mobile application development using language we all know and love – C#. However, it is still required to learn concepts of each platform. For example to send text message (SMS) in all these three platforms there are different set of APIs.

Below API is for Android, which uses SmsManager to send the text message. There is another way to do this using Intents.


In case of Windows Phone, ChatMessage allows us to declare and send text message. This API is available in WinRT platform. In case of SL based apps, we need to use Launchers/Choosers.


In case of iOS as shown below, there is no API as such. But we use URL to launch default messaging app. In this case, we cannot set the message body, which we want to send out.


Life will be much simpler if there will be just one API on all these platforms which will take care of sending text messages and as I developer we don’t need to bother about on which platform it is being called. Here comes components and plugins. My friend James has written a nice blog about ‘What Exactly is a Plugin for Xamarin?’. You can read it here

In our case, we’re going to use Messaging Plugin for Xamarin and Windows which allow us to use same API to send text messages. Below code is written once in a Xamarin.Forms project which depending on platform on which code is executing, send the message using that platform’s APIs.


Using this plugin, it becomes easier to send text messages on Android, iOS and Windows. And this is the magic of Plugins for Xamarin.

In future posts, we’ll cover some of the best plugins and components which can help you build cross-platform mobile applications with single code-base.

I hope you’ve enjoyed this.

Mayur Tendulkar

Events! Events!! Events Everywhere!!!

I’m drafting this blog post while attending (virtually) Apple Live event about iPhone 6 and Watch. And this is a start of series of events that are happening in near future. This is your one reference guide to those events. Don’t miss them if you’re a .NET Developer, Xamarin developer or a Microsoft MVP. Smile

PUG DevCon 2014


PUG DevCon is a premier event for developers in and around Pune, India. This is going to be a 2 days, multi-track event with industry experts and speakers like Daniel, Nauzad, Raj, Guruji (Sanjay Vyas) and many more. This event is happening on 13th and 14th Sept at MCCIA, SB Road Pune. For more information visit:

Xamarin EVOLVE 2014


This almost a week long event is all about cross-platform mobile and smart gear app development using Xamarin. This event also includes hands-on training and sessions by various industry experts and it is happening at Atlanta, GA on 6th Oct till 10th Oct. For More information visit:

TechEd 2014


Microsoft India’s premier technology event – TechEd is happening from 5th till 6th Nov and this time at Lalit Ashok, Bangalore. You can find more information about this event at: 

MVP Summit


If you’re a Microsoft MVP, you might have received MVP Summit invite –  a special invite only event for MVPs. This time it is happening from 3rd Nov till 6th Nov at Redmond. Follow the invite for more information.

And much more:

Apart from these events, there are many events in December, for example friend Kunal and Deepak are getting married. Aviraj is coming for a short India visit and I think these are big events for us. And these are very special invite only events Smile

Till then, don’t forget to register and see you at all these events. ‘Say Hi’ if you’re around (except TechEd, I’ll be at Summit).


Mayur Tendulkar