Azure / azure-cli

Azure Command-Line Interface
MIT License
3.95k stars 2.93k forks source link

deployment valdiate doesn't validate properly. #4511

Open siennathesane opened 6 years ago

siennathesane commented 6 years ago

Description

When calling az group deployment validate g "test-01" --template-file .\azuredeploy.json --parameters .\azuredeploy-test-params.json, it returns no errors. When az group deployment create is called with the same parameters, it fails with InvalidRequestFormat.

Here is a subset of the template:

{
      "name": "pcf",
      "type": "Microsoft.Network/virtualNetworks",
      "apiVersion": "2017-03-01",
      "location": "[parameters('location')]",
      "tags": {
        "Environment": "[parameters('environment')]"
      },
      "properties": {
        "addressSpace": {
          "addressPrefixes": [
            "10.0.0.0/16"
          ]
        },
        "subnets": [
          {
            "name": "Management",
            "properties": {
              "addressPrefix": "10.0.4.0/22",
              "location": "[parameters('location')]",
              "tags": {
                "Environment": "[parameters('environment')]"
              },
              "properties": {
                "networkSecurityGroup": {
                  "securityRules": [
                    {
                      "properties": {
                        "description": "Allow Inbound HTTP/S",
                        "protocol": "*",
                        "sourcePortRange": "*",
                        "destinationPortRange": "80,443",
                        "sourceAddressPrefix": "*",
                        "destinationAddressPrefix": "*",
                        "access": "Allow",
                        "priority": 1400,
                        "direction": "Inbound"
                      },
                      "name": "Allow-Web"
                    }
                  ]
                }
              }
            }
          }
        ]
      }
    }

Here is an example of the failure:

Deployment failed. {
  "error": {
    "code": "InvalidRequestFormat",
    "message": "Cannot parse the request.",
    "details": [
      {
        "code": "InvalidJson",
        "message": "Could not find member 'location' on object of type 'SubnetProperties'. Path 'properties.subnets[0].properties.location', line 1, position 202."
      },
      {
        "code": "InvalidJson",
        "message": "Could not find member 'tags' on object of type 'SubnetProperties'. Path 'properties.subnets[0].properties.tags', line 1, position 218."
      },
      {
        "code": "InvalidJson",
        "message": "Could not find member 'properties' on object of type 'SubnetProperties'. Path 'properties.subnets[0].properties.properties', line 1, position 253."
      }
    ]
  }
}

Environment summary

Install Method: How did you install the CLI? (e.g. pip, interactive script, apt-get, Docker, MSI, nightly)
Answer here: MSI

CLI Version: What version of the CLI and modules are installed? (Use az --version)

PS C:\Users\MikeLloyd\Development\azure\pcf-azure-arm-templates> az --version
azure-cli (2.0.16)

acr (2.0.11)
acs (2.0.14)
appservice (0.1.15)
batch (3.1.2)
billing (0.1.4)
cdn (0.0.7)
cloud (2.0.7)
cognitiveservices (0.1.7)
command-modules-nspkg (2.0.1)
component (2.0.7)
configure (2.0.10)
consumption (0.1.4)
container (0.1.9)
core (2.0.15)
cosmosdb (0.1.12)
dla (0.0.11)
dls (0.0.13)
eventgrid (0.1.3)
feedback (2.0.6)
find (0.2.6)
interactive (0.3.9)
iot (0.1.11)
keyvault (2.0.9)
lab (0.0.10)
monitor (0.0.9)
network (2.0.13)
nspkg (3.0.1)
profile (2.0.11)
rdbms (0.0.6)
redis (0.2.8)
resource (2.0.13)
role (2.0.11)
servicefabric (0.0.3)
sf (1.0.8)
sql (2.0.10)
storage (2.0.14)
vm (2.0.13)

Python (Windows) 3.6.1 (v3.6.1:69c0db5, Mar 21 2017, 17:54:52) [MSC v.1900 32 bit (Intel)]

Python location 'C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\python.exe'

Legal docs and information: aka.ms/AzureCliLegal

OS Version: What OS and version are you using?
Answer here: image

Shell Type: What shell are you using? (e.g. bash, cmd.exe, Bash on Windows)
Answer here:

PS C:\Users\MikeLloyd\Development\azure\pcf-azure-arm-templates> $PSVersionTable

Name                           Value
----                           -----
PSVersion                      5.1.15063.608
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.15063.608
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
yugangw-msft commented 5 years ago

This will be addressed as part of the enhancement ARM team is making on the validate API

ghost commented 5 years ago

Thanks for the feedback! We are routing this to the appropriate team for follow-up. cc @armleads-azure

abatishchev commented 2 years ago

@yugangw-msft shall this issue be closed if addressed?