修改Azure ARM虚拟网络参数后遇InvalidJson错误求助
Got it, let's break down why you're seeing that error and how to fix it quickly.
The Root Cause
You've correctly set up your addressPrefix parameter as an array of multiple CIDRs, but the way you're referencing it in the virtual network template is creating an invalid JSON structure. Here's what's happening:
- Your parameter is an array:
"parameters": { "addressPrefix": { "value": [ "10.18.0.0/17", "10.90.0.0/19" ] }, ... } - But in your template, you're wrapping this array parameter inside another set of brackets:
"properties": { "addressSpace": { "addressPrefixes": [ "[parameters('addressPrefix')]" ] }, ... }
When the ARM template engine processes this, it replaces [parameters('addressPrefix')] with your array of CIDRs. That leaves you with:
"addressPrefixes": [ ["10.18.0.0/17", "10.90.0.0/19"] ]
The addressPrefixes property expects an array of strings, not an array containing another array. This mismatch is exactly what's causing the "Unexpected character encountered while parsing value: [" error.
The Simple Fix
Just remove the outer brackets around the parameter reference. Your corrected template section should look like this:
"properties": { "addressSpace": { "addressPrefixes": "[parameters('addressPrefix')]" }, ... }
Now, when evaluated, addressPrefixes will directly be your array of CIDR strings, which fits the required schema perfectly.
Why It Worked for LocalNetworkGateways
My guess is that in your local network gateway template, you didn't wrap the parameter in those extra brackets. The localNetworkAddressSpace.addressPrefixes property also expects an array of strings, so using the parameter directly (without the outer []) was the correct approach there—same as what we're fixing here.
内容的提问来源于stack exchange,提问作者irom

