The operation that retrieves information about the capacity reservation.
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}?api-version=2025-11-01
With optional parameters:
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/capacityReservationGroups/{capacityReservationGroupName}/capacityReservations/{capacityReservationName}?api-version=2025-11-01&$expand=instanceView
URI Parameters
| Name |
In |
Required |
Type |
Description |
|
capacityReservationGroupName
|
path |
True
|
string
|
The name of the capacity reservation group.
|
|
capacityReservationName
|
path |
True
|
string
|
The name of the capacity reservation.
|
|
resourceGroupName
|
path |
True
|
string
minLength: 1 maxLength: 90
|
The name of the resource group. The name is case insensitive.
|
|
subscriptionId
|
path |
True
|
string
minLength: 1
|
The ID of the target subscription.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
The API version to use for this operation.
|
|
$expand
|
query |
|
CapacityReservationInstanceViewTypes
|
The expand expression to apply on the operation. 'InstanceView' retrieves a snapshot of the runtime properties of the capacity reservation that is managed by the platform and can change outside of control plane operations.
|
Responses
| Name |
Type |
Description |
|
200 OK
|
CapacityReservation
|
Azure operation completed successfully.
|
|
Other Status Codes
|
CloudError
|
An unexpected error response.
|
Security
azure_auth
Azure Active Directory OAuth2 Flow.
Type:
oauth2
Flow:
implicit
Authorization URL:
https://login.microsoftonline.com/common/oauth2/authorize
Scopes
| Name |
Description |
|
user_impersonation
|
impersonate your user account
|
Examples
Get a block capacity reservation.
Sample request
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/capacityReservationGroups/blockCapacityReservationGroup/capacityReservations/blockCapacityReservation?api-version=2025-11-01&$expand=instanceView
import com.azure.resourcemanager.compute.models.CapacityReservationInstanceViewTypes;
/**
* Samples for CapacityReservations Get.
*/
public final class Main {
/*
* x-ms-original-file: 2025-11-01/capacityReservationExamples/BlockCapacityReservation_Get.json
*/
/**
* Sample code: Get a block capacity reservation.
*
* @param manager Entry point to ComputeManager.
*/
public static void getABlockCapacityReservation(com.azure.resourcemanager.compute.ComputeManager manager) {
manager.serviceClient().getCapacityReservations().getWithResponse("myResourceGroup",
"blockCapacityReservationGroup", "blockCapacityReservation",
CapacityReservationInstanceViewTypes.INSTANCE_VIEW, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python block_capacity_reservation_get.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.capacity_reservations.get(
resource_group_name="myResourceGroup",
capacity_reservation_group_name="blockCapacityReservationGroup",
capacity_reservation_name="blockCapacityReservation",
)
print(response)
# x-ms-original-file: 2025-11-01/capacityReservationExamples/BlockCapacityReservation_Get.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v8"
)
// Generated from example definition: 2025-11-01/capacityReservationExamples/BlockCapacityReservation_Get.json
func ExampleCapacityReservationsClient_Get_getABlockCapacityReservation() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("{subscriptionId}", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewCapacityReservationsClient().Get(ctx, "myResourceGroup", "blockCapacityReservationGroup", "blockCapacityReservation", &armcompute.CapacityReservationsClientGetOptions{
Expand: to.Ptr(armcompute.CapacityReservationInstanceViewTypesInstanceView)})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armcompute.CapacityReservationsClientGetResponse{
// CapacityReservation: &armcompute.CapacityReservation{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/capacityReservationGroups/blockCapacityReservationGroup/capacityReservations/blockCapacityReservation"),
// Properties: &armcompute.CapacityReservationProperties{
// PlatformFaultDomainCount: to.Ptr[int32](3),
// ReservationID: to.Ptr("{GUID}"),
// ProvisioningTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-27T01:02:38.3138469+00:00"); return t}()),
// VirtualMachinesAssociated: []*armcompute.SubResourceReadOnly{
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"),
// },
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM2"),
// },
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM3"),
// },
// },
// ProvisioningState: to.Ptr("Succeeded"),
// InstanceView: &armcompute.CapacityReservationInstanceView{
// UtilizationInfo: &armcompute.CapacityReservationUtilization{
// CurrentCapacity: to.Ptr[int32](5),
// VirtualMachinesAllocated: []*armcompute.SubResourceReadOnly{
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"),
// },
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM2"),
// },
// },
// },
// Statuses: []*armcompute.InstanceViewStatus{
// {
// Code: to.Ptr("ProvisioningState/succeeded"),
// Level: to.Ptr(armcompute.StatusLevelTypesInfo),
// DisplayStatus: to.Ptr("Provisioning succeeded"),
// },
// },
// },
// ScheduleProfile: &armcompute.ScheduleProfile{
// Start: to.Ptr("2025-08-01T12:00:00Z"),
// End: to.Ptr("2025-08-02T11:30:00Z"),
// },
// TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-27T01:02:38.3138469+00:00"); return t}()),
// },
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "department": to.Ptr("HR"),
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_ND96isr_H100_v5"),
// Capacity: to.Ptr[int64](1),
// },
// Zones: []*string{
// to.Ptr("1"),
// },
// Name: to.Ptr("blockCapacityReservation"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to the operation that retrieves information about the capacity reservation.
*
* @summary the operation that retrieves information about the capacity reservation.
* x-ms-original-file: 2025-11-01/capacityReservationExamples/BlockCapacityReservation_Get.json
*/
async function getABlockCapacityReservation() {
const credential = new DefaultAzureCredential();
const subscriptionId = "{subscriptionId}";
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.capacityReservations.get(
"myResourceGroup",
"blockCapacityReservationGroup",
"blockCapacityReservation",
{ expand: "instanceView" },
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/Compute/stable/2025-11-01/examples/capacityReservationExamples/BlockCapacityReservation_Get.json
// this example is just showing the usage of "CapacityReservations_Get" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this CapacityReservationGroupResource created on azure
// for more information of creating CapacityReservationGroupResource, please refer to the document of CapacityReservationGroupResource
string subscriptionId = "{subscriptionId}";
string resourceGroupName = "myResourceGroup";
string capacityReservationGroupName = "blockCapacityReservationGroup";
ResourceIdentifier capacityReservationGroupResourceId = CapacityReservationGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, capacityReservationGroupName);
CapacityReservationGroupResource capacityReservationGroup = client.GetCapacityReservationGroupResource(capacityReservationGroupResourceId);
// get the collection of this CapacityReservationResource
CapacityReservationCollection collection = capacityReservationGroup.GetCapacityReservations();
// invoke the operation
string capacityReservationName = "blockCapacityReservation";
CapacityReservationInstanceViewType? expand = CapacityReservationInstanceViewType.InstanceView;
NullableResponse<CapacityReservationResource> response = await collection.GetIfExistsAsync(capacityReservationName, expand: expand);
CapacityReservationResource result = response.HasValue ? response.Value : null;
if (result == null)
{
Console.WriteLine("Succeeded with null as result");
}
else
{
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
CapacityReservationData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/capacityReservationGroups/blockCapacityReservationGroup/capacityReservations/blockCapacityReservation",
"properties": {
"platformFaultDomainCount": 3,
"reservationId": "{GUID}",
"provisioningTime": "2021-06-27T01:02:38.3138469+00:00",
"virtualMachinesAssociated": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM2"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM3"
}
],
"provisioningState": "Succeeded",
"instanceView": {
"utilizationInfo": {
"currentCapacity": 5,
"virtualMachinesAllocated": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM2"
}
]
},
"statuses": [
{
"code": "ProvisioningState/succeeded",
"level": "Info",
"displayStatus": "Provisioning succeeded"
}
]
},
"scheduleProfile": {
"start": "2025-08-01T12:00:00Z",
"end": "2025-08-02T11:30:00Z"
},
"timeCreated": "2021-06-27T01:02:38.3138469+00:00"
},
"location": "westus",
"tags": {
"department": "HR"
},
"sku": {
"name": "Standard_ND96isr_H100_v5",
"capacity": 1
},
"zones": [
"1"
],
"name": "blockCapacityReservation"
}
Get a capacity reservation.
Sample request
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/capacityReservationGroups/myCapacityReservationGroup/capacityReservations/myCapacityReservation?api-version=2025-11-01&$expand=instanceView
import com.azure.resourcemanager.compute.models.CapacityReservationInstanceViewTypes;
/**
* Samples for CapacityReservations Get.
*/
public final class Main {
/*
* x-ms-original-file: 2025-11-01/capacityReservationExamples/CapacityReservation_Get.json
*/
/**
* Sample code: Get a capacity reservation.
*
* @param manager Entry point to ComputeManager.
*/
public static void getACapacityReservation(com.azure.resourcemanager.compute.ComputeManager manager) {
manager.serviceClient().getCapacityReservations().getWithResponse("myResourceGroup",
"myCapacityReservationGroup", "myCapacityReservation", CapacityReservationInstanceViewTypes.INSTANCE_VIEW,
com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python capacity_reservation_get.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.capacity_reservations.get(
resource_group_name="myResourceGroup",
capacity_reservation_group_name="myCapacityReservationGroup",
capacity_reservation_name="myCapacityReservation",
)
print(response)
# x-ms-original-file: 2025-11-01/capacityReservationExamples/CapacityReservation_Get.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v8"
)
// Generated from example definition: 2025-11-01/capacityReservationExamples/CapacityReservation_Get.json
func ExampleCapacityReservationsClient_Get_getACapacityReservation() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("{subscriptionId}", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewCapacityReservationsClient().Get(ctx, "myResourceGroup", "myCapacityReservationGroup", "myCapacityReservation", &armcompute.CapacityReservationsClientGetOptions{
Expand: to.Ptr(armcompute.CapacityReservationInstanceViewTypesInstanceView)})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armcompute.CapacityReservationsClientGetResponse{
// CapacityReservation: &armcompute.CapacityReservation{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/capacityReservationGroups/myCapacityReservationGroup/capacityReservations/myCapacityReservation"),
// Properties: &armcompute.CapacityReservationProperties{
// PlatformFaultDomainCount: to.Ptr[int32](3),
// ReservationID: to.Ptr("{GUID}"),
// ProvisioningTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-27T01:02:38.3138469+00:00"); return t}()),
// VirtualMachinesAssociated: []*armcompute.SubResourceReadOnly{
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"),
// },
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM2"),
// },
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM3"),
// },
// },
// ProvisioningState: to.Ptr("Succeeded"),
// InstanceView: &armcompute.CapacityReservationInstanceView{
// UtilizationInfo: &armcompute.CapacityReservationUtilization{
// CurrentCapacity: to.Ptr[int32](5),
// VirtualMachinesAllocated: []*armcompute.SubResourceReadOnly{
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"),
// },
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM2"),
// },
// },
// },
// Statuses: []*armcompute.InstanceViewStatus{
// {
// Code: to.Ptr("ProvisioningState/succeeded"),
// Level: to.Ptr(armcompute.StatusLevelTypesInfo),
// DisplayStatus: to.Ptr("Provisioning succeeded"),
// },
// },
// },
// TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-27T01:02:38.3138469+00:00"); return t}()),
// },
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "department": to.Ptr("HR"),
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DS1_v2"),
// Capacity: to.Ptr[int64](4),
// },
// Zones: []*string{
// to.Ptr("1"),
// },
// Name: to.Ptr("myCapacityReservation"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to the operation that retrieves information about the capacity reservation.
*
* @summary the operation that retrieves information about the capacity reservation.
* x-ms-original-file: 2025-11-01/capacityReservationExamples/CapacityReservation_Get.json
*/
async function getACapacityReservation() {
const credential = new DefaultAzureCredential();
const subscriptionId = "{subscriptionId}";
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.capacityReservations.get(
"myResourceGroup",
"myCapacityReservationGroup",
"myCapacityReservation",
{ expand: "instanceView" },
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/Compute/stable/2025-11-01/examples/capacityReservationExamples/CapacityReservation_Get.json
// this example is just showing the usage of "CapacityReservations_Get" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this CapacityReservationGroupResource created on azure
// for more information of creating CapacityReservationGroupResource, please refer to the document of CapacityReservationGroupResource
string subscriptionId = "{subscriptionId}";
string resourceGroupName = "myResourceGroup";
string capacityReservationGroupName = "myCapacityReservationGroup";
ResourceIdentifier capacityReservationGroupResourceId = CapacityReservationGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, capacityReservationGroupName);
CapacityReservationGroupResource capacityReservationGroup = client.GetCapacityReservationGroupResource(capacityReservationGroupResourceId);
// get the collection of this CapacityReservationResource
CapacityReservationCollection collection = capacityReservationGroup.GetCapacityReservations();
// invoke the operation
string capacityReservationName = "myCapacityReservation";
CapacityReservationInstanceViewType? expand = CapacityReservationInstanceViewType.InstanceView;
NullableResponse<CapacityReservationResource> response = await collection.GetIfExistsAsync(capacityReservationName, expand: expand);
CapacityReservationResource result = response.HasValue ? response.Value : null;
if (result == null)
{
Console.WriteLine("Succeeded with null as result");
}
else
{
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
CapacityReservationData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/capacityReservationGroups/myCapacityReservationGroup/capacityReservations/myCapacityReservation",
"properties": {
"platformFaultDomainCount": 3,
"reservationId": "{GUID}",
"provisioningTime": "2021-06-27T01:02:38.3138469+00:00",
"virtualMachinesAssociated": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM2"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM3"
}
],
"provisioningState": "Succeeded",
"instanceView": {
"utilizationInfo": {
"currentCapacity": 5,
"virtualMachinesAllocated": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM2"
}
]
},
"statuses": [
{
"code": "ProvisioningState/succeeded",
"level": "Info",
"displayStatus": "Provisioning succeeded"
}
]
},
"timeCreated": "2021-06-27T01:02:38.3138469+00:00"
},
"location": "westus",
"tags": {
"department": "HR"
},
"sku": {
"name": "Standard_DS1_v2",
"capacity": 4
},
"zones": [
"1"
],
"name": "myCapacityReservation"
}
Get a targeted capacity reservation.
Sample request
GET https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/capacityReservationGroups/targetedCapacityReservationGroup/capacityReservations/targetedCapacityReservation?api-version=2025-11-01&$expand=instanceView
import com.azure.resourcemanager.compute.models.CapacityReservationInstanceViewTypes;
/**
* Samples for CapacityReservations Get.
*/
public final class Main {
/*
* x-ms-original-file: 2025-11-01/capacityReservationExamples/TargetedCapacityReservation_Get.json
*/
/**
* Sample code: Get a targeted capacity reservation.
*
* @param manager Entry point to ComputeManager.
*/
public static void getATargetedCapacityReservation(com.azure.resourcemanager.compute.ComputeManager manager) {
manager.serviceClient().getCapacityReservations().getWithResponse("myResourceGroup",
"targetedCapacityReservationGroup", "targetedCapacityReservation",
CapacityReservationInstanceViewTypes.INSTANCE_VIEW, com.azure.core.util.Context.NONE);
}
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
from azure.identity import DefaultAzureCredential
from azure.mgmt.compute import ComputeManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-compute
# USAGE
python targeted_capacity_reservation_get.py
Before run the sample, please set the values of the client ID, tenant ID and client secret
of the AAD application as environment variables: AZURE_CLIENT_ID, AZURE_TENANT_ID,
AZURE_CLIENT_SECRET. For more info about how to get the value, please see:
https://docs.microsoft.com/azure/active-directory/develop/howto-create-service-principal-portal
"""
def main():
client = ComputeManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.capacity_reservations.get(
resource_group_name="myResourceGroup",
capacity_reservation_group_name="targetedCapacityReservationGroup",
capacity_reservation_name="targetedCapacityReservation",
)
print(response)
# x-ms-original-file: 2025-11-01/capacityReservationExamples/TargetedCapacityReservation_Get.json
if __name__ == "__main__":
main()
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
package armcompute_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azcore/to"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/compute/armcompute/v8"
)
// Generated from example definition: 2025-11-01/capacityReservationExamples/TargetedCapacityReservation_Get.json
func ExampleCapacityReservationsClient_Get_getATargetedCapacityReservation() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armcompute.NewClientFactory("{subscriptionId}", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
res, err := clientFactory.NewCapacityReservationsClient().Get(ctx, "myResourceGroup", "targetedCapacityReservationGroup", "targetedCapacityReservation", &armcompute.CapacityReservationsClientGetOptions{
Expand: to.Ptr(armcompute.CapacityReservationInstanceViewTypesInstanceView)})
if err != nil {
log.Fatalf("failed to finish the request: %v", err)
}
// You could use response here. We use blank identifier for just demo purposes.
_ = res
// If the HTTP response code is 200 as defined in example definition, your response structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// res = armcompute.CapacityReservationsClientGetResponse{
// CapacityReservation: &armcompute.CapacityReservation{
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/capacityReservationGroups/targetedCapacityReservationGroup/capacityReservations/targetedCapacityReservation"),
// Properties: &armcompute.CapacityReservationProperties{
// PlatformFaultDomainCount: to.Ptr[int32](3),
// ReservationID: to.Ptr("{GUID}"),
// ProvisioningTime: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-27T01:02:38.3138469+00:00"); return t}()),
// VirtualMachinesAssociated: []*armcompute.SubResourceReadOnly{
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"),
// },
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM2"),
// },
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM3"),
// },
// },
// ProvisioningState: to.Ptr("Succeeded"),
// InstanceView: &armcompute.CapacityReservationInstanceView{
// UtilizationInfo: &armcompute.CapacityReservationUtilization{
// CurrentCapacity: to.Ptr[int32](5),
// VirtualMachinesAllocated: []*armcompute.SubResourceReadOnly{
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"),
// },
// {
// ID: to.Ptr("/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM2"),
// },
// },
// },
// Statuses: []*armcompute.InstanceViewStatus{
// {
// Code: to.Ptr("ProvisioningState/succeeded"),
// Level: to.Ptr(armcompute.StatusLevelTypesInfo),
// DisplayStatus: to.Ptr("Provisioning succeeded"),
// },
// },
// },
// TimeCreated: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2021-06-27T01:02:38.3138469+00:00"); return t}()),
// },
// Location: to.Ptr("westus"),
// Tags: map[string]*string{
// "department": to.Ptr("HR"),
// },
// SKU: &armcompute.SKU{
// Name: to.Ptr("Standard_DS1_v2"),
// Capacity: to.Ptr[int64](4),
// },
// Zones: []*string{
// to.Ptr("1"),
// },
// Name: to.Ptr("targetedCapacityReservation"),
// },
// }
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
const { ComputeManagementClient } = require("@azure/arm-compute");
const { DefaultAzureCredential } = require("@azure/identity");
/**
* This sample demonstrates how to the operation that retrieves information about the capacity reservation.
*
* @summary the operation that retrieves information about the capacity reservation.
* x-ms-original-file: 2025-11-01/capacityReservationExamples/TargetedCapacityReservation_Get.json
*/
async function getATargetedCapacityReservation() {
const credential = new DefaultAzureCredential();
const subscriptionId = "{subscriptionId}";
const client = new ComputeManagementClient(credential, subscriptionId);
const result = await client.capacityReservations.get(
"myResourceGroup",
"targetedCapacityReservationGroup",
"targetedCapacityReservation",
{ expand: "instanceView" },
);
console.log(result);
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
using Azure;
using Azure.ResourceManager;
using System;
using System.Threading.Tasks;
using Azure.Core;
using Azure.Identity;
using Azure.ResourceManager.Compute.Models;
using Azure.ResourceManager.Compute;
// Generated from example definition: specification/compute/resource-manager/Microsoft.Compute/Compute/stable/2025-11-01/examples/capacityReservationExamples/TargetedCapacityReservation_Get.json
// this example is just showing the usage of "CapacityReservations_Get" operation, for the dependent resources, they will have to be created separately.
// get your azure access token, for more details of how Azure SDK get your access token, please refer to https://learn.microsoft.com/en-us/dotnet/azure/sdk/authentication?tabs=command-line
TokenCredential cred = new DefaultAzureCredential();
// authenticate your client
ArmClient client = new ArmClient(cred);
// this example assumes you already have this CapacityReservationGroupResource created on azure
// for more information of creating CapacityReservationGroupResource, please refer to the document of CapacityReservationGroupResource
string subscriptionId = "{subscriptionId}";
string resourceGroupName = "myResourceGroup";
string capacityReservationGroupName = "targetedCapacityReservationGroup";
ResourceIdentifier capacityReservationGroupResourceId = CapacityReservationGroupResource.CreateResourceIdentifier(subscriptionId, resourceGroupName, capacityReservationGroupName);
CapacityReservationGroupResource capacityReservationGroup = client.GetCapacityReservationGroupResource(capacityReservationGroupResourceId);
// get the collection of this CapacityReservationResource
CapacityReservationCollection collection = capacityReservationGroup.GetCapacityReservations();
// invoke the operation
string capacityReservationName = "targetedCapacityReservation";
CapacityReservationInstanceViewType? expand = CapacityReservationInstanceViewType.InstanceView;
NullableResponse<CapacityReservationResource> response = await collection.GetIfExistsAsync(capacityReservationName, expand: expand);
CapacityReservationResource result = response.HasValue ? response.Value : null;
if (result == null)
{
Console.WriteLine("Succeeded with null as result");
}
else
{
// the variable result is a resource, you could call other operations on this instance as well
// but just for demo, we get its data from this resource instance
CapacityReservationData resourceData = result.Data;
// for demo we just print out the id
Console.WriteLine($"Succeeded on id: {resourceData.Id}");
}
To use the Azure SDK library in your project, see this documentation. To provide feedback on this code sample, open a GitHub issue
Sample response
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/capacityReservationGroups/targetedCapacityReservationGroup/capacityReservations/targetedCapacityReservation",
"properties": {
"platformFaultDomainCount": 3,
"reservationId": "{GUID}",
"provisioningTime": "2021-06-27T01:02:38.3138469+00:00",
"virtualMachinesAssociated": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM2"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM3"
}
],
"provisioningState": "Succeeded",
"instanceView": {
"utilizationInfo": {
"currentCapacity": 5,
"virtualMachinesAllocated": [
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM1"
},
{
"id": "/subscriptions/{subscription-id}/resourceGroups/myResourceGroup/providers/Microsoft.Compute/virtualMachines/myVM2"
}
]
},
"statuses": [
{
"code": "ProvisioningState/succeeded",
"level": "Info",
"displayStatus": "Provisioning succeeded"
}
]
},
"timeCreated": "2021-06-27T01:02:38.3138469+00:00"
},
"location": "westus",
"tags": {
"department": "HR"
},
"sku": {
"name": "Standard_DS1_v2",
"capacity": 4
},
"zones": [
"1"
],
"name": "targetedCapacityReservation"
}
Definitions
| Name |
Description |
|
ApiError
|
Api error.
|
|
ApiErrorBase
|
Api error base.
|
|
CapacityReservation
|
Specifies information about the capacity reservation.
|
|
CapacityReservationInstanceView
|
The instance view of a capacity reservation that provides as snapshot of the runtime properties of the capacity reservation that is managed by the platform and can change outside of control plane operations.
|
|
CapacityReservationInstanceViewTypes
|
|
|
CapacityReservationUtilization
|
Represents the capacity reservation utilization in terms of resources allocated.
|
|
CloudError
|
An error response from the Compute service.
|
|
createdByType
|
The type of identity that created the resource.
|
|
InnerError
|
Inner error details.
|
|
InstanceViewStatus
|
Instance view status.
|
|
ScheduleProfile
|
Defines the schedule for Block-type capacity reservations. Specifies the schedule during which capacity reservation is active and VM or VMSS resource can be allocated using reservation. This property is required and only supported when the capacity reservation group type is 'Block'. The scheduleProfile, start, and end fields are immutable after creation. Minimum API version: 2025-04-01. Please refer to https://aka.ms/blockcapacityreservation for more details.
|
|
Sku
|
Describes a virtual machine scale set sku. NOTE: If the new VM SKU is not supported on the hardware the scale set is currently on, you need to deallocate the VMs in the scale set before you modify the SKU name.
|
|
StatusLevelTypes
|
The level code.
|
|
SubResourceReadOnly
|
|
|
systemData
|
Metadata pertaining to creation and last modification of the resource.
|
ApiError
Object
Api error.
| Name |
Type |
Description |
|
code
|
string
|
The error code.
|
|
details
|
ApiErrorBase[]
|
The Api error details
|
|
innererror
|
InnerError
|
The Api inner error
|
|
message
|
string
|
The error message.
|
|
target
|
string
|
The target of the particular error.
|
ApiErrorBase
Object
Api error base.
| Name |
Type |
Description |
|
code
|
string
|
The error code.
|
|
message
|
string
|
The error message.
|
|
target
|
string
|
The target of the particular error.
|
CapacityReservation
Object
Specifies information about the capacity reservation.
| Name |
Type |
Description |
|
id
|
string
|
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
location
|
string
|
The geo-location where the resource lives
|
|
name
|
string
|
The name of the resource
|
|
properties.instanceView
|
CapacityReservationInstanceView
|
The Capacity reservation instance view.
|
|
properties.platformFaultDomainCount
|
integer
(int32)
|
Specifies the value of fault domain count that Capacity Reservation supports for requested VM size. Note: The fault domain count specified for a resource (like virtual machines scale set) must be less than or equal to this value if it deploys using capacity reservation. Minimum api-version: 2022-08-01.
|
|
properties.provisioningState
|
string
|
The provisioning state, which only appears in the response.
|
|
properties.provisioningTime
|
string
(date-time)
|
The date time when the capacity reservation was last updated.
|
|
properties.reservationId
|
string
|
A unique id generated and assigned to the capacity reservation by the platform which does not change throughout the lifetime of the resource.
|
|
properties.scheduleProfile
|
ScheduleProfile
|
Defines the schedule for Block-type capacity reservations. Specifies the schedule during which capacity reservation is active and VM or VMSS resource can be allocated using reservation. This property is required and only supported when the capacity reservation group type is 'Block'. The scheduleProfile, start, and end fields are immutable after creation. Minimum API version: 2025-04-01. Please refer to https://aka.ms/blockcapacityreservation for more details.
|
|
properties.timeCreated
|
string
(date-time)
|
Specifies the time at which the Capacity Reservation resource was created. Minimum api-version: 2021-11-01.
|
|
properties.virtualMachinesAssociated
|
SubResourceReadOnly[]
|
A list of all virtual machine resource ids that are associated with the capacity reservation.
|
|
sku
|
Sku
|
SKU of the resource for which capacity needs be reserved. The SKU name and capacity is required to be set. For Block capacity reservations, sku.capacity can only accept values 1, 2, 4, 8, 16, 32, 64. Currently VM Skus with the capability called 'CapacityReservationSupported' set to true are supported. When 'CapacityReservationSupported' is true, the SKU capability also specifies the 'SupportedCapacityReservationTypes', which lists the types of capacity reservations (such as Targeted or Block) that the SKU supports. Refer to List Microsoft.Compute SKUs in a region (https://docs.microsoft.com/rest/api/compute/resourceskus/list) for supported values.
|
|
systemData
|
systemData
|
Azure Resource Manager metadata containing createdBy and modifiedBy information.
|
|
tags
|
object
|
Resource tags.
|
|
type
|
string
|
The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts"
|
|
zones
|
string[]
|
The availability zones.
|
CapacityReservationInstanceView
Object
The instance view of a capacity reservation that provides as snapshot of the runtime properties of the capacity reservation that is managed by the platform and can change outside of control plane operations.
CapacityReservationInstanceViewTypes
Enumeration
| Value |
Description |
|
instanceView
|
|
CapacityReservationUtilization
Object
Represents the capacity reservation utilization in terms of resources allocated.
| Name |
Type |
Description |
|
currentCapacity
|
integer
(int32)
|
The value provides the current capacity of the VM size which was reserved successfully and for which the customer is getting billed. Minimum api-version: 2022-08-01.
|
|
virtualMachinesAllocated
|
SubResourceReadOnly[]
|
A list of all virtual machines resource ids allocated against the capacity reservation.
|
CloudError
Object
An error response from the Compute service.
| Name |
Type |
Description |
|
error
|
ApiError
|
Api error.
|
createdByType
Enumeration
The type of identity that created the resource.
| Value |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
InnerError
Object
Inner error details.
| Name |
Type |
Description |
|
errordetail
|
string
|
The internal error message or exception dump.
|
|
exceptiontype
|
string
|
The exception type.
|
InstanceViewStatus
Object
Instance view status.
| Name |
Type |
Description |
|
code
|
string
|
The status code.
|
|
displayStatus
|
string
|
The short localizable label for the status.
|
|
level
|
StatusLevelTypes
|
The level code.
|
|
message
|
string
|
The detailed status message, including for alerts and error messages.
|
|
time
|
string
(date-time)
|
The time of the status.
|
ScheduleProfile
Object
Defines the schedule for Block-type capacity reservations. Specifies the schedule during which capacity reservation is active and VM or VMSS resource can be allocated using reservation. This property is required and only supported when the capacity reservation group type is 'Block'. The scheduleProfile, start, and end fields are immutable after creation. Minimum API version: 2025-04-01. Please refer to https://aka.ms/blockcapacityreservation for more details.
| Name |
Type |
Description |
|
end
|
string
|
The required end date for block capacity reservations. Must be after the start date, with a duration of either 1–14 whole days or 3–26 whole weeks. Example: 2025-06-28.
|
|
start
|
string
|
The required start date for block capacity reservations. Must be today or within 56 days in the future. For same-day scheduling, requests must be submitted before 11:30 AM UTC. Example: 2025-06-27.
|
Sku
Object
Describes a virtual machine scale set sku. NOTE: If the new VM SKU is not supported on the hardware the scale set is currently on, you need to deallocate the VMs in the scale set before you modify the SKU name.
| Name |
Type |
Description |
|
capacity
|
integer
(int64)
|
Specifies the number of virtual machines in the scale set.
|
|
name
|
string
|
The sku name.
|
|
tier
|
string
|
Specifies the tier of virtual machines in a scale set.
Possible Values:
Standard
Basic
|
StatusLevelTypes
Enumeration
The level code.
| Value |
Description |
|
Info
|
|
|
Warning
|
|
|
Error
|
|
SubResourceReadOnly
Object
| Name |
Type |
Description |
|
id
|
string
|
Resource Id
|
systemData
Object
Metadata pertaining to creation and last modification of the resource.
| Name |
Type |
Description |
|
createdAt
|
string
(date-time)
|
The timestamp of resource creation (UTC).
|
|
createdBy
|
string
|
The identity that created the resource.
|
|
createdByType
|
createdByType
|
The type of identity that created the resource.
|
|
lastModifiedAt
|
string
(date-time)
|
The timestamp of resource last modification (UTC)
|
|
lastModifiedBy
|
string
|
The identity that last modified the resource.
|
|
lastModifiedByType
|
createdByType
|
The type of identity that last modified the resource.
|