conditions JSON format required is not syntactically correct JSON
Description
Outline the issue here:
The only JSON which the Azure cloud will accept for creating a Monitoring rule is as below:
{ "dataSource": { "odata.type": "Microsoft.Azure.Management.Insights.Models.RuleMetricDataSource", "resourceUri": "/subscriptions/your_subscription/resourceGroups/your_resource_group/providers/Microsoft.Compute/virtualMachines/hcm99mon01", "metricName": "Percentage CPU", }, "odata.type": "Microsoft.Azure.Management.Insights.Models.ThresholdRuleCondition", "threshold" : 60, "operator": "GreaterThan", "windowSize" : "PT5M", "timeAggregation": "Average" }
The comma after "metricName": "Percentage CPU",
is not correct JSON as there are no items following the comma. Yet the Azure cloud will say "poorly formed request" when the comma is removed.
The JSON code above will work in Azure cloud to create a metric based rule.
But will fail JSON validation at the JSON validation LINT site:
https://jsonlint.com/
Environment summary
Install Method: How did you install the CLI? (e.g. pip, interactive script, apt-get, Docker, MSI, nightly)
Answer here:
Nightly then installed public / bash
CLI Version: What version of the CLI and modules are installed? (Use az --version)
Answer here:
3.0.2
Monitor 0.0.3
OS Version: What OS and version are you using?
Answer here:
macOS Sierra
Shell Type: What shell are you using? (e.g. bash, cmd.exe, Bash on Windows)
Answer here:
csh
I tested this on CMD.exe (Windows) with both variants and it worked fine. It might be a peculiarity with your shell. Right now the CLI only officially supports CMD.exe, bash and zsh. I'll try it out on bash as well.
When I run this on bash (Mac) without the comma, the request succeeds. If I run it with the extra comma I get the following error:
EOL while scanning string literal: "metricName": "Percentage CPU",
Interesting.
Must be the CLI Version which I am running.
I for the life of me could not get it to work without that comma at the end.
Maybe try the vanilla Public build and see how that one goes?
I think my installation is a mix of Public build and the newer 0.0.3 Monitoring.
On 5/2/17 2:35 PM, Travis Prescott wrote:
When I run this on bash (Mac) without the comma, the request succeeds. If I run it with the extra comma I get the following error:
|EOL while scanning string literal: "metricName": "Percentage CPU", |
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/Azure/azure-cli/issues/3135#issuecomment-298768425, or mute the thread https://github.com/notifications/unsubscribe-auth/AA64_HMfQ30rX0jvV5HTfQxO_QEuoa4Wks5r16GVgaJpZM4NOkoX.
Could be. I did a fresh pip install of the latest public build and it worked.
My az --version for reference:
azure-cli (2.0.4)
acr (2.0.2)
acs (2.0.4)
appservice (0.1.4)
batch (2.0.2)
cloud (2.0.2)
command-modules-nspkg (2.0.0)
component (2.0.2)
configure (2.0.4)
container (0.1.4)
core (2.0.4)
documentdb (0.1.4)
feedback (2.0.2)
find (0.2.1)
iot (0.1.4)
keyvault (2.0.2)
lab (0.0.3)
monitor (0.0.3)
network (2.0.4)
nspkg (3.0.0)
profile (2.0.4)
redis (0.2.1)
resource (2.0.4)
role (2.0.3)
sql (2.0.2)
storage (2.0.4)
vm (2.0.4)
Python (Windows) 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)]
Ah 2.0.4 now
:-)
On May 2, 2017, at 3:06 PM, Travis Prescott [email protected] wrote:
Could be. I did a fresh pip install of the latest public build and it worked.
My az --version for reference:
azure-cli (2.0.4)
acr (2.0.2) acs (2.0.4) appservice (0.1.4) batch (2.0.2) cloud (2.0.2) command-modules-nspkg (2.0.0) component (2.0.2) configure (2.0.4) container (0.1.4) core (2.0.4) documentdb (0.1.4) feedback (2.0.2) find (0.2.1) iot (0.1.4) keyvault (2.0.2) lab (0.0.3) monitor (0.0.3) network (2.0.4) nspkg (3.0.0) profile (2.0.4) redis (0.2.1) resource (2.0.4) role (2.0.3) sql (2.0.2) storage (2.0.4) vm (2.0.4)
Python (Windows) 3.5.1 (v3.5.1:37a07cee5969, Dec 6 2015, 01:38:48) [MSC v.1900 32 bit (Intel)] — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.
Yeah, but it's 2.0.5 2.0.6 that you want that won't be super crappy. 2.0.4 is only slightly less crappy.