title: Logic App bypass Null in filter query
body: <p>I am building a Logic App that uses the Azure Resource connector to obtain a list of my resources. I would then like to filter the results to <code>Microsoft.Compute</code> resources that have a tag name and value of <code>stop</code> and <code>normal</code>.</p>
  
  <p>Here is a snippet of resource that I receive back <strong>without</strong> any filters</p>
  
  <pre><code>{
      "id": "/subscriptions/&lt;subscription&gt;/resourceGroups/Env1/providers/Microsoft.Compute/virtualMachines/MyVM1",
      "name": "MyVM1",
      "type": "Microsoft.Compute/virtualMachines",
      "location": "westeurope",
      "tags": {
          "stop": "normal"
      }
  },
  {
      "id": "/subscriptions/&lt;subscription&gt;/resourceGroups/LogicApp/providers/Microsoft.Logic/workflows/DWSize-Check",
      "name": "DWSize-Check",
      "type": "Microsoft.Logic/workflows",
      "location": "westeurope",
      "tags": {}
  }
  </code></pre>
  
  <p>As you can see, the bottom resource does not contain any tags, as with many others that will appear in the list</p>
  
  <p>I use the standard <code>Compose</code> <code>Filter Array</code> connector to try and filter out from the <code>value</code> I receive back.</p>
  
  <p>Here is the code that I wish to use for the filter command:</p>
  
  <pre><code>@and(contains(item()?['id'], '/Microsoft.Compute/virtualMachines/'), contains(item()?['tags'], variables('TagName')), contains(item()?['tags'], variables('TagValue')))
  </code></pre>
  
  <p><code>variables('TagName')</code> and <code>variables('TagValue')</code> will be <code>stop</code> and <code>normal</code>, as show in the example tags listed in my results snippet.</p>
  
  <p>However, because there is no tag values listed in other resources, such as <code>Microsoft.Logic/workflows</code>, I receive the following <code>null</code> error:</p>
  
  <blockquote>
    <p>InvalidTemplate. The execution of template action 'Filter_array'
    failed: The evaluation of 'query' action 'where' expression
    '@contains(item()?['tags'], variables('TagValue'))' failed: 'The
    template language function 'contains' expects its first argument
    'collection' to be a dictionary (object), an array or a string. The
    provided value is of type 'Null'.'.</p>
  </blockquote>
  
  <p>Would anyone know how to get around this?</p>
  
  <p>I have tried similar queries to this <code>@contains(item().tags?.stop, variables('TagValue'))</code> just to see if it picks up anything, but I'm still blocked by a <code>null</code> response  :(</p>
  
  <p>I tried the above with the help of the <a href="https://docs.microsoft.com/en-us/azure/logic-apps/logic-apps-workflow-definition-language" rel="nofollow noreferrer">Workflow Definition Language</a>, but still no dice. Any help would be greatly appreciated.</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>In addition to the answer posted by Thomas, I have performed the following (image below) to filter out <code>null</code> from the results and get to the <code>TagName</code>, but I am still unable to get to the <code>TagValue</code>, even if I use <em>contains</em>: </p>
  
  <p><code>@and(contains(item()?['tags'], variables('TagName')), contains(item()?['tags'], variables('TagValue')))</code></p>
  
  <p>or event just trying to look for <code>TagValue</code></p>
  
  <p><code>@contains(item()?['tags'], variables('TagValue'))</code></p>
  
  <p><a href="https://i.stack.imgur.com/MQahH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MQahH.jpg" alt="Filtered"></a></p>