Hi There,
Hoping somebody can assist with this, I have several runbooks failing, these are listed below;
Recommend-VMSSOptimizationsToBlobStorage
Recommend-VMsHighAvailabilityToBlobStorage
Recommend-UnusedLoadBalancersToBlobStorage
Recommend-UnusedAppGWsToBlobStorage
Recommend-SqlDbOptimizationsToBlobStorage
All of these have similar errors, please see two examples below;
EXAMPLE 1:
Recommend-VMsHighAvailabilityToBlobStorage
Output:
Logging in to Azure with ManagedIdentity...
Environments
{[AzureChinaCloud, AzureChinaCloud], [AzureCloud, AzureCloud], [AzureGermanCloud, AzureGermanCloud], [AzureUSGovernme...
Finding tables where recommendations will be generated from...
Will run query against tables AzureOptimizationAvailSetsV1_CL, AzureOptimizationVMsV1_CL, AzureOptimizationVMSSV1_CL, AzureOptimizationVhdDisksV1_CL and AzureOptimizationResourceContainersV1_CL
Name : Internal IT (xxxxx) - xxxxx -
MSI@xxxxx
Account : MSI@xxxxx
Environment : AzureCloud
Subscription : xxxxx
Tenant : xxxxx
TokenCache :
VersionProfile :
ExtendedProperties : {}
Looking for Availability Sets with a low fault domain count...
Warnings:
-TenantId ‘xxxxx’ contains more than one active subscription. First one will be selected for further use. To select another subscription, use Set-AzContext.
-Query failed. Debug the following query in the AOE Log Analytics workspace: AzureOptimizationAvailSetsV1_CL | where TimeGenerated > ago(1d) and toint(FaultDomains_s) < 3 and toint(FaultDomains_s) < todouble(VmCount_s)/2 | project TimeGenerated, InstanceId_s, InstanceName_s, ResourceGroupName_s, SubscriptionGuid_g, TenantGuid_g, Cloud_s, Tags_s, FaultDomains_s, VmCount_s | join kind=leftouter ( AzureOptimizationResourceContainersV1_CL | where TimeGenerated > ago(1d) | where ContainerType_s =~ 'microsoft.resources/subscriptions' | project SubscriptionGuid_g, SubscriptionName = ContainerName_s ) on SubscriptionGuid_g
-Operation returned an invalid status code 'BadRequest'
EXAMPLE 2:
Recommend-VMSSOptimizationsToBlobStorage
Output:
Logging in to Azure with ManagedIdentity...
Environments
{[AzureChinaCloud, AzureChinaCloud], [AzureCloud, AzureCloud], [AzureGermanCloud, AzureGermanCloud], [AzureUSGovernme...
Finding tables where recommendations will be generated from...
Will run query against tables AzureOptimizationVMSSV1_CL, AzureOptimizationMonitorMetricsV1_CL, AzureOptimizationResourceContainersV1_CL and AzureOptimizationConsumptionV1_CL
Name : Internal IT (xxxxx) - xxxxx -
MSI@xxxxx
Account : MSI@xxxxx
Environment : AzureCloud
Subscription : xxxxx
Tenant : xxxxx
TokenCache :
VersionProfile :
ExtendedProperties : {}
Getting Virtual Machine SKUs for the australiaeast region...
Getting the current Pricesheet...
Consumption pricesheet not available, will estimate savings based in cores count...
Looking for underutilized Scale Sets, with less than 30% CPU and 50% RAM usage...
Warnings:
-TenantId 'xxxxx' contains more than one active subscription. First one will be selected for further use. To select another subscription, use Set-AzContext.
-SubscriptionGuid_g, Cloud_s, TenantGuid_g, VMSSSize_s, NicCount_s, DataDiskCount_s, PMemoryPercentage, PCPUPercentage, Tags_s, Last30DaysCost, Last30DaysQuantity | join kind=leftouter ( AzureOptimizationResourceContainersV1_CL | where TimeGenerated > ago(1d) | where ContainerType_s =~ 'microsoft.resources/subscriptions' | project SubscriptionId = SubscriptionGuid_g, SubscriptionName = ContainerName_s ) on SubscriptionId | where isnotempty(PMemoryPercentage) and isnotempty(PCPUPercentage) and PMemoryPercentage < 50 and PCPUPercentage < 30
-Error getting consumption data: Cost Management not available (Cost management data is not supported for subscription(s) xxxxx in the provided api-version. Please use api-version 2019-10-01 or later. (Request ID: e3cb353c-c42b-4b71-afa1-234e815d4481)). 1 of 3 tries. Waiting 30 seconds...
-Query failed. Debug the following query in the AOE Log Analytics workspace: let billingInterval = 30d; let perfInterval = 7d; let cpuPercentileValue = 99; let memoryPercentileValue = 99; let etime = todatetime(toscalar(AzureOptimizationConsumptionV1_CL | summarize max(UsageDate_t))); let stime = etime-billingInterval; let BilledVMs = AzureOptimizationConsumptionV1_CL | where UsageDate_t between (stime..etime) and InstanceId_s contains 'virtualmachinescalesets' | extend VMConsumedQuantity = iif(InstanceId_s contains 'virtualmachinescalesets' and MeterCategory_s == 'Virtual Machines', todouble(Quantity_s), 0.0) | extend VMPrice = iif(InstanceId_s contains 'virtualmachinescalesets' and MeterCategory_s == 'Virtual Machines', todouble(UnitPrice_s), 0.0) | extend FinalCost = VMPrice * VMConsumedQuantity | summarize Last30DaysCost = sum(FinalCost), Last30DaysQuantity = sum(VMConsumedQuantity) by InstanceId_s; let MemoryPerf = AzureOptimizationMonitorMetricsV1_CL | where TimeGenerated > ago(perfInterval) | where MetricNames_s == "Available Memory Bytes" and AggregationType_s == "Minimum" | extend MemoryAvailableMBs = todouble(MetricValue_s)/1024/1024 | project TimeGenerated, MemoryAvailableMBs, InstanceId_s=ResourceId | join kind=inner ( AzureOptimizationVMSSV1_CL | where TimeGenerated > ago(1d) | distinct InstanceId_s, MemoryMB_s ) on InstanceId_s | extend MemoryPercentage = todouble(toint(MemoryMB_s) - toint(MemoryAvailableMBs)) / todouble(MemoryMB_s) * 100 | summarize PMemoryPercentage = percentile(MemoryPercentage, memoryPercentileValue) by InstanceId_s; let ProcessorPerf = AzureOptimizationMonitorMetricsV1_CL | where TimeGenerated > ago(perfInterval) | where MetricNames_s == "Percentage CPU" and AggregationType_s == 'Maximum' | extend InstanceId_s = ResourceId | summarize PCPUPercentage = percentile(todouble(MetricValue_s), cpuPercentileValue) by InstanceId_s; AzureOptimizationVMSSV1_CL | where TimeGenerated > ago(1d) | distinct InstanceId_s, VMSSName_s, ResourceGroupName_s, SubscriptionGuid_g, Cloud_s, TenantGuid_g, VMSSSize_s, NicCount_s, DataDiskCount_s, Tags_s | join kind=inner ( BilledVMs ) on InstanceId_s | join kind=leftouter ( MemoryPerf ) on InstanceId_s | join kind=leftouter ( ProcessorPerf ) on InstanceId_s | project InstanceId_s, VMSSName = VMSSName_s, ResourceGroup = ResourceGroupName_s, SubscriptionId =
-Operation returned an invalid status code 'BadRequest'