question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

JSON parameters are not parsed correctly using CMD

See original GitHub issue

It seems to be parsing this incorrectly and I’m not sure why?

az vmss extension set --publisher Microsoft.Azure.Extensions --version 2.0 --name CustomScript --resource-group vmss-test-1 --vmss-name myscaleset --settings '{"commandToExecute": "apt-get -y update && apt-get -y install nginx"}'

az: error: unrecognized arguments: apt-get -y update && apt-get -y install nginx}'

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:12 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
tjprescottcommented, Mar 30, 2017

For the meantime, I’ve confirmed this works:

python -m azure.cli vmss extension set --publisher Microsoft.Azure.Extensions --version 2.0 --name CustomScript -g tjp-vmss --vmss-name vmss1 --settings "{\"commandToExecute\": \"apt-get -y update ^&^& apt-get -y install nginx\"}"

You need to escape the & with ^, and you have to replace az with python -m azure.cli. I will see if we can fix this through a tweak to az.bat

0reactions
rghertacommented, Sep 5, 2019

I am sorry for the flashback but I am having issues passing --indexing-policy to cosmosdb as a string. I get all sorts of errors. I saw this statement –settings @settings.json

But I do not understand how exactly should I use it… let’s say I save my json to disk as “C:\path\my.json” . How exactly do I pass this file as parameter? If I put the path as a string or not, it simply fails at first character, even less info compared to when I pass the json as string argument. What exactly is that fancy @ sign and what is the step by step procedure to give a disk file as argument to one of the azure cli commands.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Passing JSON Parameters on the Command Line
Here you'll find examples of correct escaping and quotes when passing JSON objects on the command line using different shells.
Read more >
Pass a JSON string as a command line argument
Declare it as a string with "" and escape the other " with \ and it should work. Command line:
Read more >
[SOLVED] Problems with JSON parsing errors - Ubidots API
I want to test setting a variable to a value. My device is called mqttdata and the variable is called number. My curl...
Read more >
Parsing JSON with PowerShell - Microsoft Community Hub
Q: I try to parse my JSON with the handy dandy “ConvertFrom-JSON” cmdlet but it only works in PowerShell 7, not in my...
Read more >
SyntaxError: JSON.parse: bad parsing - JavaScript | MDN
You cannot use single-quotes around properties, like 'foo'. JSON.parse("{'foo': 1}"); ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found