Red Shirt Dev Tour 2018 à Paris - Hands On Labs avec Graph API - Cellenza Blog

Sometimes you might want to get some information about Azure virtual machines. In this article, we will explore Azure Graph API to extract information about your virtual machines with a very simple PowerShell script.

More information about Graph API :

Open the Azure Portal, go to App Registrations

 App Registrations

Click New Registration to create a new app

New Registration

Enter a friendly name to your application. Regarding the URI, it is optional, so you can add https:///localhost


Once it is created, you will see the information on the home page. We will need to copy/paste these information later.

Home page

Go to Certificates & secrets to create a Client Secret that will be used to authenticate to the Azure REST API calls.

Certificates & secrets

Click on New Client secret to generate the secret.

New Client secret

Add a description and select if you want expiration or not

Add a description

Be careful, you have to save the key somewhere as it will not be accessible after.

Save the key somewhere

Now go to Subscription and the IAM blade. Click Add / Add role assignment

Add role assignment

Search the App created previously and select the Reader role for your App.

Reader role

Copy/paste the subscription ID as it will be required later.

Subscription ID

StarWind VSAN for vSphere uses your local hypervisor cluster to create fault-tolerant and robust virtual shared storage, eliminating the need to buy a costly physical SAN. You can deploy it on any off-the-shelf hardware you already got. Thanks to mirroring of internal hard disks and flash between hypervisor servers, you get a 2-node Highly Available cluster. There is no need for a witness instance, and you’re not restricted on storage size, features, or number of VMs. Your IT-environment will not only achieve constant uptime and skyrocketing performance, you will also save a good deal on CapEx and OpEx.
Find out more about ➡ StarWind VSAN for vSphere

Everything is ok, so now we can use the following PowerShell script in order to query the Azure subscription.

This script returns information about Virtual Machines.

Information about Virtual Machines

Of course, you can get information about all the Azure resources, please check the following documentation:

Views All Time
Views Today
Back to blog
The following two tabs change content below.
Nicolas Prigent
Nicolas Prigent
Nicolas Prigent works as an IT Production Manager, based in Paris, with a primary focus on Microsoft technologies. Nicolas is a three-time Microsoft MVP in Cloud and Datacenter Management with 10 years experience in administering Windows products. He also received the "PowerShell Heroes 2016" Award.