title: AZ CLI query filter on multiple properties using &&
body: <p>I am trying to create an az cli query that can evaluate if I am logged into the correct tenant and subscription. I know I have to use the <code>?</code> and <code>&amp;&amp;</code> operators but have not been able to get them in the correct combination yet that will work. When I query for just a single value using the line below, works fine:</p>
  
  <pre><code>az account list --query "[?id=='my_subscription_id']" --output json
  </code></pre>
  
  <p>But when I try either of the lines below, it tells me it is invalid jmespath_type value:</p>
  
  <pre><code>az account list --query "[?id=='my_subscription_id' &amp;&amp; ?tenantId=='my_tenant_id']"  --output json
  az account list --query "[(?id=='my_subscription_id') &amp;&amp; (?tenantId=='my_tenant_id')]"  --output json
  </code></pre>
  
  <p>when I try the line below, it gives me the error <code>] was unexpected at this time</code>:</p>
  
  <pre><code>az account list --query "[(?id=='my_subscription_id')&amp;&amp;(?tenantId=='my_tenant_id')]"  --output json
  </code></pre>
  
  <p>I know this can be done, just can't seem to find the right mixture yet.</p>
  
  <p>UPDATED INFO:</p>
  
  <p>Upon further testing, I made some progress but still not exactly what I was expecting. Assume that the tenant ID is 123, the subscription ID of the sub I am wanting is ABC and  my account also has access to the subscription ID EFG. When running the command below:</p>
  
  <pre><code>az account list --query "[].{subscriptionId:id,tenantId:tenantId}"
  </code></pre>
  
  <p>I get the output:</p>
  
  <pre><code>  {
      "subscriptionId": "ABC",
      "tenantId": "123"
    },
    {
      "subscriptionId": "EFG",
      "tenantId": "123"
    }
  </code></pre>
  
  <p>I would expect that running the command below, would return just the single record that matches:</p>
  
  <pre><code>az account list --query "[?id == 'ABC' &amp;&amp; tenantid == '123'].{subscriptionId:id,tenantId:tenantId}" --output json
  </code></pre>
  
  <p>But, it does not. It returns <code>[]</code>.</p>
  
  <p>Running the command below returns the single record that matches both conditions:</p>
  
  <pre><code>az account list --query "[?id == 'ABC' || tenantid == '123'].{subscriptionId:id,tenantId:tenantId}" --output json
  </code></pre>
  
  <p>Based on the documentation, <code>&amp;&amp;</code> is an AND, and <code>||</code> is an OR. I would think when running the command line that has the <code>||</code> in it would return BOTH records but it only returns the one that contains both values.</p>