Lijst met aanbevelingen voor het kopen van gereserveerde instanties.
GET https://management.azure.com/{resourceScope}/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01
Met optionele parameters:
GET https://management.azure.com/{resourceScope}/providers/Microsoft.Consumption/reservationRecommendations?api-version=2024-08-01&$filter={$filter}
URI-parameters
| Name |
In |
Vereist |
Type |
Description |
|
resourceScope
|
path |
True
|
string
|
De volledig gekwalificeerde Azure Resource Manager-id van de resource.
|
|
api-version
|
query |
True
|
string
minLength: 1
|
De API-versie die voor deze bewerking moet worden gebruikt.
|
|
$filter
|
query |
|
string
|
Kan worden gebruikt om reservationRecommendations te filteren op: properties/scope with allowed values ['Single', 'Shared'] en standaardwaarde 'Single'; properties/resourceType met toegestane waarden ['VirtualMachines', 'SQLDatabases', 'PostgreSQL', 'ManagedDisk', 'MySQL', 'RedHat', 'MariaDB', 'RedisCache', 'CosmosDB', 'SqlDataWarehouse', 'SUSELinux', 'AppService', 'BlockBlob', 'AzureDataExplorer', 'VMwareCloudSimple'] en standaardwaarde 'VirtualMachines'; en properties/lookBackPeriod met toegestane waarden ['Last7Days', 'Last30Days', 'Last60Days'] en de standaardwaarde 'Last7Days'.
|
Antwoorden
Beveiliging
azure_auth
OAuth2-stroom voor Azure Active Directory.
Type:
oauth2
Stroom:
implicit
Autorisatie-URL:
https://login.microsoftonline.com/common/oauth2/authorize
Bereiken
| Name |
Description |
|
user_impersonation
|
Uw gebruikersaccount imiteren
|
Voorbeelden
ReservationRecommendationsByBillingAccount-Legacy
Voorbeeldaanvraag
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{
// CostWithNoReservedInstances: to.Ptr[float64](12.0785105),
// 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"),
// NetSavings: to.Ptr[float64](0.588546019225182),
// NormalizedSize: to.Ptr("Standard_DS1_v2"),
// RecommendedQuantity: to.Ptr[float64](1),
// 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"),
// TotalCostWithReservedInstances: to.Ptr[float64](11.4899644807748),
// 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{
// CostWithNoReservedInstances: to.Ptr[float64](10.0785105),
// 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"),
// NetSavings: to.Ptr[float64](0.68),
// NormalizedSize: to.Ptr("Standard_DS1"),
// RecommendedQuantity: to.Ptr[float64](1),
// 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"),
// TotalCostWithReservedInstances: to.Ptr[float64](13.48),
// 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
Voorbeeldrespons
{
"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
Voorbeeldaanvraag
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{
// CostWithNoReservedInstances: to.Ptr[float64](0.332),
// 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"),
// NetSavings: to.Ptr[float64](0.13725114155251145),
// NormalizedSize: to.Ptr("Standard_B1ms"),
// RecommendedQuantity: to.Ptr[float64](1),
// 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"),
// TotalCostWithReservedInstances: to.Ptr[float64](0.19474885844748857),
// },
// 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{
// CostWithNoReservedInstances: to.Ptr[float64](0.332),
// 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"),
// NetSavings: to.Ptr[float64](0.20688584474885846),
// NormalizedSize: to.Ptr("Standard_B1ms"),
// RecommendedQuantity: to.Ptr[float64](1),
// 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"),
// TotalCostWithReservedInstances: to.Ptr[float64](0.12511415525114156),
// },
// 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
Voorbeeldrespons
{
"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
Voorbeeldaanvraag
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"),
// Value: to.Ptr[float64](279881.9457795231),
// },
// 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"),
// Value: to.Ptr[float64](153766.87728637524),
// },
// NormalizedSize: to.Ptr("SQLDB_BC_Compute_Gen5"),
// RecommendedQuantity: to.Ptr[float64](35),
// 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"),
// Value: to.Ptr[float64](126115.06849314792),
// },
// 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"),
// Value: to.Ptr[float64](93208.8596802244),
// },
// 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"),
// Value: to.Ptr[float64](32553.85968022456),
// },
// NormalizedSize: to.Ptr("SQLDB_BC_Compute_Gen5"),
// RecommendedQuantity: to.Ptr[float64](35),
// 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"),
// Value: to.Ptr[float64](60654.99999999984),
// },
// 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
Voorbeeldrespons
{
"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
Voorbeeldaanvraag
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{
// CostWithNoReservedInstances: to.Ptr[float64](0),
// 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"),
// NetSavings: to.Ptr[float64](4.634521202630137),
// RecommendedQuantity: to.Ptr[float64](1),
// Scope: to.Ptr("Single"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Term: to.Ptr("P1Y"),
// TotalCostWithReservedInstances: to.Ptr[float64](0),
// 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{
// CostWithNoReservedInstances: to.Ptr[float64](0),
// 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"),
// NetSavings: to.Ptr[float64](7.289315723178081),
// RecommendedQuantity: to.Ptr[float64](1),
// Scope: to.Ptr("Single"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Term: to.Ptr("P3Y"),
// TotalCostWithReservedInstances: to.Ptr[float64](0),
// 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
Voorbeeldrespons
{
"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
Voorbeeldaanvraag
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{
// CostWithNoReservedInstances: to.Ptr[float64](0),
// 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"),
// NetSavings: to.Ptr[float64](4.634521202630137),
// RecommendedQuantity: to.Ptr[float64](1),
// Scope: to.Ptr("Single"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Term: to.Ptr("P1Y"),
// TotalCostWithReservedInstances: to.Ptr[float64](0),
// 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{
// CostWithNoReservedInstances: to.Ptr[float64](0),
// 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"),
// NetSavings: to.Ptr[float64](7.289315723178081),
// RecommendedQuantity: to.Ptr[float64](1),
// Scope: to.Ptr("Single"),
// SubscriptionID: to.Ptr("00000000-0000-0000-0000-000000000000"),
// Term: to.Ptr("P3Y"),
// TotalCostWithReservedInstances: to.Ptr[float64](0),
// 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
Voorbeeldrespons
{
"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
Voorbeeldaanvraag
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{
// CostWithNoReservedInstances: to.Ptr[float64](0),
// 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"),
// NetSavings: to.Ptr[float64](4.634521202630137),
// RecommendedQuantity: to.Ptr[float64](1),
// 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"),
// TotalCostWithReservedInstances: to.Ptr[float64](0),
// 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{
// CostWithNoReservedInstances: to.Ptr[float64](0),
// 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"),
// NetSavings: to.Ptr[float64](7.289315723178081),
// RecommendedQuantity: to.Ptr[float64](1),
// 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"),
// TotalCostWithReservedInstances: to.Ptr[float64](0),
// 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
Voorbeeldrespons
{
"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"
}
]
}
Definities
amount
Object
Het bedrag plus valuta.
| Name |
Type |
Description |
|
currency
|
string
|
Valutabedrag.
|
|
value
|
number
(decimal)
|
Aantal.
|
createdByType
Opsomming
Het type identiteit waarmee de resource is gemaakt.
| Waarde |
Description |
|
User
|
|
|
Application
|
|
|
ManagedIdentity
|
|
|
Key
|
|
ErrorAdditionalInfo
Object
Aanvullende informatie over de resourcebeheerfout.
| Name |
Type |
Description |
|
info
|
object
|
De aanvullende informatie.
|
|
type
|
string
|
Het extra informatietype.
|
ErrorDetail
Object
De foutdetails.
| Name |
Type |
Description |
|
additionalInfo
|
ErrorAdditionalInfo[]
|
De fout bevat aanvullende informatie.
|
|
code
|
string
|
De foutcode.
|
|
details
|
ErrorDetail[]
|
De foutdetails.
|
|
message
|
string
|
Het foutbericht.
|
|
target
|
string
|
Het foutdoel.
|
ErrorResponse
Object
Foutreactie
| Name |
Type |
Description |
|
error
|
ErrorDetail
|
Het foutobject.
|
LegacyReservationRecommendation
Object
Aanbeveling voor verouderde reserveringen.
| Name |
Type |
Description |
|
etag
|
string
|
De etag voor de resource.
|
|
id
|
string
|
Volledig gekwalificeerde resource-id voor de resource. Vb.: - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
kind
|
string:
legacy
|
Hiermee geeft u het type reserveringsaanveling op.
|
|
location
|
string
|
Resourcelocatie
|
|
name
|
string
|
De naam van de resource
|
|
properties
|
LegacyReservationRecommendationProperties:
|
Aanbevelingen voor eigenschappen voor oude reserveringen
|
|
sku
|
string
|
Resource-sku
|
|
systemData
|
systemData
|
Azure Resource Manager-metagegevens met createdBy- en modifiedBy-gegevens.
|
|
tags
|
object
|
Resourcetags.
|
|
type
|
string
|
Het type bron. Bijvoorbeeld 'Microsoft.Compute/virtualMachines' of 'Microsoft.Storage/storageAccounts'
|
LegacySharedScopeReservationRecommendationProperties
Object
De eigenschappen van de verouderde reserveringsaanbeveling voor gedeeld bereik.
| Name |
Type |
Description |
|
costWithNoReservedInstances
|
number
(decimal)
|
Het totale bedrag aan kosten zonder gereserveerde instanties.
|
|
firstUsageDate
|
string
(date-time)
|
De gebruiksdatum om terug te kijken.
|
|
instanceFlexibilityGroup
|
string
|
De flexibiliteitsgroep van het exemplaar.
|
|
instanceFlexibilityRatio
|
number
(float)
|
De flexibiliteitsverhouding van het exemplaar.
|
|
lastUsageDate
|
string
(date-time)
|
De laatste gebruiksdatum die wordt gebruikt voor het berekenen van de aanbeveling.
|
|
lookBackPeriod
|
string
|
Het aantal dagen gebruik om terug te kijken naar aanbevelingen.
|
|
meterId
|
string
(uuid)
|
De meter-id (GUID)
|
|
netSavings
|
number
(decimal)
|
Totale geschatte besparingen met gereserveerde instanties.
|
|
normalizedSize
|
string
|
De genormaliseerde grootte.
|
|
recommendedQuantity
|
number
(decimal)
|
Aanbevolen kwaliteit voor gereserveerde instanties.
|
|
recommendedQuantityNormalized
|
number
(float)
|
De aanbevolen hoeveelheid genormaliseerd.
|
|
resourceType
|
string
|
Het azure-resourcetype.
|
|
scope
|
string:
Shared
|
Gedeelde of enkele aanbeveling.
|
|
skuProperties
|
SkuProperty[]
|
Lijst met SKU-eigenschappen
|
|
term
|
string
|
Termijn van de reservering. bijvoorbeeld: P1M, P1Y of P3Y.
|
|
totalCostWithReservedInstances
|
number
(decimal)
|
Het totale bedrag aan kosten met gereserveerde instanties.
|
|
totalHours
|
integer
(int32)
|
Het totale aantal uren waarvoor de kosten worden gedekt.
|
LegacySingleScopeReservationRecommendationProperties
Object
De eigenschappen van de verouderde reserveringsaanbeveling voor één bereik.
| Name |
Type |
Description |
|
costWithNoReservedInstances
|
number
(decimal)
|
Het totale bedrag aan kosten zonder gereserveerde instanties.
|
|
firstUsageDate
|
string
(date-time)
|
De gebruiksdatum om terug te kijken.
|
|
instanceFlexibilityGroup
|
string
|
De flexibiliteitsgroep van het exemplaar.
|
|
instanceFlexibilityRatio
|
number
(float)
|
De flexibiliteitsverhouding van het exemplaar.
|
|
lastUsageDate
|
string
(date-time)
|
De laatste gebruiksdatum die wordt gebruikt voor het berekenen van de aanbeveling.
|
|
lookBackPeriod
|
string
|
Het aantal dagen gebruik om terug te kijken naar aanbevelingen.
|
|
meterId
|
string
(uuid)
|
De meter-id (GUID)
|
|
netSavings
|
number
(decimal)
|
Totale geschatte besparingen met gereserveerde instanties.
|
|
normalizedSize
|
string
|
De genormaliseerde grootte.
|
|
recommendedQuantity
|
number
(decimal)
|
Aanbevolen kwaliteit voor gereserveerde instanties.
|
|
recommendedQuantityNormalized
|
number
(float)
|
De aanbevolen hoeveelheid genormaliseerd.
|
|
resourceType
|
string
|
Het azure-resourcetype.
|
|
scope
|
string:
Single
|
Gedeelde of enkele aanbeveling.
|
|
skuProperties
|
SkuProperty[]
|
Lijst met SKU-eigenschappen
|
|
subscriptionId
|
string
(uuid)
|
Abonnements-id gekoppeld aan aanbeveling met één bereik.
|
|
term
|
string
|
Termijn van de reservering. bijvoorbeeld: P1M, P1Y of P3Y.
|
|
totalCostWithReservedInstances
|
number
(decimal)
|
Het totale bedrag aan kosten met gereserveerde instanties.
|
|
totalHours
|
integer
(int32)
|
Het totale aantal uren waarvoor de kosten worden gedekt.
|
ModernReservationRecommendation
Object
Aanbeveling voor moderne reserveringen.
| Name |
Type |
Description |
|
etag
|
string
|
De etag voor de resource.
|
|
id
|
string
|
Volledig gekwalificeerde resource-id voor de resource. Vb.: - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}
|
|
kind
|
string:
modern
|
Hiermee geeft u het type reserveringsaanveling op.
|
|
location
|
string
|
Resourcelocatie
|
|
name
|
string
|
De naam van de resource
|
|
properties
|
ModernReservationRecommendationProperties:
|
Eigenschappen voor moderne reserveringsaanbeveling
|
|
sku
|
string
|
Resource-sku
|
|
systemData
|
systemData
|
Azure Resource Manager-metagegevens met createdBy- en modifiedBy-gegevens.
|
|
tags
|
object
|
Resourcetags.
|
|
type
|
string
|
Het type bron. Bijvoorbeeld 'Microsoft.Compute/virtualMachines' of 'Microsoft.Storage/storageAccounts'
|
ModernSharedScopeReservationRecommendationProperties
Object
De eigenschappen van de moderne reserveringsaanbeveling voor gedeelde reikwijdte.
| Name |
Type |
Description |
|
costWithNoReservedInstances
|
amount
|
Het totale bedrag aan kosten zonder gereserveerde instanties.
|
|
firstUsageDate
|
string
(date-time)
|
De gebruiksdatum om terug te kijken.
|
|
instanceFlexibilityGroup
|
string
|
De flexibiliteitsgroep van het exemplaar.
|
|
instanceFlexibilityRatio
|
number
(float)
|
De flexibiliteitsverhouding van het exemplaar.
|
|
lastUsageDate
|
string
(date-time)
|
De laatste gebruiksdatum die wordt gebruikt voor het berekenen van de aanbeveling.
|
|
location
|
string
|
Resourcelocatie.
|
|
lookBackPeriod
|
integer
(int32)
|
Het aantal dagen gebruik om terug te kijken naar aanbevelingen.
|
|
meterId
|
string
(uuid)
|
De meter-id (GUID)
|
|
netSavings
|
amount
|
Totale geschatte besparingen met gereserveerde instanties.
|
|
normalizedSize
|
string
|
De genormaliseerde grootte.
|
|
recommendedQuantity
|
number
(decimal)
|
Aanbevolen kwaliteit voor gereserveerde instanties.
|
|
recommendedQuantityNormalized
|
number
(float)
|
De aanbevolen hoeveelheid genormaliseerd.
|
|
resourceType
|
string
|
Resourcetype.
|
|
scope
|
string:
Shared
|
Gedeelde of enkele aanbeveling.
|
|
skuName
|
string
|
Dit is de NAAM van de ARM-SKU.
|
|
skuProperties
|
SkuProperty[]
|
Lijst met SKU-eigenschappen
|
|
term
|
string
|
Termijn van de reservering. bijvoorbeeld: P1M, P1Y of P3Y.
|
|
totalCostWithReservedInstances
|
amount
|
Het totale bedrag aan kosten met gereserveerde instanties.
|
|
totalHours
|
integer
(int32)
|
Het totale aantal uren waarvoor de kosten worden gedekt.
|
ModernSingleScopeReservationRecommendationProperties
Object
De eigenschappen van de moderne reserveringsaanbeveling voor single scope.
| Name |
Type |
Description |
|
costWithNoReservedInstances
|
amount
|
Het totale bedrag aan kosten zonder gereserveerde instanties.
|
|
firstUsageDate
|
string
(date-time)
|
De gebruiksdatum om terug te kijken.
|
|
instanceFlexibilityGroup
|
string
|
De flexibiliteitsgroep van het exemplaar.
|
|
instanceFlexibilityRatio
|
number
(float)
|
De flexibiliteitsverhouding van het exemplaar.
|
|
lastUsageDate
|
string
(date-time)
|
De laatste gebruiksdatum die wordt gebruikt voor het berekenen van de aanbeveling.
|
|
location
|
string
|
Resourcelocatie.
|
|
lookBackPeriod
|
integer
(int32)
|
Het aantal dagen gebruik om terug te kijken naar aanbevelingen.
|
|
meterId
|
string
(uuid)
|
De meter-id (GUID)
|
|
netSavings
|
amount
|
Totale geschatte besparingen met gereserveerde instanties.
|
|
normalizedSize
|
string
|
De genormaliseerde grootte.
|
|
recommendedQuantity
|
number
(decimal)
|
Aanbevolen kwaliteit voor gereserveerde instanties.
|
|
recommendedQuantityNormalized
|
number
(float)
|
De aanbevolen hoeveelheid genormaliseerd.
|
|
resourceType
|
string
|
Resourcetype.
|
|
scope
|
string:
Single
|
Gedeelde of enkele aanbeveling.
|
|
skuName
|
string
|
Dit is de NAAM van de ARM-SKU.
|
|
skuProperties
|
SkuProperty[]
|
Lijst met SKU-eigenschappen
|
|
subscriptionId
|
string
(uuid)
|
Abonnements-ID gekoppeld aan aanbeveling met één bereik.
|
|
term
|
string
|
Termijn van de reservering. bijvoorbeeld: P1M, P1Y of P3Y.
|
|
totalCostWithReservedInstances
|
amount
|
Het totale bedrag aan kosten met gereserveerde instanties.
|
|
totalHours
|
integer
(int32)
|
Het totale aantal uren waarvoor de kosten worden gedekt.
|
ReservationRecommendationKind
Opsomming
Hiermee geeft u het type reserveringsaanveling op.
| Waarde |
Description |
|
legacy
|
|
|
modern
|
|
ReservationRecommendationsListResult
Object
Resultaat van het weergeven van reserveringsaankopen.
| Name |
Type |
Description |
|
nextLink
|
string
|
De koppeling (URL) naar de volgende pagina met resultaten.
|
|
previousLink
|
string
|
De koppeling (URL) naar de vorige pagina met resultaten.
|
|
value
|
ReservationRecommendation[]:
|
De lijst met aanbevelingen voor reserveringen.
|
SkuProperty
Object
De SKU-eigenschap
| Name |
Type |
Description |
|
name
|
string
|
De naam van de SKU-eigenschap.
|
|
value
|
string
|
De waarde van de SKU-eigenschap.
|
systemData
Object
Metagegevens met betrekking tot het maken en de laatste wijziging van de resource.
| Name |
Type |
Description |
|
createdAt
|
string
(date-time)
|
De tijdstempel van het maken van resources (UTC).
|
|
createdBy
|
string
|
De identiteit waarmee de resource is gemaakt.
|
|
createdByType
|
createdByType
|
Het type identiteit waarmee de resource is gemaakt.
|
|
lastModifiedAt
|
string
(date-time)
|
De tijdstempel van de laatste wijziging van de resource (UTC)
|
|
lastModifiedBy
|
string
|
De identiteit die de resource voor het laatst heeft gewijzigd.
|
|
lastModifiedByType
|
createdByType
|
Het type identiteit dat de resource voor het laatst heeft gewijzigd.
|