List of recommendations for purchasing reserved instances.
GET https://management.azure.com/{resourceScope}/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01
With optional parameters:
GET https://management.azure.com/{resourceScope}/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01&$filter={$filter}
URI Parameters
| Name |
In |
Required |
Type |
Description |
|
resourceScope
|
path |
True
|
string
|
The fully qualified Azure Resource manager identifier of the resource.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
The API version to use for this operation.
|
|
$filter
|
query |
string
|
May be used to filter reservationRecommendations by: properties/scope with allowed values ['Single', 'Shared'] and default value 'Single'; properties/resourceType with allowed values ['VirtualMachines', 'SQLDatabases', 'PostgreSQL', 'ManagedDisk', 'MySQL', 'RedHat', 'MariaDB', 'RedisCache', 'CosmosDB', 'SqlDataWarehouse', 'SUSELinux', 'AppService', 'BlockBlob', 'AzureDataExplorer', 'VMwareCloudSimple'] and default value 'VirtualMachines'; and properties/lookBackPeriod with allowed values ['Last7Days', 'Last30Days', 'Last60Days'] and default value 'Last7Days'.
|
Responses
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
ReservationRecommendationsByBillingAccount-Legacy
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python reservation_recommendations_by_billing_account.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 = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.reservation_recommendations.list(
resource_scope="providers/Microsoft.Billing/billingAccounts/123456",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/ReservationRecommendationsByBillingAccount.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 armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ReservationRecommendationsByBillingAccount.json
func ExampleReservationRecommendationsClient_NewListPager_reservationRecommendationsByBillingAccountLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewReservationRecommendationsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/123456", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.ReservationRecommendationsClientListResponse{
// ReservationRecommendationsListResult: armconsumption.ReservationRecommendationsListResult{
// NextLink: to.Ptr("https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01&$skiptoken=AQAAAA%3D%3D&"),
// Value: []armconsumption.ReservationRecommendationClassification{
// &armconsumption.LegacyReservationRecommendation{
// Name: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"),
// ID: to.Ptr("billingAccount/123456/providers/Microsoft.Consumption/reservationRecommendations/00000000-0000-0000-0000-000000000000"),
// Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy),
// Location: to.Ptr("westus"),
// Properties: &armconsumption.LegacySharedScopeReservationRecommendationProperties{
// FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-07T00:00:00-07:00"); return t}()),
// InstanceFlexibilityGroup: to.Ptr("DSv2 Series"),
// InstanceFlexibilityRatio: to.Ptr[float32](1),
// LastUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-07T00:00:00-07:00"); return t}()),
// LookBackPeriod: to.Ptr("Last7Days"),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// NormalizedSize: to.Ptr("Standard_DS1_v2"),
// RecommendedQuantityNormalized: to.Ptr[float32](1),
// Scope: to.Ptr("Shared"),
// SKUProperties: []*armconsumption.SKUProperty{
// {
// Name: to.Ptr("Cores"),
// Value: to.Ptr("1"),
// },
// {
// Name: to.Ptr("Ram"),
// Value: to.Ptr("1"),
// },
// },
// Term: to.Ptr("P1Y"),
// TotalHours: to.Ptr[int32](701),
// },
// SKU: to.Ptr("Standard_DS1_v2"),
// },
// &armconsumption.LegacyReservationRecommendation{
// Name: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"),
// ID: to.Ptr("billingAccount/123456/providers/Microsoft.Consumption/reservationRecommendations/00000000-0000-0000-0000-000000000000"),
// Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy),
// Location: to.Ptr("westus"),
// Properties: &armconsumption.LegacySharedScopeReservationRecommendationProperties{
// FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-07-07T00:00:00-07:00"); return t}()),
// InstanceFlexibilityGroup: to.Ptr("DSv2 Series"),
// InstanceFlexibilityRatio: to.Ptr[float32](1),
// LastUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2019-08-09T00:00:00-07:00"); return t}()),
// LookBackPeriod: to.Ptr("Last7Days"),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// NormalizedSize: to.Ptr("Standard_DS1"),
// RecommendedQuantityNormalized: to.Ptr[float32](1.2),
// Scope: to.Ptr("Shared"),
// SKUProperties: []*armconsumption.SKUProperty{
// {
// Name: to.Ptr("SkuDisplayName"),
// Value: to.Ptr("B"),
// },
// {
// Name: to.Ptr("CPU"),
// Value: to.Ptr("1"),
// },
// },
// Term: to.Ptr("P1Y"),
// TotalHours: to.Ptr[int32](805),
// },
// SKU: to.Ptr("Standard_DS1_v2"),
// },
// },
// },
// }
}
}
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
{
"nextLink": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01&$skiptoken=AQAAAA%3D%3D&",
"value": [
{
"name": "00000000-0000-0000-0000-000000000000",
"type": "Microsoft.Consumption/reservationRecommendations",
"id": "billingAccount/123456/providers/Microsoft.Consumption/reservationRecommendations/00000000-0000-0000-0000-000000000000",
"kind": "legacy",
"location": "westus",
"properties": {
"costWithNoReservedInstances": 12.0785105,
"firstUsageDate": "2019-07-07T00:00:00-07:00",
"instanceFlexibilityGroup": "DSv2 Series",
"instanceFlexibilityRatio": 1,
"lastUsageDate": "2019-08-07T00:00:00-07:00",
"lookBackPeriod": "Last7Days",
"meterId": "00000000-0000-0000-0000-000000000000",
"netSavings": 0.588546019225182,
"normalizedSize": "Standard_DS1_v2",
"recommendedQuantity": 1,
"recommendedQuantityNormalized": 1,
"scope": "Shared",
"skuProperties": [
{
"name": "Cores",
"value": "1"
},
{
"name": "Ram",
"value": "1"
}
],
"term": "P1Y",
"totalCostWithReservedInstances": 11.4899644807748,
"totalHours": 701
},
"sku": "Standard_DS1_v2"
},
{
"name": "00000000-0000-0000-0000-000000000000",
"type": "Microsoft.Consumption/reservationRecommendations",
"id": "billingAccount/123456/providers/Microsoft.Consumption/reservationRecommendations/00000000-0000-0000-0000-000000000000",
"kind": "legacy",
"location": "westus",
"properties": {
"costWithNoReservedInstances": 10.0785105,
"firstUsageDate": "2019-07-07T00:00:00-07:00",
"instanceFlexibilityGroup": "DSv2 Series",
"instanceFlexibilityRatio": 1,
"lastUsageDate": "2019-08-09T00:00:00-07:00",
"lookBackPeriod": "Last7Days",
"meterId": "00000000-0000-0000-0000-000000000000",
"netSavings": 0.68,
"normalizedSize": "Standard_DS1",
"recommendedQuantity": 1,
"recommendedQuantityNormalized": 1.2,
"scope": "Shared",
"skuProperties": [
{
"name": "SkuDisplayName",
"value": "B"
},
{
"name": "CPU",
"value": "1"
}
],
"term": "P1Y",
"totalCostWithReservedInstances": 13.48,
"totalHours": 805
},
"sku": "Standard_DS1_v2"
}
]
}
ReservationRecommendationsByBillingAccountFilterForScope
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/123456/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01&$filter=properties/scope eq 'Single'
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python reservation_recommendations_by_billing_account_filter_by_scope.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 = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.reservation_recommendations.list(
resource_scope="providers/Microsoft.Billing/billingAccounts/123456",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/ReservationRecommendationsByBillingAccountFilterByScope.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 armconsumption_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/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ReservationRecommendationsByBillingAccountFilterByScope.json
func ExampleReservationRecommendationsClient_NewListPager_reservationRecommendationsByBillingAccountFilterForScope() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewReservationRecommendationsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/123456", &armconsumption.ReservationRecommendationsClientListOptions{
Filter: to.Ptr("properties/scope eq 'Single'")})
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.ReservationRecommendationsClientListResponse{
// ReservationRecommendationsListResult: armconsumption.ReservationRecommendationsListResult{
// Value: []armconsumption.ReservationRecommendationClassification{
// &armconsumption.LegacyReservationRecommendation{
// Name: to.Ptr("71fd91a7-13b9-4ade-bb11-85cfd6422d9d"),
// Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"),
// ID: to.Ptr("billingAccount/123456/providers/Microsoft.Consumption/reservationRecommendations/71fd91a7-13b9-4ade-bb11-85cfd6422d9d"),
// Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy),
// Location: to.Ptr("westus3"),
// Properties: &armconsumption.LegacySingleScopeReservationRecommendationProperties{
// FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-30T07:00:00Z"); return t}()),
// InstanceFlexibilityGroup: to.Ptr("BS Series High Memory"),
// InstanceFlexibilityRatio: to.Ptr[float32](8),
// LookBackPeriod: to.Ptr("Last7Days"),
// MeterID: to.Ptr("9a3781ce-d0dc-5f76-99d7-29eb5aec447f"),
// NormalizedSize: to.Ptr("Standard_B1ms"),
// RecommendedQuantityNormalized: to.Ptr[float32](8),
// ResourceType: to.Ptr("virtualmachines"),
// Scope: to.Ptr("Single"),
// SKUProperties: []*armconsumption.SKUProperty{
// },
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Term: to.Ptr("P1Y"),
// },
// SKU: to.Ptr("Standard_B4ms"),
// },
// &armconsumption.LegacyReservationRecommendation{
// Name: to.Ptr("904b99c2-baf3-4bff-98ff-a96238ccbc96"),
// Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"),
// ID: to.Ptr("billingAccount/123456/providers/Microsoft.Consumption/reservationRecommendations/904b99c2-baf3-4bff-98ff-a96238ccbc96"),
// Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy),
// Location: to.Ptr("westus3"),
// Properties: &armconsumption.LegacySingleScopeReservationRecommendationProperties{
// FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2024-04-30T07:00:00Z"); return t}()),
// InstanceFlexibilityGroup: to.Ptr("BS Series High Memory"),
// InstanceFlexibilityRatio: to.Ptr[float32](8),
// LookBackPeriod: to.Ptr("Last7Days"),
// MeterID: to.Ptr("9a3781ce-d0dc-5f76-99d7-29eb5aec447f"),
// NormalizedSize: to.Ptr("Standard_B1ms"),
// RecommendedQuantityNormalized: to.Ptr[float32](8),
// ResourceType: to.Ptr("virtualmachines"),
// Scope: to.Ptr("Single"),
// SKUProperties: []*armconsumption.SKUProperty{
// },
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Term: to.Ptr("P3Y"),
// },
// SKU: to.Ptr("Standard_B4ms"),
// },
// },
// },
// }
}
}
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
{
"value": [
{
"name": "71fd91a7-13b9-4ade-bb11-85cfd6422d9d",
"type": "Microsoft.Consumption/reservationRecommendations",
"id": "billingAccount/123456/providers/Microsoft.Consumption/reservationRecommendations/71fd91a7-13b9-4ade-bb11-85cfd6422d9d",
"kind": "legacy",
"location": "westus3",
"properties": {
"costWithNoReservedInstances": 0.332,
"firstUsageDate": "2024-04-30T07:00:00Z",
"instanceFlexibilityGroup": "BS Series High Memory",
"instanceFlexibilityRatio": 8,
"lookBackPeriod": "Last7Days",
"meterId": "9a3781ce-d0dc-5f76-99d7-29eb5aec447f",
"netSavings": 0.13725114155251145,
"normalizedSize": "Standard_B1ms",
"recommendedQuantity": 1,
"recommendedQuantityNormalized": 8,
"resourceType": "virtualmachines",
"scope": "Single",
"skuProperties": [],
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"term": "P1Y",
"totalCostWithReservedInstances": 0.19474885844748857
},
"sku": "Standard_B4ms"
},
{
"name": "904b99c2-baf3-4bff-98ff-a96238ccbc96",
"type": "Microsoft.Consumption/reservationRecommendations",
"id": "billingAccount/123456/providers/Microsoft.Consumption/reservationRecommendations/904b99c2-baf3-4bff-98ff-a96238ccbc96",
"kind": "legacy",
"location": "westus3",
"properties": {
"costWithNoReservedInstances": 0.332,
"firstUsageDate": "2024-04-30T07:00:00Z",
"instanceFlexibilityGroup": "BS Series High Memory",
"instanceFlexibilityRatio": 8,
"lookBackPeriod": "Last7Days",
"meterId": "9a3781ce-d0dc-5f76-99d7-29eb5aec447f",
"netSavings": 0.20688584474885846,
"normalizedSize": "Standard_B1ms",
"recommendedQuantity": 1,
"recommendedQuantityNormalized": 8,
"resourceType": "virtualmachines",
"scope": "Single",
"skuProperties": [],
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"term": "P3Y",
"totalCostWithReservedInstances": 0.12511415525114156
},
"sku": "Standard_B4ms"
}
]
}
ReservationRecommendationsByBillingProfile-Modern
Sample request
GET https://management.azure.com/providers/Microsoft.Billing/billingAccounts/123456/billingProfiles/6420/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python reservation_recommendations_by_billing_profile.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 = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.reservation_recommendations.list(
resource_scope="providers/Microsoft.Billing/billingAccounts/123456/billingProfiles/6420",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/ReservationRecommendationsByBillingProfile.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 armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ReservationRecommendationsByBillingProfile.json
func ExampleReservationRecommendationsClient_NewListPager_reservationRecommendationsByBillingProfileModern() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewReservationRecommendationsClient().NewListPager("providers/Microsoft.Billing/billingAccounts/123456/billingProfiles/6420", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.ReservationRecommendationsClientListResponse{
// ReservationRecommendationsListResult: armconsumption.ReservationRecommendationsListResult{
// NextLink: to.Ptr("https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01&$skiptoken=AQAAAA%3D%3D&"),
// Value: []armconsumption.ReservationRecommendationClassification{
// &armconsumption.ModernReservationRecommendation{
// Name: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/billingProfiles/6420/providers/Microsoft.Consumption/reservationRecommendations/00000000-0000-0000-0000-000000000000"),
// Kind: to.Ptr(armconsumption.ReservationRecommendationKindModern),
// Properties: &armconsumption.ModernSingleScopeReservationRecommendationProperties{
// CostWithNoReservedInstances: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-22T00:00:00Z"); return t}()),
// InstanceFlexibilityGroup: to.Ptr("NA"),
// InstanceFlexibilityRatio: to.Ptr[float32](1),
// LastUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-09-22T00:00:00Z"); return t}()),
// Location: to.Ptr("westus2"),
// LookBackPeriod: to.Ptr[int32](60),
// MeterID: to.Ptr("30f7049a-b092-42f4-9173-9ec31ab945ad"),
// NetSavings: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// NormalizedSize: to.Ptr("SQLDB_BC_Compute_Gen5"),
// RecommendedQuantityNormalized: to.Ptr[float32](35),
// ResourceType: to.Ptr("sqldatabases"),
// Scope: to.Ptr("Single"),
// SKUName: to.Ptr("SQLDB_BC_Compute_Gen5"),
// SubscriptionID: to.Ptr("c6aa8a01-a744-44a7-a4f1-caad17512f27"),
// Term: to.Ptr("P3Y"),
// TotalCostWithReservedInstances: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// TotalHours: to.Ptr[int32](717),
// },
// },
// &armconsumption.ModernReservationRecommendation{
// Name: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"),
// ID: to.Ptr("/providers/Microsoft.Billing/billingAccounts/123456/billingProfiles/6420/providers/Microsoft.Consumption/reservationRecommendations/00000000-0000-0000-0000-000000000000"),
// Kind: to.Ptr(armconsumption.ReservationRecommendationKindModern),
// Properties: &armconsumption.ModernSingleScopeReservationRecommendationProperties{
// CostWithNoReservedInstances: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-22T00:00:00Z"); return t}()),
// InstanceFlexibilityGroup: to.Ptr("NA"),
// InstanceFlexibilityRatio: to.Ptr[float32](1),
// LastUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2022-08-27T00:00:00Z"); return t}()),
// Location: to.Ptr("westus2"),
// LookBackPeriod: to.Ptr[int32](60),
// MeterID: to.Ptr("30f7049a-b092-42f4-9173-9ec31ab945ad"),
// NetSavings: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// NormalizedSize: to.Ptr("SQLDB_BC_Compute_Gen5"),
// RecommendedQuantityNormalized: to.Ptr[float32](35),
// ResourceType: to.Ptr("sqldatabases"),
// Scope: to.Ptr("Single"),
// SKUName: to.Ptr("SQLDB_BC_Compute_Gen5"),
// SubscriptionID: to.Ptr("c6aa8a01-a744-44a7-a4f1-caad17512f27"),
// Term: to.Ptr("P1Y"),
// TotalCostWithReservedInstances: &armconsumption.Amount{
// Currency: to.Ptr("USD"),
// },
// TotalHours: to.Ptr[int32](527),
// },
// },
// },
// },
// }
}
}
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
{
"nextLink": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01&$skiptoken=AQAAAA%3D%3D&",
"value": [
{
"name": "00000000-0000-0000-0000-000000000000",
"type": "Microsoft.Consumption/reservationRecommendations",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/billingProfiles/6420/providers/Microsoft.Consumption/reservationRecommendations/00000000-0000-0000-0000-000000000000",
"kind": "modern",
"properties": {
"costWithNoReservedInstances": {
"currency": "USD",
"value": 279881.9457795231
},
"firstUsageDate": "2022-08-22T00:00:00Z",
"instanceFlexibilityGroup": "NA",
"instanceFlexibilityRatio": 1,
"lastUsageDate": "2022-09-22T00:00:00Z",
"location": "westus2",
"lookBackPeriod": 60,
"meterId": "30f7049a-b092-42f4-9173-9ec31ab945ad",
"netSavings": {
"currency": "USD",
"value": 153766.87728637524
},
"normalizedSize": "SQLDB_BC_Compute_Gen5",
"recommendedQuantity": 35,
"recommendedQuantityNormalized": 35,
"resourceType": "sqldatabases",
"scope": "Single",
"skuName": "SQLDB_BC_Compute_Gen5",
"skuProperties": null,
"subscriptionId": "c6aa8a01-a744-44a7-a4f1-caad17512f27",
"term": "P3Y",
"totalCostWithReservedInstances": {
"currency": "USD",
"value": 126115.06849314792
},
"totalHours": 717
}
},
{
"name": "00000000-0000-0000-0000-000000000000",
"type": "Microsoft.Consumption/reservationRecommendations",
"id": "/providers/Microsoft.Billing/billingAccounts/123456/billingProfiles/6420/providers/Microsoft.Consumption/reservationRecommendations/00000000-0000-0000-0000-000000000000",
"kind": "modern",
"properties": {
"costWithNoReservedInstances": {
"currency": "USD",
"value": 93208.8596802244
},
"firstUsageDate": "2022-08-22T00:00:00Z",
"instanceFlexibilityGroup": "NA",
"instanceFlexibilityRatio": 1,
"lastUsageDate": "2022-08-27T00:00:00Z",
"location": "westus2",
"lookBackPeriod": 60,
"meterId": "30f7049a-b092-42f4-9173-9ec31ab945ad",
"netSavings": {
"currency": "USD",
"value": 32553.85968022456
},
"normalizedSize": "SQLDB_BC_Compute_Gen5",
"recommendedQuantity": 35,
"recommendedQuantityNormalized": 35,
"resourceType": "sqldatabases",
"scope": "Single",
"skuName": "SQLDB_BC_Compute_Gen5",
"skuProperties": null,
"subscriptionId": "c6aa8a01-a744-44a7-a4f1-caad17512f27",
"term": "P1Y",
"totalCostWithReservedInstances": {
"currency": "USD",
"value": 60654.99999999984
},
"totalHours": 527
}
}
]
}
ReservationRecommendationsByResourceGroup-Legacy
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python reservation_recommendations_by_resource_group.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 = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.reservation_recommendations.list(
resource_scope="subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/ReservationRecommendationsByResourceGroup.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 armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ReservationRecommendationsByResourceGroup.json
func ExampleReservationRecommendationsClient_NewListPager_reservationRecommendationsByResourceGroupLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewReservationRecommendationsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.ReservationRecommendationsClientListResponse{
// ReservationRecommendationsListResult: armconsumption.ReservationRecommendationsListResult{
// NextLink: to.Ptr("https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01&$skiptoken=AQAAAA%3D%3D&"),
// Value: []armconsumption.ReservationRecommendationClassification{
// &armconsumption.LegacyReservationRecommendation{
// Name: to.Ptr("reservationRecommendations1"),
// Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"),
// ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGrouups/testGroup/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations1"),
// Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy),
// Location: to.Ptr("northeurope"),
// Properties: &armconsumption.LegacySingleScopeReservationRecommendationProperties{
// FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-06T00:00:00Z"); return t}()),
// LastUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-08T00:00:00Z"); return t}()),
// LookBackPeriod: to.Ptr("Last7Days"),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Scope: to.Ptr("Single"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Term: to.Ptr("P1Y"),
// TotalHours: to.Ptr[int32](427),
// },
// SKU: to.Ptr("Standard_DS1_v2"),
// },
// &armconsumption.LegacyReservationRecommendation{
// Name: to.Ptr("reservationRecommendations2"),
// Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"),
// ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations2"),
// Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy),
// Location: to.Ptr("northeurope"),
// Properties: &armconsumption.LegacySingleScopeReservationRecommendationProperties{
// FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-06T00:00:00Z"); return t}()),
// LastUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-09T00:00:00Z"); return t}()),
// LookBackPeriod: to.Ptr("Last7Days"),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Scope: to.Ptr("Single"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Term: to.Ptr("P3Y"),
// TotalHours: to.Ptr[int32](327),
// },
// SKU: to.Ptr("Standard_DS1_v2"),
// },
// },
// },
// }
}
}
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
{
"nextLink": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01&$skiptoken=AQAAAA%3D%3D&",
"value": [
{
"name": "reservationRecommendations1",
"type": "Microsoft.Consumption/reservationRecommendations",
"id": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGrouups/testGroup/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations1",
"kind": "legacy",
"location": "northeurope",
"properties": {
"costWithNoReservedInstances": 0,
"firstUsageDate": "2018-03-06T00:00:00Z",
"lastUsageDate": "2018-03-08T00:00:00Z",
"lookBackPeriod": "Last7Days",
"meterId": "00000000-0000-0000-0000-000000000000",
"netSavings": 4.634521202630137,
"recommendedQuantity": 1,
"scope": "Single",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"term": "P1Y",
"totalCostWithReservedInstances": 0,
"totalHours": 427
},
"sku": "Standard_DS1_v2"
},
{
"name": "reservationRecommendations2",
"type": "Microsoft.Consumption/reservationRecommendations",
"id": "subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/testGroup/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations2",
"kind": "legacy",
"location": "northeurope",
"properties": {
"costWithNoReservedInstances": 0,
"firstUsageDate": "2018-03-06T00:00:00Z",
"lastUsageDate": "2018-03-09T00:00:00Z",
"lookBackPeriod": "Last7Days",
"meterId": "00000000-0000-0000-0000-000000000000",
"netSavings": 7.289315723178081,
"recommendedQuantity": 1,
"scope": "Single",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"term": "P3Y",
"totalCostWithReservedInstances": 0,
"totalHours": 327
},
"sku": "Standard_DS1_v2"
}
]
}
ReservationRecommendationsBySubscription-Legacy
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python reservation_recommendations_by_subscription.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 = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.reservation_recommendations.list(
resource_scope="subscriptions/00000000-0000-0000-0000-000000000000",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/ReservationRecommendationsBySubscription.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 armconsumption_test
import (
"context"
"log"
"github.com/Azure/azure-sdk-for-go/sdk/azidentity"
"github.com/Azure/azure-sdk-for-go/sdk/resourcemanager/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ReservationRecommendationsBySubscription.json
func ExampleReservationRecommendationsClient_NewListPager_reservationRecommendationsBySubscriptionLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewReservationRecommendationsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", nil)
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.ReservationRecommendationsClientListResponse{
// ReservationRecommendationsListResult: armconsumption.ReservationRecommendationsListResult{
// NextLink: to.Ptr("https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01&$skiptoken=AQAAAA%3D%3D&"),
// Value: []armconsumption.ReservationRecommendationClassification{
// &armconsumption.LegacyReservationRecommendation{
// Name: to.Ptr("reservationRecommendations1"),
// Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"),
// ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations1"),
// Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy),
// Location: to.Ptr("northeurope"),
// Properties: &armconsumption.LegacySingleScopeReservationRecommendationProperties{
// FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-06T00:00:00Z"); return t}()),
// LastUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-10T00:00:00Z"); return t}()),
// LookBackPeriod: to.Ptr("Last7Days"),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Scope: to.Ptr("Single"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Term: to.Ptr("P1Y"),
// TotalHours: to.Ptr[int32](827),
// },
// SKU: to.Ptr("Standard_DS1_v2"),
// },
// &armconsumption.LegacyReservationRecommendation{
// Name: to.Ptr("reservationRecommendations2"),
// Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"),
// ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations2"),
// Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy),
// Location: to.Ptr("northeurope"),
// Properties: &armconsumption.LegacySingleScopeReservationRecommendationProperties{
// FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-06T00:00:00Z"); return t}()),
// LastUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-15T00:00:00Z"); return t}()),
// LookBackPeriod: to.Ptr("Last7Days"),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Scope: to.Ptr("Single"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Term: to.Ptr("P3Y"),
// TotalHours: to.Ptr[int32](927),
// },
// SKU: to.Ptr("Standard_DS1_v2"),
// },
// },
// },
// }
}
}
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
{
"nextLink": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01&$skiptoken=AQAAAA%3D%3D&",
"value": [
{
"name": "reservationRecommendations1",
"type": "Microsoft.Consumption/reservationRecommendations",
"id": "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations1",
"kind": "legacy",
"location": "northeurope",
"properties": {
"costWithNoReservedInstances": 0,
"firstUsageDate": "2018-03-06T00:00:00Z",
"lastUsageDate": "2018-03-10T00:00:00Z",
"lookBackPeriod": "Last7Days",
"meterId": "00000000-0000-0000-0000-000000000000",
"netSavings": 4.634521202630137,
"recommendedQuantity": 1,
"scope": "Single",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"term": "P1Y",
"totalCostWithReservedInstances": 0,
"totalHours": 827
},
"sku": "Standard_DS1_v2"
},
{
"name": "reservationRecommendations2",
"type": "Microsoft.Consumption/reservationRecommendations",
"id": "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations2",
"kind": "legacy",
"location": "northeurope",
"properties": {
"costWithNoReservedInstances": 0,
"firstUsageDate": "2018-03-06T00:00:00Z",
"lastUsageDate": "2018-03-15T00:00:00Z",
"lookBackPeriod": "Last7Days",
"meterId": "00000000-0000-0000-0000-000000000000",
"netSavings": 7.289315723178081,
"recommendedQuantity": 1,
"scope": "Single",
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"term": "P3Y",
"totalCostWithReservedInstances": 0,
"totalHours": 927
},
"sku": "Standard_DS1_v2"
}
]
}
ReservationRecommendationsFilterBySubscriptionForScopeLookBackPeriod-Legacy
Sample request
GET https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01&$filter=properties/scope eq 'Single' AND properties/lookBackPeriod eq 'Last7Days'
from azure.identity import DefaultAzureCredential
from azure.mgmt.consumption import ConsumptionManagementClient
"""
# PREREQUISITES
pip install azure-identity
pip install azure-mgmt-consumption
# USAGE
python reservation_recommendations_filter_by_subscription_for_scope_look_back_period.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 = ConsumptionManagementClient(
credential=DefaultAzureCredential(),
subscription_id="SUBSCRIPTION_ID",
)
response = client.reservation_recommendations.list(
resource_scope="subscriptions/00000000-0000-0000-0000-000000000000",
)
for item in response:
print(item)
# x-ms-original-file: 2024-08-01/ReservationRecommendationsFilterBySubscriptionForScopeLookBackPeriod.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 armconsumption_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/consumption/armconsumption/v2"
)
// Generated from example definition: 2024-08-01/ReservationRecommendationsFilterBySubscriptionForScopeLookBackPeriod.json
func ExampleReservationRecommendationsClient_NewListPager_reservationRecommendationsFilterBySubscriptionForScopeLookBackPeriodLegacy() {
cred, err := azidentity.NewDefaultAzureCredential(nil)
if err != nil {
log.Fatalf("failed to obtain a credential: %v", err)
}
ctx := context.Background()
clientFactory, err := armconsumption.NewClientFactory("<subscriptionID>", cred, nil)
if err != nil {
log.Fatalf("failed to create client: %v", err)
}
pager := clientFactory.NewReservationRecommendationsClient().NewListPager("subscriptions/00000000-0000-0000-0000-000000000000", &armconsumption.ReservationRecommendationsClientListOptions{
Filter: to.Ptr("properties/scope eq 'Single' AND properties/lookBackPeriod eq 'Last7Days'")})
for pager.More() {
page, err := pager.NextPage(ctx)
if err != nil {
log.Fatalf("failed to advance page: %v", err)
}
for _, v := range page.Value {
// You could use page here. We use blank identifier for just demo purposes.
_ = v
}
// If the HTTP response code is 200 as defined in example definition, your page structure would look as follows. Please pay attention that all the values in the output are fake values for just demo purposes.
// page = armconsumption.ReservationRecommendationsClientListResponse{
// ReservationRecommendationsListResult: armconsumption.ReservationRecommendationsListResult{
// NextLink: to.Ptr("https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01&$filter=properties/scope+eq+'Single'+AND+properties/lookBackPeriod+eq+'Last7Days'&$skiptoken=AQAAAA%3D%3D&"),
// Value: []armconsumption.ReservationRecommendationClassification{
// &armconsumption.LegacyReservationRecommendation{
// Name: to.Ptr("reservationRecommendations1"),
// Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"),
// ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations1"),
// Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy),
// Location: to.Ptr("northeurope"),
// Properties: &armconsumption.LegacySingleScopeReservationRecommendationProperties{
// FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-06T00:00:00Z"); return t}()),
// LastUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-15T00:00:00Z"); return t}()),
// LookBackPeriod: to.Ptr("Last7Days"),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Scope: to.Ptr("Single"),
// SKUProperties: []*armconsumption.SKUProperty{
// {
// Name: to.Ptr("Cores"),
// Value: to.Ptr("1"),
// },
// {
// Name: to.Ptr("Ram"),
// Value: to.Ptr("1"),
// },
// },
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Term: to.Ptr("P1Y"),
// TotalHours: to.Ptr[int32](527),
// },
// SKU: to.Ptr("Standard_DS1_v2"),
// },
// &armconsumption.LegacyReservationRecommendation{
// Name: to.Ptr("reservationRecommendations2"),
// Type: to.Ptr("Microsoft.Consumption/reservationRecommendations"),
// ID: to.Ptr("subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations2"),
// Kind: to.Ptr(armconsumption.ReservationRecommendationKindLegacy),
// Location: to.Ptr("northeurope"),
// Properties: &armconsumption.LegacySingleScopeReservationRecommendationProperties{
// FirstUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-06T00:00:00Z"); return t}()),
// LastUsageDate: to.Ptr(func() time.Time { t, _ := time.Parse(time.RFC3339Nano, "2018-03-08T00:00:00Z"); return t}()),
// LookBackPeriod: to.Ptr("Last7Days"),
// MeterID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Scope: to.Ptr("Single"),
// SKUProperties: []*armconsumption.SKUProperty{
// {
// Name: to.Ptr("SkuDisplayName"),
// Value: to.Ptr("B"),
// },
// {
// Name: to.Ptr("CPU"),
// Value: to.Ptr("1"),
// },
// },
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Term: to.Ptr("P3Y"),
// TotalHours: to.Ptr[int32](427),
// },
// SKU: to.Ptr("Standard_DS1_v2"),
// },
// },
// },
// }
}
}
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
{
"nextLink": "https://management.azure.com/subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01&$filter=properties/scope+eq+'Single'+AND+properties/lookBackPeriod+eq+'Last7Days'&$skiptoken=AQAAAA%3D%3D&",
"value": [
{
"name": "reservationRecommendations1",
"type": "Microsoft.Consumption/reservationRecommendations",
"id": "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations1",
"kind": "legacy",
"location": "northeurope",
"properties": {
"costWithNoReservedInstances": 0,
"firstUsageDate": "2018-03-06T00:00:00Z",
"lastUsageDate": "2018-03-15T00:00:00Z",
"lookBackPeriod": "Last7Days",
"meterId": "00000000-0000-0000-0000-000000000000",
"netSavings": 4.634521202630137,
"recommendedQuantity": 1,
"scope": "Single",
"skuProperties": [
{
"name": "Cores",
"value": "1"
},
{
"name": "Ram",
"value": "1"
}
],
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"term": "P1Y",
"totalCostWithReservedInstances": 0,
"totalHours": 527
},
"sku": "Standard_DS1_v2"
},
{
"name": "reservationRecommendations2",
"type": "Microsoft.Consumption/reservationRecommendations",
"id": "subscriptions/00000000-0000-0000-0000-000000000000/providers/Microsoft.Consumption/reservationRecommendations/reservationRecommendations2",
"kind": "legacy",
"location": "northeurope",
"properties": {
"costWithNoReservedInstances": 0,
"firstUsageDate": "2018-03-06T00:00:00Z",
"lastUsageDate": "2018-03-08T00:00:00Z",
"lookBackPeriod": "Last7Days",
"meterId": "00000000-0000-0000-0000-000000000000",
"netSavings": 7.289315723178081,
"recommendedQuantity": 1,
"scope": "Single",
"skuProperties": [
{
"name": "SkuDisplayName",
"value": "B"
},
{
"name": "CPU",
"value": "1"
}
],
"subscriptionId": "00000000-0000-0000-0000-000000000000",
"term": "P3Y",
"totalCostWithReservedInstances": 0,
"totalHours": 427
},
"sku": "Standard_DS1_v2"
}
]
}
Definitions
amount
Object
The amount plus currency .
| Name |
Type |
Description |
|
currency
|
string
|
Amount currency.
|
|
value
|
number
(decimal)
|
Amount.
|
createdByType
Enumeration
The type of identity that created the resource.
| Value |
Description |
|
User
|
|
Application
|
|
ManagedIdentity
|
|
Key
|
ErrorAdditionalInfo
Object
The resource management error additional info.
| Name |
Type |
Description |
|
info
|
object
|
The additional info.
|
|
type
|
string
|
The additional info type.
|
ErrorDetail
Object
The error detail.
| Name |
Type |
Description |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
The error additional info.
|
|
code
|
string
|
The error code.
|
|
details
|
ErrorDetail[]
|
The error details.
|
|
message
|
string
|
The error message.
|
|
target
|
string
|
The error target.
|
ErrorResponse
Object
Error response
| Name |
Type |
Description |
|
error
|
ErrorDetail
|
The error object.
|
LegacyReservationRecommendation
Object
Legacy reservation recommendation.
| Name |
Type |
Description |
|
etag
|
string
|
The etag for the resource.
|
|
id
|
string
|
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
kind
|
string:
legacy
|
Specifies the kind of reservation recommendation.
|
|
location
|
string
|
Resource location
|
|
name
|
string
|
The name of the resource
|
|
properties
|
LegacyReservationRecommendationProperties:
|
Properties for legacy reservation recommendation
|
|
sku
|
string
|
Resource sku
|
|
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"
|
LegacySharedScopeReservationRecommendationProperties
Object
The properties of the legacy reservation recommendation for shared scope.
| Name |
Type |
Description |
|
costWithNoReservedInstances
|
number
(decimal)
|
The total amount of cost without reserved instances.
|
|
firstUsageDate
|
string
(date-time)
|
The usage date for looking back.
|
|
instanceFlexibilityGroup
|
string
|
The instance Flexibility Group.
|
|
instanceFlexibilityRatio
|
number
(float)
|
The instance Flexibility Ratio.
|
|
lastUsageDate
|
string
(date-time)
|
The last usage date used for looking back for computing the recommendation.
|
|
lookBackPeriod
|
string
|
The number of days of usage to look back for recommendation.
|
|
meterId
|
string
(uuid)
|
The meter id (GUID)
|
|
netSavings
|
number
(decimal)
|
Total estimated savings with reserved instances.
|
|
normalizedSize
|
string
|
The normalized Size.
|
|
recommendedQuantity
|
number
(decimal)
|
Recommended quality for reserved instances.
|
|
recommendedQuantityNormalized
|
number
(float)
|
The recommended Quantity Normalized.
|
|
resourceType
|
string
|
The azure resource type.
|
|
scope
|
string:
Shared
|
Shared or single recommendation.
|
|
skuProperties
|
SkuProperty[]
|
List of sku properties
|
|
term
|
string
|
Term period of the reservation. ex: P1M, P1Y or P3Y.
|
|
totalCostWithReservedInstances
|
number
(decimal)
|
The total amount of cost with reserved instances.
|
|
totalHours
|
integer
(int32)
|
The total hours for which the cost is covered.
|
LegacySingleScopeReservationRecommendationProperties
Object
The properties of the legacy reservation recommendation for single scope.
| Name |
Type |
Description |
|
costWithNoReservedInstances
|
number
(decimal)
|
The total amount of cost without reserved instances.
|
|
firstUsageDate
|
string
(date-time)
|
The usage date for looking back.
|
|
instanceFlexibilityGroup
|
string
|
The instance Flexibility Group.
|
|
instanceFlexibilityRatio
|
number
(float)
|
The instance Flexibility Ratio.
|
|
lastUsageDate
|
string
(date-time)
|
The last usage date used for looking back for computing the recommendation.
|
|
lookBackPeriod
|
string
|
The number of days of usage to look back for recommendation.
|
|
meterId
|
string
(uuid)
|
The meter id (GUID)
|
|
netSavings
|
number
(decimal)
|
Total estimated savings with reserved instances.
|
|
normalizedSize
|
string
|
The normalized Size.
|
|
recommendedQuantity
|
number
(decimal)
|
Recommended quality for reserved instances.
|
|
recommendedQuantityNormalized
|
number
(float)
|
The recommended Quantity Normalized.
|
|
resourceType
|
string
|
The azure resource type.
|
|
scope
|
string:
Single
|
Shared or single recommendation.
|
|
skuProperties
|
SkuProperty[]
|
List of sku properties
|
|
subscriptionId
|
string
(uuid)
|
Subscription id associated with single scoped recommendation.
|
|
term
|
string
|
Term period of the reservation. ex: P1M, P1Y or P3Y.
|
|
totalCostWithReservedInstances
|
number
(decimal)
|
The total amount of cost with reserved instances.
|
|
totalHours
|
integer
(int32)
|
The total hours for which the cost is covered.
|
ModernReservationRecommendation
Object
Modern reservation recommendation.
| Name |
Type |
Description |
|
etag
|
string
|
The etag for the resource.
|
|
id
|
string
|
Fully qualified resource ID for the resource. Ex - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
kind
|
string:
modern
|
Specifies the kind of reservation recommendation.
|
|
location
|
string
|
Resource location
|
|
name
|
string
|
The name of the resource
|
|
properties
|
ModernReservationRecommendationProperties:
|
Properties for modern reservation recommendation
|
|
sku
|
string
|
Resource sku
|
|
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"
|
ModernSharedScopeReservationRecommendationProperties
Object
The properties of the modern reservation recommendation for shared scope.
| Name |
Type |
Description |
|
costWithNoReservedInstances
|
amount
|
The total amount of cost without reserved instances.
|
|
firstUsageDate
|
string
(date-time)
|
The usage date for looking back.
|
|
instanceFlexibilityGroup
|
string
|
The instance Flexibility Group.
|
|
instanceFlexibilityRatio
|
number
(float)
|
The instance Flexibility Ratio.
|
|
lastUsageDate
|
string
(date-time)
|
The last usage date used for looking back for computing the recommendation.
|
|
location
|
string
|
Resource Location.
|
|
lookBackPeriod
|
integer
(int32)
|
The number of days of usage to look back for recommendation.
|
|
meterId
|
string
(uuid)
|
The meter id (GUID)
|
|
netSavings
|
amount
|
Total estimated savings with reserved instances.
|
|
normalizedSize
|
string
|
The normalized Size.
|
|
recommendedQuantity
|
number
(decimal)
|
Recommended quality for reserved instances.
|
|
recommendedQuantityNormalized
|
number
(float)
|
The recommended Quantity Normalized.
|
|
resourceType
|
string
|
Resource type.
|
|
scope
|
string:
Shared
|
Shared or single recommendation.
|
|
skuName
|
string
|
This is the ARM Sku name.
|
|
skuProperties
|
SkuProperty[]
|
List of sku properties
|
|
term
|
string
|
Term period of the reservation. ex: P1M, P1Y or P3Y.
|
|
totalCostWithReservedInstances
|
amount
|
The total amount of cost with reserved instances.
|
|
totalHours
|
integer
(int32)
|
The total hours for which the cost is covered.
|
ModernSingleScopeReservationRecommendationProperties
Object
The properties of the modern reservation recommendation for single scope.
| Name |
Type |
Description |
|
costWithNoReservedInstances
|
amount
|
The total amount of cost without reserved instances.
|
|
firstUsageDate
|
string
(date-time)
|
The usage date for looking back.
|
|
instanceFlexibilityGroup
|
string
|
The instance Flexibility Group.
|
|
instanceFlexibilityRatio
|
number
(float)
|
The instance Flexibility Ratio.
|
|
lastUsageDate
|
string
(date-time)
|
The last usage date used for looking back for computing the recommendation.
|
|
location
|
string
|
Resource Location.
|
|
lookBackPeriod
|
integer
(int32)
|
The number of days of usage to look back for recommendation.
|
|
meterId
|
string
(uuid)
|
The meter id (GUID)
|
|
netSavings
|
amount
|
Total estimated savings with reserved instances.
|
|
normalizedSize
|
string
|
The normalized Size.
|
|
recommendedQuantity
|
number
(decimal)
|
Recommended quality for reserved instances.
|
|
recommendedQuantityNormalized
|
number
(float)
|
The recommended Quantity Normalized.
|
|
resourceType
|
string
|
Resource type.
|
|
scope
|
string:
Single
|
Shared or single recommendation.
|
|
skuName
|
string
|
This is the ARM Sku name.
|
|
skuProperties
|
SkuProperty[]
|
List of sku properties
|
|
subscriptionId
|
string
(uuid)
|
Subscription ID associated with single scoped recommendation.
|
|
term
|
string
|
Term period of the reservation. ex: P1M, P1Y or P3Y.
|
|
totalCostWithReservedInstances
|
amount
|
The total amount of cost with reserved instances.
|
|
totalHours
|
integer
(int32)
|
The total hours for which the cost is covered.
|
ReservationRecommendationKind
Enumeration
Specifies the kind of reservation recommendation.
| Value |
Description |
|
legacy
|
|
modern
|
ReservationRecommendationsListResult
Object
Result of listing reservation recommendations.
| Name |
Type |
Description |
|
nextLink
|
string
|
The link (url) to the next page of results.
|
|
previousLink
|
string
|
The link (url) to the previous page of results.
|
|
value
|
ReservationRecommendation[]:
|
The list of reservation recommendations.
|
SkuProperty
Object
The Sku property
| Name |
Type |
Description |
|
name
|
string
|
The name of sku property.
|
|
value
|
string
|
The value of sku property.
|
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.
|