Monday, April 13, 2015

Azure Resource Explorer

Microsoft has just issued a very cool new Azure Tool: Azure Resource Explorer. This tool is a web site within Azure: navigate to and you get to the base.

Once you have logged in, you can use the tool to discover the Azure Resource Management APIs. These APIs are implemented as Rest APIs, where the URI is used to specify a specific resource, and JSON is used to hold the details of this resource. If you understand REST APIs, the concept is well understood. But if you come from a more traditional IT Pro background ('no developer foo foo here thank you"), understanding both Rest and the Azure REST APIs can be quite useful. And for those of you who smugly import the Azure module – remember that these cmdlets merely wrap the REST API. Running a cmdlet simply invokes the REST API.

The tool also enables you to view the API documentation. This is a fantastic bit of assistance for the developer, or an IT Pro who wants to use the API directly within a PowerShell script. Having said that, the documentation is not overwhelming. It is incomplete in places and in others, it's pretty thin. But this is something that no doubt will improve over time!

The final cool feature of the Tool is the ability to actually make API calls to your own Azure subscriptions.  When you first open up the Explorer, you notice a tree control in the left most pane – this is the resource hierarchy tree. You can use the tree control to open up lower nodes, such as the configuration of a single VM.

Here is a screenshot of one of my Azure VMs. I have blacked out the subscription ID, but the rest is as you would see it. If you notice, the shape of the hierarchy in the tree control matches the shape of the URI. This is, of course, normal REST practice – but seeing it both as a URI and a tree helps me to visualise the resources.


In the screen shot, I show one VM. In the right pane you will see the 'data' relating to a resource. In this case, it's the details of a VM. The URI/Tree control points to a specific subscription and a specific resource group and to the VMs in that group (in this case just one). That VM has a bunch of properties (hardwareProfile, networkProfile, etc). The details of the resource, the VM, is expressed in JSON. If you issue an API call (eg a Get on this URI), you will get a JSON document back – and then use ConvertTo-JSON and ConvertFrom-Json cmdlets to interoperate with the data used with the API.

One final cool feature of this tool. If you look carefully ad the details of this VM – the line numbers in the JSON document are not fully contiguous – that's because I used the region folding feature of the explorer to hid details. Just click on the chevron to the right of a line number to hide/reveal what is below. Someone put a lot of thought into this explorer. 

I hope further work is done, particularly in terms of improving the API documentation. But an even cooler feature  would be to enable the Explorer to spit out a working PowerShell snippet to interact with the API. Much like MOW's old WMI explorer that showed you how to use WMI Methods. So you navigate to the resource you want to manage, select the HTTP Verb (Get, Put, Post, Delete) and then see how that verb would used against API expressed in the URI. It would include setting up the HTTP call, making the API call, then using the data from returned JSON.

No comments: