Azure Compute API Reference

Comprehensive documentation for interacting with Azure Compute resources.

Introduction to Azure Compute API

The Azure Compute API allows you to programmatically manage a wide range of compute resources within Azure. This includes virtual machines, virtual machine scale sets, availability sets, disks, and more. By leveraging this API, you can automate deployment, configuration, and management tasks, enabling greater agility and efficiency in your cloud operations.

This documentation provides detailed information on available endpoints, request/response structures, parameters, and usage examples for the Azure Compute API.

Virtual Machines (VMs)

Manage individual virtual machine instances.

List Virtual Machines

Retrieves a list of all virtual machines in a specified resource group.

Method: GET

Endpoint: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines

Parameters:

Name Type Description Required
resourceGroupName string The name of the resource group. Yes
subscriptionId string Your Azure subscription ID. Yes

Example Request (cURL)

curl -X GET \
  'https://management.azure.com/subscriptions/YOUR_SUBSCRIPTION_ID/resourceGroups/MyResourceGroup/providers/Microsoft.Compute/virtualMachines?api-version=2023-07-01' \
  -H 'Authorization: Bearer YOUR_ACCESS_TOKEN'

Create Virtual Machine

Creates or updates a virtual machine.

Method: PUT

Endpoint: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}

Request Body:

The request body defines the properties of the virtual machine, including its size, OS image, network configuration, and storage.

{
  "location": "eastus",
  "properties": {
    "hardwareProfile": {
      "vmSize": "Standard_DS1_v2"
    },
    "storageProfile": {
      "imageReference": {
        "publisher": "Canonical",
        "offer": "0001-com-ubuntu-server-jammy",
        "version": "latest",
        "sku": "22.04-LTS"
      },
      "osDisk": {
        "createOption": "FromImage",
        "managedDisk": {
          "storageAccountType": "Standard_LRS"
        }
      }
    },
    "osProfile": {
      "computerName": "myVM",
      "adminUsername": "azureuser",
      "adminPassword": "YOUR_STRONG_PASSWORD"
    },
    "networkProfile": {
      "networkInterfaces": [
        {
          "id": "/subscriptions/YOUR_SUBSCRIPTION_ID/resourceGroups/MyResourceGroup/providers/Microsoft.Network/networkInterfaces/myNic",
          "properties": {
            "primary": true
          }
        }
      ]
    }
  }
}
Note: Ensure that the network interface (NIC) specified in the request body already exists and is configured correctly.

Get Virtual Machine Details

Retrieves the details of a specific virtual machine.

Method: GET

Endpoint: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}

Start Virtual Machine

Starts a virtual machine.

Method: POST

Endpoint: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/start

Stop Virtual Machine

Stops a virtual machine. This deallocates the VM.

Method: POST

Endpoint: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/deallocate

Delete Virtual Machine

Deletes a virtual machine. Note that this operation does not delete associated disks by default.

Method: DELETE

Endpoint: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}

Availability Sets

Ensure high availability and redundancy for your applications.

List Availability Sets

Retrieves a list of availability sets in a specified resource group.

Method: GET

Endpoint: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets

Create Availability Set

Creates or updates an availability set.

Method: PUT

Endpoint: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/availabilitySets/{availabilitySetName}

Virtual Machine Scale Sets

Manage and scale a group of identical, load-balanced virtual machines.

List Scale Sets

Retrieves a list of virtual machine scale sets in a specified resource group.

Method: GET

Endpoint: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets

Create Scale Set

Creates or updates a virtual machine scale set.

Method: PUT

Endpoint: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachineScaleSets/{vmssName}

Disk Management

Manage Azure managed disks.

List Managed Disks

Retrieves a list of managed disks in a specified resource group.

Method: GET

Endpoint: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks

Create Managed Disk

Creates or updates a managed disk.

Method: PUT

Endpoint: /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/disks/{diskName}

Tip: When creating disks, consider using a custom image or snapshot for faster provisioning and consistency.

Networking

Refer to the Azure Networking API for detailed documentation on managing virtual networks, subnets, IP addresses, and network security groups.

Microsoft.Network provider documentation.

Storage

Refer to the Azure Storage API for detailed documentation on managing storage accounts, blobs, queues, and tables.

Microsoft.Storage provider documentation.