Azure Service Map REST API samples

You probably know what Azure Service Map is: a service that can analyze traffic in your data center and display application dependencies. This can be extremely useful for different purposes, such as deciding which VMs can be moved to the public cloud, and in which order.

This picture shows a screenshot of the type of analysis you can do with Azure Service Map:

servicemap_screenshot

At the time of this writing, there is no SDK to Azure Service Map, but there are some REST APIs. Unfortunately, the Service Map REST API Reference documentation is not too rich in examples, so I compiled a Postman library and a Powershell script with sample code that demonstrates how to use Azure Service Map REST API.

The Postman library is designed to be used with Postman “environments”: you can define a new environment, configure the variables used in the API calls (SubscriptionId, TenantId, etc) and you are ready to rumble. If you did not know Postman but you are working with REST APIs, you have just found something to do for this evening.

The PowerShell script is similar: at the beginning, you have a section where you can define the specifics of your environment, and following it you will find a series of code snippets that perform different tasks.

Regarding the API itself, the authentication is using

The examples cover:

  • Authentication (using a service principal)
  • Listing virtual machines reporting information to Service Map
  • Listing VM groups configured in Service Map
  • Adding VMs to VM groups

Have fun with Azure Service Map!

Leave a comment