Xamarin Studio – Visual Studio Goodness on Mac

During Evolve 2016, Xamarin released Xamarin Studio (XS) for Mac as a Release Candidate. This release of XS provides more goodness like Visual Studio on Mac. Let’s see some of the features that are available in this release.

1. Dark Theme
For people like me, who work late at night, this is a boon. You can easily switch the theme and get ‘Dark Theme’ for your IDE. You can change the theme by going to
Xamarin Studio > Preferences > Environment > Visual Styles

XS-Dark-ThemeYou’ll need to restart the IDE to see the effects.

2. New Icons and Graphics
You can see lot of new improvements in terms of graphics and icons when you open a project.

3. Roslyn Support with IntelliSense / Code Completion
XS is rewritten to support Roslyn. It allows code- refactoring and better IntelliSense in IDE. This is like a ReSharper for me :)


4. Xamarin.Form Previewer
Xamarin.Forms Previewer will allow you to see your XAML design right next to it. It is live, so changes in XAML can reflect in UI. You can see the UI results for iOS and Android for both Phone and Tablet mode in both Portrait or Landscape mode. To see the preview, click on ‘Preview’ button on top right corner.
Note: You’ll need Xamarin.Forms v2.3x Pre NuGet package to get this working.

5. Better NuGet Support
You could always add specific version of NuGet package in XS by appending ver in query string while on ‘Add Packages’ window. However, now it has became more easier as XS provides a drop-down for version selector. Small feature, but very helpful.

These are the top 5 features which I can think about when it comes to new Xamarin Studio release. There are many more and you can read about them in release documentation. I’m sure, you’ll enjoy this release.

Mayur Tendulkar

Xamarin.Forms And The Case of Failed NuGet Packages

When you create a Xamarin.Forms project, chances are there will be updates available for Xamarin.Forms libraries and associated packages. You can check for updates to NuGet packages manually or these will be restored before “build”.

The Problem:

When you create a new Xamarin.Forms app or open existing one, if you’ve fresh formatted machine with fresh VS and Xamarin installation, the build may last for longer than expected. The reason for this being, it downloads NuGet packages along with its dependencies like Android Support Packages. If in between, VS hangs or there are interruptions in network, you’ll see some errors in build like this:


The solution:

Well, at first you may think it is issue with Xamarin or Visual Studio or NuGet. But this all has to do with lot of NuGet packages and their dependencies download. So it all depends on machine config and network connectivity. If ever you see above errors follow the below steps:

1) Start from fresh. Close Visual Studio instances and delete everything under %appdata%local/Xamarin (e.g. C:\Users\mayur\AppData\Local\Xamarin)

2) Launch Visual Studio and open the solution. Right click each project and update NuGet packages. Android is the one which will take longer to update.


3) Wait till all packages are downloaded. Make sure the %appdata% folder contents all the necessary directories and files.


4) Build the solution. And if you still get issues about some missing some resources. Open Android SDK Manager from Tools > Android and make sure right API levels (in this case API Level 23) is installed.


Now run the project and it should run without any issues.


Mayur Tendulkar

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