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  DeepSeek R1 is now available on Azure AI Foundry and GitHub

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
  • 1
    Just make it scale: An Aurora DSQL story
    • May 29, 2025
  • 2
    Reliance on US tech providers is making IT leaders skittish
    • May 28, 2025
  • Examine the 4 types of edge computing, with examples
    • May 28, 2025
  • AI and private cloud: 2 lessons from Dell Tech World 2025
    • May 28, 2025
  • 5
    TD Synnex named as UK distributor for Cohesity
    • May 28, 2025
  • Weigh these 6 enterprise advantages of storage as a service
    • May 28, 2025
  • 7
    Broadcom’s ‘harsh’ VMware contracts are costing customers up to 1,500% more
    • May 28, 2025
  • 8
    Pulsant targets partner diversity with new IaaS solution
    • May 23, 2025
  • 9
    Growing AI workloads are causing hybrid cloud headaches
    • May 23, 2025
  • Gemma 3n 10
    Announcing Gemma 3n preview: powerful, efficient, mobile-first AI
    • May 22, 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
    Cloud adoption isn’t all it’s cut out to be as enterprises report growing dissatisfaction
    • May 15, 2025
  • 2
    Hybrid cloud is complicated – Red Hat’s new AI assistant wants to solve that
    • May 20, 2025
  • 3
    Google is getting serious on cloud sovereignty
    • May 22, 2025
  • oracle-ibm 4
    Google Cloud and Philips Collaborate to Drive Consumer Marketing Innovation and Transform Digital Asset Management with AI
    • May 20, 2025
  • notta-ai-header 5
    Notta vs Fireflies: Which AI Transcription Tool Deserves Your Attention in 2025?
    • May 16, 2025
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.