{"action":"created","issue":{"url":"https://api.github.com/repos/Azure/azure-powershell/issues/4983","repository_url":"https://api.github.com/repos/Azure/azure-powershell","labels_url":"https://api.github.com/repos/Azure/azure-powershell/issues/4983/labels{/name}","comments_url":"https://api.github.com/repos/Azure/azure-powershell/issues/4983/comments","events_url":"https://api.github.com/repos/Azure/azure-powershell/issues/4983/events","html_url":"https://github.com/Azure/azure-powershell/issues/4983","id":273756910,"node_id":"MDU6SXNzdWUyNzM3NTY5MTA=","number":4983,"title":"Add-AzureRmMetricAlertRule failing for function app metrics","user":{"login":"vinaydam","id":33538314,"node_id":"MDQ6VXNlcjMzNTM4MzE0","avatar_url":"https://avatars1.githubusercontent.com/u/33538314?v=4","gravatar_id":"","url":"https://api.github.com/users/vinaydam","html_url":"https://github.com/vinaydam","followers_url":"https://api.github.com/users/vinaydam/followers","following_url":"https://api.github.com/users/vinaydam/following{/other_user}","gists_url":"https://api.github.com/users/vinaydam/gists{/gist_id}","starred_url":"https://api.github.com/users/vinaydam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vinaydam/subscriptions","organizations_url":"https://api.github.com/users/vinaydam/orgs","repos_url":"https://api.github.com/users/vinaydam/repos","events_url":"https://api.github.com/users/vinaydam/events{/privacy}","received_events_url":"https://api.github.com/users/vinaydam/received_events","type":"User","site_admin":false},"labels":[{"id":185013285,"node_id":"MDU6TGFiZWwxODUwMTMyODU=","url":"https://api.github.com/repos/Azure/azure-powershell/labels/Insights","name":"Insights","color":"e99695","default":false},{"id":1069434804,"node_id":"MDU6TGFiZWwxMDY5NDM0ODA0","url":"https://api.github.com/repos/Azure/azure-powershell/labels/Service%20Attention","name":"Service Attention","color":"e99695","default":false}],"state":"open","locked":false,"assignee":{"login":"asheniam","id":5281947,"node_id":"MDQ6VXNlcjUyODE5NDc=","avatar_url":"https://avatars3.githubusercontent.com/u/5281947?v=4","gravatar_id":"","url":"https://api.github.com/users/asheniam","html_url":"https://github.com/asheniam","followers_url":"https://api.github.com/users/asheniam/followers","following_url":"https://api.github.com/users/asheniam/following{/other_user}","gists_url":"https://api.github.com/users/asheniam/gists{/gist_id}","starred_url":"https://api.github.com/users/asheniam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asheniam/subscriptions","organizations_url":"https://api.github.com/users/asheniam/orgs","repos_url":"https://api.github.com/users/asheniam/repos","events_url":"https://api.github.com/users/asheniam/events{/privacy}","received_events_url":"https://api.github.com/users/asheniam/received_events","type":"User","site_admin":false},"assignees":[{"login":"asheniam","id":5281947,"node_id":"MDQ6VXNlcjUyODE5NDc=","avatar_url":"https://avatars3.githubusercontent.com/u/5281947?v=4","gravatar_id":"","url":"https://api.github.com/users/asheniam","html_url":"https://github.com/asheniam","followers_url":"https://api.github.com/users/asheniam/followers","following_url":"https://api.github.com/users/asheniam/following{/other_user}","gists_url":"https://api.github.com/users/asheniam/gists{/gist_id}","starred_url":"https://api.github.com/users/asheniam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asheniam/subscriptions","organizations_url":"https://api.github.com/users/asheniam/orgs","repos_url":"https://api.github.com/users/asheniam/repos","events_url":"https://api.github.com/users/asheniam/events{/privacy}","received_events_url":"https://api.github.com/users/asheniam/received_events","type":"User","site_admin":false},{"login":"gucalder","id":5290273,"node_id":"MDQ6VXNlcjUyOTAyNzM=","avatar_url":"https://avatars2.githubusercontent.com/u/5290273?v=4","gravatar_id":"","url":"https://api.github.com/users/gucalder","html_url":"https://github.com/gucalder","followers_url":"https://api.github.com/users/gucalder/followers","following_url":"https://api.github.com/users/gucalder/following{/other_user}","gists_url":"https://api.github.com/users/gucalder/gists{/gist_id}","starred_url":"https://api.github.com/users/gucalder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/gucalder/subscriptions","organizations_url":"https://api.github.com/users/gucalder/orgs","repos_url":"https://api.github.com/users/gucalder/repos","events_url":"https://api.github.com/users/gucalder/events{/privacy}","received_events_url":"https://api.github.com/users/gucalder/received_events","type":"User","site_admin":false}],"milestone":null,"comments":6,"created_at":"2017-11-14T11:22:47Z","updated_at":"2018-09-27T18:58:43Z","closed_at":null,"author_association":"NONE","body":"### Cmdlet(s)\r\nAdd-AzureRmMetricAlertRule\r\n\r\n### PowerShell Version\r\n5.1.16299.19\r\n\r\n### Module Version\r\n4.0.0\r\n\r\n### OS Version\r\n10.0.16299.19\r\n\r\n### Description\r\nWhen I try to add the \"FunctionExecutionCount\" or \"Http5xx\" metrics to a function app using the Add-AzureRmMetricAlertRule, it fails citing the error \"Add-AzureRmMetricAlertRule : Exception type: ErrorResponseException, Message: The metric with namespace '' and name 'FunctionExecutionCount' is not supported for this resource id\". The same behavior is observed for function apps with an App Service Plan and a Consumption Plan.\r\n\r\n### Debug Output\r\nDEBUG: 4:46:55 PM - AddAzureRmMetricAlertRuleCommand begin processing with ParameterSet '__AllParameterSets'.\r\nDEBUG: 4:46:55 PM - using account id 'vinaydami@outlook.com'...\r\nWARNING: [Add-AzureRmMetricAlertRule] Parameter name change: The parameter plural names for the parameters will be deprecated in a future breaking change\r\n release in favor of the singular versions of the same names.\r\nDEBUG: [Common.Authentication]: Authenticating using Account: 'vinaydami@outlook.com', environment: 'AzureCloud', tenant: '5ed1d584-3cdd-4f8b-87b5-515a23\r\ne7e65e'\r\nDEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : \r\nDEBUG: 11/14/2017 11:16:55: 16a2e83f-93d5-4471-a9b7-f34e810934ef - AcquireTokenHandlerBase: === Token Acquisition started:\r\n\tAuthority: https://login.microsoftonline.com/5ed1d584-3cdd-4f8b-87b5-515a23e7e65e/\r\n\tResource: https://management.core.windows.net/\r\n\tClientId: 1950a258-227b-4e31-a9cf-717495945fc2\r\n\tCacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (6 items)\r\n\tAuthentication Target: User\r\n\t\r\n\r\nDEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : \r\nDEBUG: 11/14/2017 11:16:55: 16a2e83f-93d5-4471-a9b7-f34e810934ef - TokenCache: Looking up cache for a token...\r\n\r\nDEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : \r\nDEBUG: 11/14/2017 11:16:55: 16a2e83f-93d5-4471-a9b7-f34e810934ef - TokenCache: An item matching the requested resource was found in the cache\r\n\r\nDEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : \r\nDEBUG: 11/14/2017 11:16:55: 16a2e83f-93d5-4471-a9b7-f34e810934ef - TokenCache: 29.7242895766667 minutes left until token in cache expires\r\n\r\nDEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : \r\nDEBUG: 11/14/2017 11:16:55: 16a2e83f-93d5-4471-a9b7-f34e810934ef - TokenCache: A matching item (access token or refresh token or both) was found in the c\r\nache\r\n\r\nDEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : \r\nDEBUG: 11/14/2017 11:16:55: 16a2e83f-93d5-4471-a9b7-f34e810934ef - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token \r\nwas retuned:\r\n\tAccess Token Hash: vqZ9QV1qyjNrjiISc/Ym8W7r3RSLJpKelruP+3vwbTg=\r\n\tRefresh Token Hash: VDR4u6C0ZYqv1GBz/FdeF9w0pTZ35mMuhTOIrf9s/Sg=\r\n\tExpiration Time: 11/14/2017 11:46:38 +00:00\r\n\tUser Hash: 4uMjdux6PlbHohqQSPfTCHKRPTSuusBeoflGpyYQ1ps=\r\n\t\r\n\r\nDEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : \r\nDEBUG: 11/14/2017 11:16:55:  - TokenCache: Serializing token cache with 6 items.\r\n\r\nDEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : \r\nDEBUG: 11/14/2017 11:16:55: 6fbd5187-9561-4284-9b57-1c3b5512956d - AcquireTokenHandlerBase: === Token Acquisition started:\r\n\tAuthority: https://login.microsoftonline.com/5ed1d584-3cdd-4f8b-87b5-515a23e7e65e/\r\n\tResource: https://management.core.windows.net/\r\n\tClientId: 1950a258-227b-4e31-a9cf-717495945fc2\r\n\tCacheType: Microsoft.Azure.Commands.Common.Authentication.AuthenticationStoreTokenCache (6 items)\r\n\tAuthentication Target: User\r\n\t\r\n\r\nDEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : \r\nDEBUG: 11/14/2017 11:16:55: 6fbd5187-9561-4284-9b57-1c3b5512956d - TokenCache: Looking up cache for a token...\r\n\r\nDEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : \r\nDEBUG: 11/14/2017 11:16:55: 6fbd5187-9561-4284-9b57-1c3b5512956d - TokenCache: An item matching the requested resource was found in the cache\r\n\r\nDEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Verbose: 1 : \r\nDEBUG: 11/14/2017 11:16:55: 6fbd5187-9561-4284-9b57-1c3b5512956d - TokenCache: 29.7241557933333 minutes left until token in cache expires\r\n\r\nDEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : \r\nDEBUG: 11/14/2017 11:16:55: 6fbd5187-9561-4284-9b57-1c3b5512956d - TokenCache: A matching item (access token or refresh token or both) was found in the c\r\nache\r\n\r\nDEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : \r\nDEBUG: 11/14/2017 11:16:55: 6fbd5187-9561-4284-9b57-1c3b5512956d - AcquireTokenHandlerBase: === Token Acquisition finished successfully. An access token \r\nwas retuned:\r\n\tAccess Token Hash: vqZ9QV1qyjNrjiISc/Ym8W7r3RSLJpKelruP+3vwbTg=\r\n\tRefresh Token Hash: VDR4u6C0ZYqv1GBz/FdeF9w0pTZ35mMuhTOIrf9s/Sg=\r\n\tExpiration Time: 11/14/2017 11:46:38 +00:00\r\n\tUser Hash: 4uMjdux6PlbHohqQSPfTCHKRPTSuusBeoflGpyYQ1ps=\r\n\t\r\n\r\nDEBUG: Microsoft.IdentityModel.Clients.ActiveDirectory Information: 2 : \r\nDEBUG: 11/14/2017 11:16:55:  - TokenCache: Serializing token cache with 6 items.\r\n\r\nDEBUG: ============================ HTTP REQUEST ============================\r\n\r\nHTTP Method:\r\nPUT\r\n\r\nAbsolute Uri:\r\nhttps://management.azure.com/subscriptions/8d6baaa6-0ec4-49fd-acfa-55c3194e32dd/resourcegroups/functions/providers/microsoft.insights/alertrules/functest\r\n?api-version=2016-03-01\r\n\r\nHeaders:\r\nx-ms-client-request-id        : f11fbc53-a7a8-4567-ba09-cc123809fe9e\r\naccept-language               : en-US\r\n\r\nBody:\r\n{\r\n  \"properties\": {\r\n    \"name\": \"functest\",\r\n    \"description\": \"This metric alert rule was created from Powershell version: 4.0.0\",\r\n    \"isEnabled\": true,\r\n    \"condition\": {\r\n      \"odata.type\": \"Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition\",\r\n      \"operator\": \"GreaterThan\",\r\n      \"threshold\": 100.0,\r\n      \"windowSize\": \"PT5M\",\r\n      \"timeAggregation\": \"Total\",\r\n      \"dataSource\": {\r\n        \"odata.type\": \"Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource\",\r\n        \"metricName\": \"FunctionExecutionCount\",\r\n        \"resourceUri\": \"/subscriptions/8d6baaa6-0ec4-49fd-acfa-55c3194e32dd/resourceGroups/functions/providers/Microsoft.Web/sites/funcappstdplan\"\r\n      }\r\n    }\r\n  },\r\n  \"location\": \"westus\",\r\n  \"tags\": {\r\n    \"$type\": \"Microsoft.WindowsAzure.Management.Common.Storage.CasePreservedDictionary,Microsoft.WindowsAzure.Management.Common.Storage\",\r\n    \"hidden-link:/subscriptions/8d6baaa6-0ec4-49fd-acfa-55c3194e32dd/resourceGroups/functions/providers/Microsoft.Web/sites/funcappstdplan\": \"Resource\"\r\n  }\r\n}\r\n\r\n\r\nDEBUG: ============================ HTTP RESPONSE ============================\r\n\r\nStatus Code:\r\nBadRequest\r\n\r\nHeaders:\r\nPragma                        : no-cache\r\nStrict-Transport-Security     : max-age=31536000; includeSubDomains\r\nx-ms-request-id               : 00000000-0000-0000-0000-000000000000\r\nx-ms-ratelimit-remaining-subscription-writes: 1195\r\nx-ms-correlation-request-id   : 0a9e5112-d5f7-43b6-b346-8d82ca7c83ba\r\nx-ms-routing-request-id       : SOUTHINDIA:20171114T111700Z:0a9e5112-d5f7-43b6-b346-8d82ca7c83ba\r\nCache-Control                 : no-cache\r\nDate                          : Tue, 14 Nov 2017 11:16:59 GMT\r\nServer                        : Microsoft-IIS/8.5\r\n\r\nBody:\r\n{\r\n  \"code\": \"UnsupportedMetric\",\r\n  \"message\": \"The metric with namespace '' and name 'FunctionExecutionCount' is not supported for this resource id '/subscriptions/8d6baaa6-0ec4-49fd-acf\r\na-55c3194e32dd/resourceGroups/functions/providers/Microsoft.Web/sites/funcappstdplan'.\"\r\n}\r\n\r\n\r\nAdd-AzureRmMetricAlertRule : Exception type: ErrorResponseException, Message: The metric with namespace '' and name 'FunctionExecutionCount' is not \r\nsupported for this resource id \r\n'/subscriptions/8d6baaa6-0ec4-49fd-acfa-55c3194e32dd/resourceGroups/functions/providers/Microsoft.Web/sites/funcappstdplan'., Code: UnsupportedMetric, \r\nStatus code:BadRequest, Reason phrase: Bad Request\r\nAt line:1 char:1\r\n+ Add-AzureRmMetricAlertRule -ResourceGroup functions -TargetResourceId ...\r\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n    + CategoryInfo          : CloseError: (:) [Add-AzureRmMetricAlertRule], PSInvalidOperationException\r\n    + FullyQualifiedErrorId : Microsoft.Azure.Commands.Insights.Alerts.AddAzureRmMetricAlertRuleCommand\r\n \r\nDEBUG: AzureQoSEvent: CommandName - Add-AzureRmMetricAlertRule; IsSuccess - False; Duration - 00:00:05.1417806; Exception - System.Management.Automation.\r\nPSInvalidOperationException: Exception type: ErrorResponseException, Message: The metric with namespace '' and name 'FunctionExecutionCount' is not suppo\r\nrted for this resource id '/subscriptions/8d6baaa6-0ec4-49fd-acfa-55c3194e32dd/resourceGroups/functions/providers/Microsoft.Web/sites/funcappstdplan'., C\r\node: UnsupportedMetric, Status code:BadRequest, Reason phrase: Bad Request ---> Microsoft.Azure.Management.Monitor.Management.Models.ErrorResponseExcepti\r\non: Operation returned an invalid status code 'BadRequest'\r\n   at Microsoft.Azure.Management.Monitor.Management.AlertRulesOperations.<CreateOrUpdateWithHttpMessagesAsync>d__5.MoveNext()\r\n   --- End of inner exception stack trace ---\r\n   at Microsoft.Azure.Commands.Insights.MonitorCmdletBase.ExecuteCmdlet()\r\n   at Microsoft.WindowsAzure.Commands.Utilities.Common.AzurePSCmdlet.ProcessRecord();\r\nDEBUG: Finish sending metric.\r\nDEBUG: 4:47:00 PM - AddAzureRmMetricAlertRuleCommand end processing.\r\nDEBUG: 4:47:00 PM - AddAzureRmMetricAlertRuleCommand end processing.\r\n\r\n### Script/Steps for Reproduction\r\n1) Create a function app with a Standard App service plan or a consumption plan\r\n2) Execute the following powershell command:\r\nAdd-AzureRmMetricAlertRule -ResourceGroup functions -TargetResourceId \"/subscriptions/8d6baaa6-0ec4-49fd-acfa-55c3194e32dd/resourceGroups/functions/providers/Microsoft.Web/sites/funcappstdplan\" -MetricName \"FunctionExecutionCount\" -Name \"functest\" -WindowSize 00:05:00 -TimeAggregationOperator Total -Operator GreaterThan -Threshold \"100\" -Location \"westus\""},"comment":{"url":"https://api.github.com/repos/Azure/azure-powershell/issues/comments/425205721","html_url":"https://github.com/Azure/azure-powershell/issues/4983#issuecomment-425205721","issue_url":"https://api.github.com/repos/Azure/azure-powershell/issues/4983","id":425205721,"node_id":"MDEyOklzc3VlQ29tbWVudDQyNTIwNTcyMQ==","user":{"login":"amjad","id":1428634,"node_id":"MDQ6VXNlcjE0Mjg2MzQ=","avatar_url":"https://avatars2.githubusercontent.com/u/1428634?v=4","gravatar_id":"","url":"https://api.github.com/users/amjad","html_url":"https://github.com/amjad","followers_url":"https://api.github.com/users/amjad/followers","following_url":"https://api.github.com/users/amjad/following{/other_user}","gists_url":"https://api.github.com/users/amjad/gists{/gist_id}","starred_url":"https://api.github.com/users/amjad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/amjad/subscriptions","organizations_url":"https://api.github.com/users/amjad/orgs","repos_url":"https://api.github.com/users/amjad/repos","events_url":"https://api.github.com/users/amjad/events{/privacy}","received_events_url":"https://api.github.com/users/amjad/received_events","type":"User","site_admin":false},"created_at":"2018-09-27T18:58:43Z","updated_at":"2018-09-27T18:58:43Z","author_association":"NONE","body":"@asheniam Is there an update on this?"}}
{"actor":{"display_login":"amjad"}}