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  Boost processing performance by combining AI models

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
    Pure Accelerate 2025: All the news and updates live from Las Vegas
    • June 18, 2025
  • 2
    ‘This was a very purposeful strategy’: Pure Storage unveils Enterprise Data Cloud in bid to unify data storage, management
    • June 18, 2025
  • What is cloud bursting?
    • June 18, 2025
  • 4
    There’s a ‘cloud reset’ underway, and VMware Cloud Foundation 9.0 is a chance for Broadcom to pounce on it
    • June 17, 2025
  • What is confidential computing?
    • June 17, 2025
  • Oracle adds xAI Grok models to OCI
    • June 17, 2025
  • Fine-tune your storage-as-a-service approach
    • June 16, 2025
  • 8
    Advanced audio dialog and generation with Gemini 2.5
    • June 15, 2025
  • 9
    A Father’s Day Gift for Every Pop and Papa
    • June 13, 2025
  • 10
    Global cloud spending might be booming, but AWS is trailing Microsoft and Google
    • June 13, 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
  • Google Cloud, Cloudflare struck by widespread outages
    • June 12, 2025
  • What is PC as a service (PCaaS)?
    • June 12, 2025
  • 3
    Crayon targets mid-market gains with expanded Google Cloud partnership
    • June 10, 2025
  • By the numbers: Use AI to fill the IT skills gap
    • June 11, 2025
  • 5
    Apple services deliver powerful features and intelligent updates to users this autumn
    • June 11, 2025
  • /
  • Technology
  • Tools
  • About
  • Contact Us

Input your search keywords and press Enter.