Instructions: to get PowerShell version, type $PSVersionTable and look for the value associated with PSVersion
PSVersion 5.1.15063.786
Module Version
OS Version
Instructions: to get OS version, type $PSversionTable and look for value associated with BuildVersion
BuildVersion 10.0.15063.786
Description
Hi,
I have a problem with cmdlet Add-AzureRmMetricAlertRule.
After created appService I trying to set alert in Application Insight (cpu).
When I Start my scripts I have bellow error:
WARNING: [Add-AzureRmMetricAlertRule] Parameter name change: The parameter plural names for the parameters will be deprecated in a future breaking change release in favor of the singular versions of the same names.
Add-AzureRmMetricAlertRule : Exception type: ErrorResponseException, Message: {"code":"Value cannot be null.","message":"Value cannot be null.\r\nParameter name: No definition for metric 'ProcessCPU' for '/subscriptions/422d1e9b-7707-47c2-9875-88086599bbd5/res
ourceGroups/SalaryCalculator-rg-eun-beta/providers/microsoft.insights/components/SalaryCalculator-ins-eun-beta'","innererror":{"diagnosticcontext":"8e46fb7f-5b7a-41e3-be0d-e0cf42aafd6f","time":"2018-01-29T09:43:08.6850777Z"}}, Code: BadRequest, Status code:Bad
Request, Reason phrase: Bad Request
At C:\salary-calculator\set_alert.ps1:17 char:1
Instructions: to get Debug Output, set $DebugPreference="Continue" and then execute the cmdlet or script causing the issue
DEBUG: 10:45:19 - AddAzureRmMetricAlertRuleCommand begin processing with ParameterSet '__AllParameterSets'.
DEBUG: 10:45:19 - using account id 'pps@xyz.com'...
WARNING: [Add-AzureRmMetricAlertRule] Parameter name change: The parameter plural names for the parameters will be deprecated in a future breaking change release in favor of the singular versions of the same names.
DEBUG: [Common.Authentication]: Authenticating using Account: 'pps@xyz.com', environment: 'AzureCloud', tenant: 'xxxx-xxxx'
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/29/2018 09:45:19: 11111-11111 - AcquireTokenHandlerBase: === Token Acquisition started:
Authority: https://login.microsoftonline.com/xxxx-xxxx
Resource: https://management.core.windows.net/
ClientId: 222-222
CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (5 items)
Authentication Target: User
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 01/29/2018 09:45:19: 11111-11111 - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/29/2018 09:45:19: 11111-11111 - TokenCache: An item matching the requested resource was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 :
DEBUG: 01/29/2018 09:45:19: 11111-11111 - TokenCache: 8.69682866166667 minutes left until token in cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 :
DEBUG: 01/29/2018 09:45:19: 11111-11111 - TokenCache: A matching item (access token or refresh token or both) was found in the cache
Body:
{
"code": "BadRequest",
"message": "{\"code\":\"Value cannot be null.\",\"message\":\"Value cannot be null.\r\nParameter name: No definition for metric 'ProcessCPU' for '/subscriptions/xxx/resourceGroups/sample-group/providers/microsoft.insights/components/sample-app'\",\"innererror\":{\"diagnosticcontext\":\"xxx\",\"time\":\"2018-01-29T09:45:20.8785508Z\"}}"
}
Add-AzureRmMetricAlertRule : Exception type: ErrorResponseException, Message: {"code":"Value cannot be null.","message":"Value cannot be null.\r\nParameter name: No definition for metric 'ProcessCPU' for '/subscriptions/xxx/res
ourceGroups/sample-group/providers/microsoft.insights/components/sample-app'","innererror":{"diagnosticcontext":"xxx","time":"2018-01-29T09:45:20.8785508Z"}}, Code: BadRequest, Status code:Bad
Request, Reason phrase: Bad Request
At C:\salary-calculator\set_alert.ps1:17 char:1
DEBUG: AzureQoSEvent: CommandName - Add-AzureRmMetricAlertRule; IsSuccess - False; Duration - 00:00:02.4906082; Exception - System.Management.Automation.PSInvalidOperationException: Exception type: ErrorResponseException, Message: {"code":"Value cannot be null.","message":"Value cannot be null.\r\nParameter name: No definition for metric 'ProcessCPU' for '/subscriptions/xxx/resourceGroups/sample-group/providers/microsoft.insights/components/sample-app'","innererror":{"diagnosticcontext":"xxx","time":"2018-01-29T09:45:20.8785508Z"}}, Code: BadRequest, Status code:BadRequest, Reason phrase: Bad Request ---> Microsoft.Azure.Management.Monitor.Management.Models.ErrorResponseException: Operation returned an invalid status code 'BadRequest'
w Microsoft.Azure.Management.Monitor.Management.AlertRulesOperations.d__5.MoveNext()
--- Koniec śladu stosu wyjątków wewnętrznych ---
w Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet()
w Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 10:45:22 - AddAzureRmMetricAlertRuleCommand end processing.
DEBUG: 10:45:22 - AddAzureRmMetricAlertRuleCommand end processing.
Cmdlet(s)
Add-AzureRmMetricAlertRule
PowerShell Version
Instructions: to get PowerShell version, type
$PSVersionTable
and look for the value associated withPSVersion
PSVersion 5.1.15063.786Module Version
OS Version
Instructions: to get OS version, type
$PSversionTable
and look for value associated withBuildVersion
BuildVersion 10.0.15063.786Description
Hi,
I have a problem with cmdlet Add-AzureRmMetricAlertRule. After created appService I trying to set alert in Application Insight (cpu). When I Start my scripts I have bellow error:
WARNING: [Add-AzureRmMetricAlertRule] Parameter name change: The parameter plural names for the parameters will be deprecated in a future breaking change release in favor of the singular versions of the same names. Add-AzureRmMetricAlertRule : Exception type: ErrorResponseException, Message: {"code":"Value cannot be null.","message":"Value cannot be null.\r\nParameter name: No definition for metric 'ProcessCPU' for '/subscriptions/422d1e9b-7707-47c2-9875-88086599bbd5/res ourceGroups/SalaryCalculator-rg-eun-beta/providers/microsoft.insights/components/SalaryCalculator-ins-eun-beta'","innererror":{"diagnosticcontext":"8e46fb7f-5b7a-41e3-be0d-e0cf42aafd6f","time":"2018-01-29T09:43:08.6850777Z"}}, Code: BadRequest, Status code:Bad Request, Reason phrase: Bad Request At C:\salary-calculator\set_alert.ps1:17 char:1
Debug Output
Instructions: to get Debug Output, set
$DebugPreference="Continue"
and then execute the cmdlet or script causing the issueDEBUG: 10:45:19 - AddAzureRmMetricAlertRuleCommand begin processing with ParameterSet '__AllParameterSets'. DEBUG: 10:45:19 - using account id 'pps@xyz.com'... WARNING: [Add-AzureRmMetricAlertRule] Parameter name change: The parameter plural names for the parameters will be deprecated in a future breaking change release in favor of the singular versions of the same names. DEBUG: [Common.Authentication]: Authenticating using Account: 'pps@xyz.com', environment: 'AzureCloud', tenant: 'xxxx-xxxx' DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 01/29/2018 09:45:19: 11111-11111 - AcquireTokenHandlerBase: === Token Acquisition started: Authority: https://login.microsoftonline.com/xxxx-xxxx Resource: https://management.core.windows.net/ ClientId: 222-222 CacheType: Microsoft.Azure.Commands.Common.Authentication.ProtectedFileTokenCache (5 items) Authentication Target: User
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 01/29/2018 09:45:19: - TokenCache: Deserialized 5 items to token cache.
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : DEBUG: 01/29/2018 09:45:19: 11111-11111 - TokenCache: Looking up cache for a token...
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 01/29/2018 09:45:19: 11111-11111 - TokenCache: An item matching the requested resource was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : DEBUG: 01/29/2018 09:45:19: 11111-11111 - TokenCache: 8.69682866166667 minutes left until token in cache expires
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 01/29/2018 09:45:19: 11111-11111 - TokenCache: A matching item (access token or refresh token or both) was found in the cache
DEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : DEBUG: 01/29/2018 09:45:19: 11111-11111 - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token was retuned: Access Token Hash: X/0eVDN6VI= Refresh Token Hash: 111= Expiration Time: 01/29/2018 09:54:00 +00:00 User Hash: 111=
DEBUG: ============================ HTTP REQUEST ============================
HTTP Method: PUT
Absolute Uri: https://management.azure.com/subscriptions/xxx/resourcegroups/sample-app/providers/microsoft.insights/alertrules/CPU-metric?api-version=2016-03-01
Headers: x-ms-client-request-id : 444-444 accept-language : en-US
Body: { "properties": { "name": "CPU-metric", "description": "This metric alert rule was created from Powershell version: 4.0.0", "isEnabled": true, "condition": { "odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition", "operator": "GreaterThan", "threshold": 80.0, "windowSize": "PT5M", "timeAggregation": "Total", "dataSource": { "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource", "metricName": "ProcessCPU", "resourceUri": "/subscriptions/xxx/resourceGroups/sample-group/providers/microsoft.insights/components/sample-app/" } } }, "location": "northeurope", "tags": { "$type": "Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary,Microsoft.WindowsAzure.Management.Common.Storage", "hidden-link:/subscriptions/xxx/resourceGroups/sample-group/providers/microsoft.insights/components/sample-app/": "Resource" } }
DEBUG: ============================ HTTP RESPONSE ============================
Status Code: BadRequest
Headers: Pragma : no-cache Strict-Transport-Security : max-age=31536000; includeSubDomains x-ms-request-id : 00000000-0000-0000-0000-000000000000 x-ms-ratelimit-remaining-subscription-writes: 1199 x-ms-correlation-request-id : a9026e18-e8df-4f3d-80d7-b62c054beb74 x-ms-routing-request-id : WESTEUROPE:2018012521Z:a9026e18-e8df-4f3d-80d7-b64beb74 Cache-Control : no-cache Date : Mon, 29 Jan 2018 09:45:21 GMT Server : Microsoft-IIS/8.5
Body: { "code": "BadRequest", "message": "{\"code\":\"Value cannot be null.\",\"message\":\"Value cannot be null.\r\nParameter name: No definition for metric 'ProcessCPU' for '/subscriptions/xxx/resourceGroups/sample-group/providers/microsoft.insights/components/sample-app'\",\"innererror\":{\"diagnosticcontext\":\"xxx\",\"time\":\"2018-01-29T09:45:20.8785508Z\"}}" }
Add-AzureRmMetricAlertRule : Exception type: ErrorResponseException, Message: {"code":"Value cannot be null.","message":"Value cannot be null.\r\nParameter name: No definition for metric 'ProcessCPU' for '/subscriptions/xxx/res ourceGroups/sample-group/providers/microsoft.insights/components/sample-app'","innererror":{"diagnosticcontext":"xxx","time":"2018-01-29T09:45:20.8785508Z"}}, Code: BadRequest, Status code:Bad Request, Reason phrase: Bad Request At C:\salary-calculator\set_alert.ps1:17 char:1
DEBUG: AzureQoSEvent: CommandName - Add-AzureRmMetricAlertRule; IsSuccess - False; Duration - 00:00:02.4906082; Exception - System.Management.Automation.PSInvalidOperationException: Exception type: ErrorResponseException, Message: {"code":"Value cannot be null.","message":"Value cannot be null.\r\nParameter name: No definition for metric 'ProcessCPU' for '/subscriptions/xxx/resourceGroups/sample-group/providers/microsoft.insights/components/sample-app'","innererror":{"diagnosticcontext":"xxx","time":"2018-01-29T09:45:20.8785508Z"}}, Code: BadRequest, Status code:BadRequest, Reason phrase: Bad Request ---> Microsoft.Azure.Management.Monitor.Management.Models.ErrorResponseException: Operation returned an invalid status code 'BadRequest' w Microsoft.Azure.Management.Monitor.Management.AlertRulesOperations.d__5.MoveNext()
--- Koniec śladu stosu wyjątków wewnętrznych ---
w Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet()
w Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();
DEBUG: Finish sending metric.
DEBUG: 10:45:22 - AddAzureRmMetricAlertRuleCommand end processing.
DEBUG: 10:45:22 - AddAzureRmMetricAlertRuleCommand end processing.
Script/Steps for Reproduction
$webappname = sample-app $groupname = sample-group $location = northeurope
$resource_id = "/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXX/resourceGroups/$groupname/providers/microsoft.insights/components/$webappname
Add-AzureRmMetricAlertRule -Name "CPU-metric" -Location $location -ResourceGroup $groupname -Operator GreaterThan -Threshold 80 -TargetResourceId $resource_id -MetricName "ProcessCPU" -TimeAggregationOperator Total -WindowSize 00:05:00