Enable Schema Validation and Required Fields for JSON in Azure Logic Apps

posted on 27 Aug 2018 | Azure

Logic Apps is pretty accommodating about the format of the json you supply to an HTTP trigger and doesn't by default warn you when it doesn't match the schema you've specified.

Here's how to enable schema validation and additionally specify required properties in that json schema to help you more easily catch issues in your input data.

  • Open the settings for the HTTP Trigger (click the ellipsis to open the menu):

Opening the HTTP Trigger Settings

  • Toggle on Schema Validation (it's off by default):

Enabling Schema Validation

  • Add a "required" array after the property definition segment of the json schema and specify which properties should always be present in the json input:

Setting Required JSON Properties

By default json properties are treated as nullable, so it's the combination of enabling schema validation and specifying the required values that can quickly help you pinpoint issues with input data that isn't formatted like you're expecting.

The required properties setting can be used on any action that lets you specify the schema of the JSON you're working with, a good example being the Parse JSON action.

If you're unfamiliar with how to create a JSON Schema for use in Logic Apps, you can create one quickly using the "Use sample payload to generate schema" link on the Logic Apps actions that accept JSON input, but for a more in depth walk through, Michael Crump has a good post here: https://www.michaelcrump.net/azure-tips-and-tricks38/

comments powered by Disqus