Home > Software design >  Azure JMESPATH query for nested json
Azure JMESPATH query for nested json

Time:10-23

I'm trying to extract just the paths portion of the result of this AZ CLI query:

az network application-gateway show --query urlPathMaps --resource-group dev-aag --name dev-aag-gateway

I'm unsure if I should use az network application-gateway list instead

This is the result of the first query, however I'm not able to extract just the paths portion -- is this because paths is nested?

        "backendAddressPool": {
          "id": "/subscriptions/42xxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/dev-aag/providers/Microsoft.Network/applicationGateways/dev-aag-gateway/backendAddressPools/co20225020a-backend-pool",
          "resourceGroup": "dev-aag"
        },
        "backendHttpSettings": {
          "id": "/subscriptions/42xxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/dev-aag/providers/Microsoft.Network/applicationGateways/dev-aag-gateway/backendHttpSettingsCollection/dev-aag-httpsetting",
          "resourceGroup": "dev-aag"
        },
        "etag": "W/\"9f2d3xxc-2cbd-49fr-8726-432c7ef00de7\"",
        "firewallPolicy": null,
        "id": "/subscriptions/42xxxxxxxxxxxxxxxxxxxxxxx/resourceGroups/dev-aag/providers/Microsoft.Network/applicationGateways/dev-aag-gateway/urlPathMaps/dev-aag-https-routing-rule/pathRules/co20225020a-cqvgkj9xxxxx9bcu-url",
        "loadDistributionPolicy": null,
        "name": "co20225020a-cqvgkj9xxxxx9bcu-url",
        "paths": [
          "/co20225020a/cqvgkj9xxxxx9bcu/*"
        ],
        "provisioningState": "Succeeded",
        "redirectConfiguration": null,
        "resourceGroup": "dev-aag",
        "rewriteRuleSet": null,
        "type": "Microsoft.Network/applicationGateways/urlPathMaps/pathRules"
      }

I'm trying to use grep and cut like this, but maybe something else I should be using instead:

az network application-gateway show --query urlPathMaps --resource-group dev-aag --name dev-aag-gateway | grep paths | cut -d ":" -f1-19

what should I be using to make this work?

CodePudding user response:

  • az network application-gateway list -->Can used if you want to list all the application gateways under a particular subscription.
  • az network application-gateway show --> should be used if you want to pull the properties of a particular app gateway.

Refer to this articles for more information about enter image description here

  • Related