{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "definitions": {
    "bindingBase": {
      "properties": {
        "name": {
          "type": "string"
        },
        "type": {
          "type": "string"
        },
        "direction": {
          "type": "string",
          "enum": ["in", "out", "inout"]
        },
        "dataType": {
          "enum": ["string", "binary", "stream"],
          "description": "The data type hint for the binding parameter (string, binary, or stream)."
        }
      },
      "required": ["name", "type", "direction"]
    },
    "dynamicBinding": {
      "properties": {
        "type": {
          "not": {
            "enum": [
              "serviceBusTrigger",
              "serviceBus",
              "blobTrigger",
              "blob",
              "manualTrigger",
              "eventHubTrigger",
              "eventHub",
              "timerTrigger",
              "queueTrigger",
              "queue",
              "httpTrigger",
              "http",
              "mobileTable",
              "documentDB",
              "table",
              "notificationHub",
              "twilioSms",
              "sendGrid",
              "sql",
              "sqlTrigger",
              "kusto"
            ]
          }
        },
        "direction": {
          "enum": ["in", "out", "inout"]
        }
      }
    },
    "serviceBusBinding": {
      "properties": {
        "queueName": {
          "type": "string",
          "description": "The service bus queue to monitor (if using a queue)"
        },
        "topicName": {
          "type": "string",
          "description": "The service bus topic to monitor (if using a queue)"
        },
        "subscriptionName": {
          "type": "string",
          "description": "The topic subscription name"
        },
        "connection": {
          "type": "string",
          "description": "An app setting (or environment variable) with the service bus connection string to be used by this binding."
        },
        "accessRights": {
          "type": "string",
          "description": "The permission level of the service bus connection string used by this binding.",
          "enum": ["manage", "listen", "send"]
        }
      },
      "oneOf": [
        {
          "properties": {
            "type": {
              "enum": ["serviceBusTrigger"]
            },
            "direction": {
              "enum": ["in"]
            }
          }
        },
        {
          "properties": {
            "type": {
              "enum": ["serviceBus"]
            },
            "direction": {
              "enum": ["out"]
            }
          }
        }
      ]
    },
    "blobBinding": {
      "properties": {
        "path": {
          "type": "string",
          "description": "The path to the blob container"
        },
        "connection": {
          "type": "string",
          "description": "An app setting (or environment variable) with the storage connection string to be used by this binding."
        }
      },
      "oneOf": [
        {
          "properties": {
            "type": {
              "enum": ["blobTrigger"]
            },
            "direction": {
              "enum": ["in"]
            }
          }
        },
        {
          "properties": {
            "type": {
              "enum": ["blob"]
            }
          }
        }
      ]
    },
    "manualTriggerBinding": {
      "properties": {
        "type": {
          "enum": ["manualTrigger"]
        },
        "direction": {
          "enum": ["in"]
        }
      }
    },
    "eventHubBinding": {
      "properties": {
        "path": {
          "type": "string",
          "description": "The event hub path."
        },
        "connection": {
          "type": "string",
          "description": "The event hub connection string setting."
        }
      },
      "oneOf": [
        {
          "properties": {
            "type": {
              "enum": ["eventHubTrigger"]
            },
            "direction": {
              "enum": ["in"]
            },
            "consumerGroup": {
              "type": "string",
              "description": "The event hub consumer group."
            },
            "cardinality": {
              "enum": ["one", "many"],
              "description": "The cardinality hint for the input binding parameter (single message or array of messages)."
            }
          }
        },
        {
          "properties": {
            "type": {
              "enum": ["eventHub"]
            },
            "direction": {
              "enum": ["out"]
            }
          }
        }
      ]
    },
    "timerTriggerBinding": {
      "properties": {
        "type": {
          "enum": ["timerTrigger"]
        },
        "direction": {
          "enum": ["in"]
        },
        "schedule": {
          "type": "string",
          "description": "A cron expression of the format '{second} {minute} {hour} {day} {month} {day of week}' to specify the schedule.",
          "pattern": "^(\\*|((([1-5]\\d)|\\d)(-(([1-5]\\d)|\\d)(/\\d+)?)?)(,((([1-5]\\d)|\\d)(-(([1-5]\\d)|\\d)(/\\d+)?)?))*)(/\\d+)? (\\*|((([1-5]\\d)|\\d)(-(([1-5]\\d)|\\d)(/\\d+)?)?)(,((([1-5]\\d)|\\d)(-(([1-5]\\d)|\\d)(/\\d+)?)?))*)(/\\d+)? (\\*|(((1\\d)|(2[0-3])|\\d)(-((1\\d)|(2[0-3])|\\d)(/\\d+)?)?)(,(((1\\d)|(2[0-3])|\\d)(-((1\\d)|(2[0-3])|\\d)(/\\d+)?)?))*)(/\\d+)? (\\*|((([1-2]\\d)|(3[0-1])|[1-9])(-(([1-2]\\d)|(3[0-1])|[1-9])(/\\d+)?)?)(,((([1-2]\\d)|(3[0-1])|[1-9])(-(([1-2]\\d)|(3[0-1])|[1-9])(/\\d+)?)?))*)(/\\d+)? (\\*|(([A-Za-z]+|(1[0-2])|[1-9])(-([A-Za-z]+|(1[0-2])|[1-9])(/\\d+)?)?)(,(([A-Za-z]+|(1[0-2])|[1-9])(-([A-Za-z]+|(1[0-2])|[1-9])(/\\d+)?)?))*)(/\\d+)? (\\*|(([A-Za-z]+|[0-6])(-([A-Za-z]+|[0-6])(/\\d+)?)?)(,(([A-Za-z]+|[0-6])(-([A-Za-z]+|[0-6])(/\\d+)?)?))*)(/\\d+)?$"
        },
        "runOnStartup": {
          "type": "boolean",
          "description": "When true, your timer function will be invoked immediately after a runtime restart and on-schedule thereafter."
        },
        "useMonitor": {
          "type": "boolean",
          "description": "When true, schedule will be persisted to aid in maintaining the correct schedule even through restarts. Defaults to true for schedules with interval >= 1 minute."
        }
      }
    },
    "queueBinding": {
      "properties": {
        "queueName": {
          "type": "string",
          "description": "The queue name."
        },
        "connection": {
          "type": "string",
          "description": "An app setting (or environment variable) with the storage connection string to be used by this binding."
        }
      },
      "oneOf": [
        {
          "properties": {
            "type": {
              "enum": ["queueTrigger"]
            },
            "direction": {
              "enum": ["in"]
            }
          }
        },
        {
          "properties": {
            "type": {
              "enum": ["queue"]
            },
            "direction": {
              "enum": ["out"]
            }
          }
        }
      ]
    },
    "httpTrigger": {},
    "httpBinding": {
      "oneOf": [
        {
          "properties": {
            "type": {
              "enum": ["httpTrigger"]
            },
            "direction": {
              "enum": ["in"]
            },
            "route": {
              "type": "string",
              "description": "The function HTTP route template."
            },
            "webHookType": {
              "type": "string",
              "description": "The type of WebHook handled by the trigger (if handling a pre-defined WebHook)."
            },
            "authLevel": {
              "type": "string",
              "default": "function",
              "enum": ["anonymous", "function", "admin"],
              "description": "The function HTTP authorization level."
            },
            "methods": {
              "type": "array",
              "items": [
                {
                  "type": "string",
                  "enum": [
                    "get",
                    "post",
                    "delete",
                    "head",
                    "patch",
                    "put",
                    "options",
                    "trace"
                  ]
                }
              ]
            }
          }
        },
        {
          "properties": {
            "type": {
              "enum": ["http"]
            },
            "direction": {
              "enum": ["out"]
            }
          }
        }
      ]
    },
    "mobileBinding": {
      "properties": {
        "type": {
          "enum": ["mobileTable"]
        },
        "tableName": {
          "type": "string",
          "description": "This is the name of the table within your Mobile App to which data will be written."
        },
        "connection": {
          "type": "string",
          "description": "This is the app setting name that specifies the URL of your Mobile App."
        },
        "apiKey": {
          "type": "string",
          "description": "This is app setting name that specifies the API Key for your Mobile App."
        }
      },
      "oneOf": [
        {
          "properties": {
            "direction": {
              "enum": ["in"]
            },
            "id": {
              "type": "string",
              "description": "This is the id for the record to retrieve."
            }
          }
        },
        {
          "properties": {
            "direction": {
              "enum": ["out"]
            }
          }
        }
      ]
    },
    "documentDBBinding": {
      "properties": {
        "type": {
          "enum": ["documentDB"]
        },
        "connection": {
          "type": "string",
          "description": "This is the connection string for your DocumentDB account."
        },
        "databaseName": {
          "type": "string",
          "description": "This is the name of the database within your DocumentDB account to which data will be written."
        },
        "collectionName": {
          "type": "string",
          "description": "This is the name of the collection within your database to which data will be written."
        }
      },
      "oneOf": [
        {
          "properties": {
            "direction": {
              "enum": ["in"]
            },
            "id": {
              "type": "string",
              "description": "This is the id for the record to retrieve."
            },
            "sqlQuery": {
              "type": "string",
              "description": "This is the query to run against the collection."
            }
          }
        },
        {
          "properties": {
            "direction": {
              "enum": ["out"]
            },
            "createIfNotExists": {
              "type": "boolean",
              "description": "When true, your database and collection will be created automatically."
            }
          }
        }
      ]
    },
    "tableBinding": {
      "properties": {
        "type": {
          "enum": ["table"]
        },
        "tableName": {
          "type": "string",
          "description": "The name of the storage table."
        },
        "partitionKey": {
          "type": "string",
          "description": "The partition key."
        },
        "rowKey": {
          "type": "string",
          "description": "The table row key."
        },
        "connection": {
          "type": "string",
          "description": "An app setting (or environment variable) with the storage connection string to be used by this binding."
        }
      },
      "oneOf": [
        {
          "properties": {
            "direction": {
              "enum": ["in"]
            },
            "take": {
              "type": "string",
              "description": "The number or records to retrieve."
            },
            "filter": {
              "type": "string",
              "description": "A filter expression to be applied when retrieving rows."
            }
          }
        },
        {
          "properties": {
            "direction": {
              "enum": ["out"]
            }
          }
        }
      ]
    },
    "notificationHubBinding": {
      "properties": {
        "type": {
          "enum": ["notificationHub"]
        },
        "direction": {
          "enum": ["out"]
        },
        "tagExpression": {
          "type": "string",
          "description": "The tag to send the notification to."
        },
        "hubName": {
          "type": "string",
          "description": "The name of the notification hub."
        },
        "connection": {
          "type": "string",
          "description": "The name of the app setting which contains the notification hub connection string."
        },
        "platform": {
          "type": "string",
          "description": "The notification platform to target. Sends template notification if platform is omitted.",
          "enum": ["apns", "adm", "gcm", "wns", "mpns"]
        }
      }
    },
    "twilioSmsBinding": {
      "properties": {
        "type": {
          "enum": ["twilioSms"]
        },
        "direction": {
          "enum": ["out"]
        },
        "accountSid": {
          "type": "string",
          "description": "The name of the app setting which contains your Twilio Account Sid."
        },
        "authToken": {
          "type": "string",
          "description": "The name of the app setting which contains your Twilio authentication token."
        },
        "to": {
          "type": "string",
          "description": "The phone number the SMS text is sent to."
        },
        "from": {
          "type": "string",
          "description": "The phone number the SMS text is sent from."
        },
        "body": {
          "type": "string",
          "description": "Optional body of SMS text message."
        }
      }
    },
    "sendGridBinding": {
      "properties": {
        "type": {
          "enum": ["sendGrid"]
        },
        "direction": {
          "enum": ["out"]
        },
        "apiKey": {
          "type": "string",
          "description": "The name of the app setting which contains your SendGrid api key."
        },
        "to": {
          "type": "string",
          "description": "The email address to send to."
        },
        "from": {
          "type": "string",
          "description": "The email address to send from."
        },
        "subject": {
          "type": "string",
          "description": "The subject of the email."
        },
        "text": {
          "type": "string",
          "description": "The text of the email."
        }
      }
    },
    "sqlBinding": {
      "properties": {
        "connectionStringSetting": {
          "type": "string",
          "description": "The name of the app setting that contains the SQL connection string used to connect to the database."
        }
      },
      "oneOf": [
        {
          "properties": {
            "type": {
              "enum": ["sqlTrigger"]
            },
            "tableName": {
              "type": "string",
              "description": "The name of the table to be monitored for changes."
            }
          }
        },
        {
          "properties": {
            "type": {
              "enum": ["sql"]
            },
            "direction": {
              "enum": ["in"]
            },
            "commandText": {
              "type": "string",
              "description": "Either a query string or the name of a stored procedure to execute."
            },
            "commandType": {
              "enum": ["text", "storedProcedure"],
              "description": "Whether the commandText is a query (text) or a stored procedure (storedProcedure)."
            },
            "parameters": {
              "type": "string",
              "description": "The parameters to the query or stored procedure."
            }
          }
        },
        {
          "properties": {
            "type": {
              "const": "sql"
            },
            "direction": {
              "const": "out"
            },
            "commandText": {
              "type": "string",
              "description": "The name of the table into which rows will be upserted."
            }
          }
        }
      ]
    },
    "kustoBinding": {
      "properties": {
        "connection": {
          "type": "string",
          "description": "Name of the app setting that contains the kusto connection string used to connect to kusto."
        },
        "database": {
          "type": "string",
          "description": "Name of the database within your kusto account to which data will be read/written."
        },
        "managedServiceIdentity": {
          "type": "string",
          "description": "A managed service identity that has to be attached to use the bindings."
        },
        "type": {
          "enum": ["kusto"]
        }
      },
      "oneOf": [
        {
          "properties": {
            "direction": {
              "enum": ["in"]
            },
            "kqlCommand": {
              "type": "string",
              "description": "The Kusto command to execute.Can be a KQL query or a KQL function with optional parameters."
            },
            "kqlParameters": {
              "type": "string",
              "description": "The parameters to the query or function. Named parameters are of the form @paramName=paramValue."
            }
          }
        },
        {
          "properties": {
            "direction": {
              "enum": ["out"]
            },
            "tableName": {
              "type": "string",
              "description": "The table to ingest the data into."
            },
            "mappingRef": {
              "type": "string",
              "description": "An ingestion mapping ref that points to the mapping created in kusto and referenced in ingestion (optional)."
            },
            "dataFormat": {
              "type": "string",
              "description": "Dataformat to use in ingestion.The default dataformat is `multijson/json`. This has been tested for text formats"
            }
          }
        }
      ]
    }
  },
  "id": "https://json.schemastore.org/function.json",
  "properties": {
    "disabled": {
      "type": "boolean",
      "description": "If set to true, marks the function as disabled (it cannot be triggered)."
    },
    "excluded": {
      "type": "boolean",
      "description": "If set to true, the function will not be loaded, compiled, or triggered."
    },
    "scriptFile": {
      "type": "string",
      "description": "Optional path to function script file."
    },
    "entryPoint": {
      "type": "string",
      "description": "Optional named entry point."
    },
    "configurationSource": {
      "enum": ["attributes", "config"],
      "description": "For C# precompiled functions only. If set to 'attributes', use WebJobs attributes to specify bindings. Otherwise, use the 'bindings' property of this function.json."
    },
    "retry": {
      "description": "Retry policy of function execution failures.",
      "type": "object",
      "properties": {
        "strategy": {
          "description": "Retry strategy to use for retrying function executions",
          "enum": ["exponentialBackoff", "fixedDelay"],
          "default": "exponentialBackoff"
        },
        "maxRetryCount": {
          "description": "The maximum number of retries allowed per function execution. -1 means to retry indefinitely.",
          "type": "integer"
        },
        "delayInterval": {
          "description": "Value indicating the delayInterval for function execution retries when using FixedDelay strategy.",
          "oneOf": [
            {
              "type": "string",
              "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d$"
            },
            {
              "enum": [null]
            }
          ]
        },
        "minimumInterval": {
          "description": "Value indicating the minimumInterval for function execution retries when using ExponentialBackoff strategy.",
          "oneOf": [
            {
              "type": "string",
              "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d$"
            },
            {
              "enum": [null]
            }
          ]
        },
        "maximumInterval": {
          "description": "Value indicating the maximumInterval for function execution retries when using ExponentialBackoff strategy.",
          "oneOf": [
            {
              "type": "string",
              "pattern": "^(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d$"
            },
            {
              "enum": [null]
            }
          ]
        }
      }
    },
    "bindings": {
      "type": "array",
      "description": "A list of function bindings.",
      "items": {
        "oneOf": [
          {
            "$ref": "#/definitions/dynamicBinding"
          },
          {
            "oneOf": [
              {
                "$ref": "#/definitions/serviceBusBinding"
              },
              {
                "$ref": "#/definitions/blobBinding"
              },
              {
                "$ref": "#/definitions/manualTriggerBinding"
              },
              {
                "$ref": "#/definitions/eventHubBinding"
              },
              {
                "$ref": "#/definitions/timerTriggerBinding"
              },
              {
                "$ref": "#/definitions/queueBinding"
              },
              {
                "$ref": "#/definitions/httpBinding"
              },
              {
                "$ref": "#/definitions/mobileBinding"
              },
              {
                "$ref": "#/definitions/documentDBBinding"
              },
              {
                "$ref": "#/definitions/tableBinding"
              },
              {
                "$ref": "#/definitions/notificationHubBinding"
              },
              {
                "$ref": "#/definitions/twilioSmsBinding"
              },
              {
                "$ref": "#/definitions/sendGridBinding"
              },
              {
                "$ref": "#/definitions/sqlBinding"
              },
              {
                "$ref": "#/definitions/kustoBinding"
              }
            ]
          }
        ],
        "allOf": [
          {
            "$ref": "#/definitions/bindingBase"
          }
        ]
      }
    }
  },
  "title": "JSON schema for Azure Functions function.json files",
  "type": "object"
}
