aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
aster.cloud aster.cloud
  • /
  • Platforms
    • Public Cloud
    • On-Premise
    • Hybrid Cloud
    • Data
  • Architecture
    • Design
    • Solutions
    • Enterprise
  • Engineering
    • Automation
    • Software Engineering
    • Project Management
    • DevOps
  • Programming
    • Learning
  • Tools
  • About
  • DevOps
  • Platforms

How To Call Azure REST APIs

  • root
  • September 25, 2019
  • 1 minute read

Overview

This guide will show you how to make a request or call the Azure REST API.

 


Partner with aster.cloud
for your next big idea.
Let us know here.



From our partners:

CITI.IO :: Business. Institutions. Society. Global Political Economy.
CYBERPOGO.COM :: For the Arts, Sciences, and Technology.
DADAHACKS.COM :: Parenting For The Rest Of Us.
ZEDISTA.COM :: Entertainment. Sports. Culture. Escape.
TAKUMAKU.COM :: For The Hearth And Home.
ASTER.CLOUD :: From The Cloud And Beyond.
LIWAIWAI.COM :: Intelligence, Inside and Outside.
GLOBALCLOUDPLATFORMS.COM :: For The World's Computing Needs.
FIREGULAMAN.COM :: For The Fire In The Belly Of The Coder.
ASTERCASTER.COM :: Supra Astra. Beyond The Stars.
BARTDAY.COM :: Prosperity For Everyone.

Prerequisites

  • Access to the Azure portal
  • REST Client or command line to send a request

An example REST Client is Postman, for a guide on how to install Postman, see here.

 

Acquiring an OAuth2 Token

01. Acquire the following information from the Azure account before proceeding further.

  • Subscription ID
  • Tenant ID
  • Client ID
  • Client Secret
  • Resource Group ID (for the resource you will be accessing)

Refer to this guide on how to acquire the above credentials.

 

02. Make an API call to retrieve the OAuth2 access token.

URL https://login.microsoftonline.com/{{tenant_id}}/oauth2/token
HTTP Method POST
HTTP Headers Content-Type : application/x-www-form-urlencoded
Form Data grant_type : client_credentials

client_id : {{client_id}}

client_secret : {{client_secret}}

resource : https://management.azure.com

 

via Postman

 

03. It will return a similar response

{
  "token_type"     : "Bearer",
  "expires_in"     : "3600",
  "ext_expires_in" : "3600",
  "expires_on"     : "1567831530",
  "not_before"     : "1567827630",
  "resource"       : "https://management.azure.com",
  "access_token"   : "{{access_token}}"
}

 

Take note of the retrieved access token, this will be used to access the Azure resources.

 

Calling a REST API Endpoint

In the following example, we will be retrieving the list of Virtual Machines for a specific Resource Group.

01. Make an API call to retrieve the list of VM Instances.

The ouath2_token is the value retrieved from the https://login.microsoftonline.com/{{tenant_id}}/oauth2/token request.

URL https://management.azure.com/subscriptions/{{subscription_id}}/resourceGroups/{{resource_group_name}}/providers/Microsoft.Compute/virtualMachines?api-version=2018-06-01
HTTP Method GET
HTTP Headers Authorization : Bearer {{oauth2_token}}
Form Data — none —

 

via Postman

 

02. The following will be the sample response. Some details have been removed.

{
    "value": [
        {
            "name": "vm-geek-web-001",
            "id": "/subscriptions/.../resourceGroups/rg-geek/providers/Microsoft.Compute/virtualMachines/vm-geek-web-001",
            "type": "Microsoft.Compute/virtualMachines",
            "location": "southeastasia",
            "properties": {
                "vmId": "50711f51-1bcd-4bda-9cec-f1a28455f7fa",
                "hardwareProfile": {
                    "vmSize": "Standard_B1ls"
                },
                "storageProfile": {
                    "imageReference": {
                        "publisher": "Canonical",
                        "offer": "UbuntuServer",
                        "sku": "18.04-LTS",
                        "version": "latest"
                    },
                    "osDisk": {
                        "osType": "Linux",
                        "name": "vm-geek-web-001_OsDisk_1_2c20eb2db8ea4405975ad6e2eb2041f1",
                        "createOption": "FromImage",
                        "caching": "ReadWrite",
                        "managedDisk": {
                            "storageAccountType": "Standard_LRS",
                            "id": "/subscriptions/.../resourceGroups/rg-geek/providers/Microsoft.Compute/disks/vm-geek-web-001_OsDisk_1_2c20eb2db8ea4405975ad6e2eb2041f1"
                        },
                        "diskSizeGB": 30
                    },
                    "dataDisks": []
                },
                "osProfile": {
                    "computerName": "vm-geek-web-001",
                    "adminUsername": "devops",
                    "linuxConfiguration": {
                        "disablePasswordAuthentication": true,
                        "ssh": {
                            "publicKeys": [
                                {
                                    "path": "/home/devops/.ssh/authorized_keys",
                                    "keyData": "ssh-rsa ..."
                                }
                            ]
                        },
                        "provisionVMAgent": true
                    },
                    "secrets": [],
                    "allowExtensionOperations": true
                },
                "networkProfile": {
                    "networkInterfaces": [
                        {
                            "id": "/subscriptions/.../resourceGroups/rg-geek/providers/Microsoft.Network/networkInterfaces/vm-geek-web-001266"
                        }
                    ]
                },
                "diagnosticsProfile": {
                    "bootDiagnostics": {
                        "enabled": true,
                        "storageUri": "https://rggeekdiag.blob.core.windows.net/"
                    }
                },
                "provisioningState": "Succeeded"
            }
        }
    ]
}

 

If the OAuth token is expired it will return the following.

{
  "error": 
  {
    "code": "ExpiredAuthenticationToken",
    "message": "The access token expiry UTC time '8/21/2019 9:13:16 AM' is earlier than current UTC time '9/7/2019 4:22:04 AM'."
  }
}
Read More  Microsoft Build 2019 | Develop data application on a no-limits SQL data platform

For enquiries, product placements, sponsorships, and collaborations, connect with us at [email protected]. We'd love to hear from you!

Our humans need coffee too! Your support is highly appreciated, thank you!

root

Related Topics
  • API
  • Azure
  • Azure REST API
  • REST
You May Also Like
Google Cloud and Smart Communications
View Post
  • Platforms
  • Technology

Smart Communications, Inc. Dials into Google Cloud AI to Help Personalize Digital Services for Filipinos

  • October 25, 2024
View Post
  • Platforms
  • Public Cloud

Empowering builders with the new AWS Asia Pacific (Malaysia) Region

  • August 30, 2024
Red Hat and Globe Telecoms
View Post
  • Platforms
  • Technology

Globe Collaborates with Red Hat Open Innovation Labs to Modernize IT Infrastructure for Greater Agility and Scalability

  • August 19, 2024
Huawei Cloud Cairo Region Goes Live
View Post
  • Cloud-Native
  • Computing
  • Platforms

Huawei Cloud Goes Live in Egypt

  • May 24, 2024
Asteroid
View Post
  • Computing
  • Platforms
  • Technology

Asteroid Institute And Google Cloud Identify 27,500 New Asteroids, Revolutionizing Minor Planet Discovery With Cloud Technology

  • April 30, 2024
IBM
View Post
  • Hybrid Cloud
  • Platforms

IBM To Acquire HashiCorp, Inc. Creating A Comprehensive End-to-End Hybrid Cloud Platform

  • April 24, 2024
View Post
  • Platforms
  • Technology

Canonical Delivers Secure, Compliant Cloud Solutions for Google Distributed Cloud

  • April 9, 2024
Redis logo
View Post
  • Platforms
  • Software

Redis Moves To Source-Available Licenses

  • April 2, 2024

Stay Connected!
LATEST
  • college-of-cardinals-2025 1
    The Definitive Who’s Who of the 2025 Papal Conclave
    • May 7, 2025
  • conclave-poster-black-smoke 2
    The World Is Revalidating Itself
    • May 6, 2025
  • oracle-ibm 3
    IBM and Oracle Expand Partnership to Advance Agentic AI and Hybrid Cloud
    • May 6, 2025
  • 4
    Conclave: How A New Pope Is Chosen
    • April 25, 2025
  • Getting things done makes her feel amazing 5
    Nurturing Minds in the Digital Revolution
    • April 25, 2025
  • 6
    AI is automating our jobs – but values need to change if we are to be liberated by it
    • April 17, 2025
  • 7
    Canonical Releases Ubuntu 25.04 Plucky Puffin
    • April 17, 2025
  • 8
    United States Army Enterprise Cloud Management Agency Expands its Oracle Defense Cloud Services
    • April 15, 2025
  • 9
    Tokyo Electron and IBM Renew Collaboration for Advanced Semiconductor Technology
    • April 2, 2025
  • 10
    IBM Accelerates Momentum in the as a Service Space with Growing Portfolio of Tools Simplifying Infrastructure Management
    • March 27, 2025
about
Hello World!

We are aster.cloud. We’re created by programmers for programmers.

Our site aims to provide guides, programming tips, reviews, and interesting materials for tech people and those who want to learn in general.

We would like to hear from you.

If you have any feedback, enquiries, or sponsorship request, kindly reach out to us at:

[email protected]
Most Popular
  • 1
    Tariffs, Trump, and Other Things That Start With T – They’re Not The Problem, It’s How We Use Them
    • March 25, 2025
  • 2
    IBM contributes key open-source projects to Linux Foundation to advance AI community participation
    • March 22, 2025
  • 3
    Co-op mode: New partners driving the future of gaming with AI
    • March 22, 2025
  • 4
    Mitsubishi Motors Canada Launches AI-Powered “Intelligent Companion” to Transform the 2025 Outlander Buying Experience
    • March 10, 2025
  • PiPiPi 5
    The Unexpected Pi-Fect Deals This March 14
    • March 13, 2025
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.