{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/microsoft-azure-sql-database/json-schema/microsoft-azure-sql-database-failover-group-schema.json",
  "title": "FailoverGroup",
  "description": "A failover group.",
  "x-generated": "2026-11-05",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/microsoft-azure-sql-database-failovergroups-api-openapi.yml#/components/schemas/FailoverGroup",
  "type": "object",
  "properties": {
    "properties": {
      "$ref": "#/$defs/FailoverGroupProperties"
    },
    "tags": {
      "type": "object",
      "description": "Resource tags.",
      "additionalProperties": {
        "type": "string"
      }
    },
    "location": {
      "type": "string",
      "description": "Resource location.",
      "readOnly": true
    }
  },
  "allOf": [
    {
      "type": "object",
      "title": "Proxy Resource",
      "description": "The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location",
      "allOf": [
        {
          "type": "object",
          "title": "Resource",
          "description": "Common fields that are returned in the response for all Azure Resource Manager resources",
          "properties": {
            "id": {
              "type": "string",
              "format": "arm-id",
              "description": "Fully qualified resource ID for the resource. E.g. \"/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}\"",
              "readOnly": true
            },
            "name": {
              "type": "string",
              "description": "The name of the resource",
              "readOnly": true
            },
            "type": {
              "type": "string",
              "description": "The type of the resource. E.g. \"Microsoft.Compute/virtualMachines\" or \"Microsoft.Storage/storageAccounts\"",
              "readOnly": true
            },
            "systemData": {
              "type": "object",
              "description": "Metadata pertaining to creation and last modification of the resource.",
              "properties": {
                "createdBy": {
                  "type": "string",
                  "description": "The identity that created the resource."
                },
                "createdByType": {
                  "type": "string",
                  "description": "The type of identity that created the resource.",
                  "enum": [
                    "User",
                    "Application",
                    "ManagedIdentity",
                    "Key"
                  ],
                  "x-ms-enum": {
                    "name": "createdByType",
                    "modelAsString": true
                  }
                },
                "createdAt": {
                  "type": "string",
                  "format": "date-time",
                  "description": "The timestamp of resource creation (UTC)."
                },
                "lastModifiedBy": {
                  "type": "string",
                  "description": "The identity that last modified the resource."
                },
                "lastModifiedByType": {
                  "type": "string",
                  "description": "The type of identity that last modified the resource.",
                  "enum": [
                    "User",
                    "Application",
                    "ManagedIdentity",
                    "Key"
                  ],
                  "x-ms-enum": {
                    "name": "createdByType",
                    "modelAsString": true
                  }
                },
                "lastModifiedAt": {
                  "type": "string",
                  "format": "date-time",
                  "description": "The timestamp of resource last modification (UTC)"
                }
              },
              "readOnly": true
            }
          },
          "x-ms-azure-resource": true
        }
      ]
    }
  ],
  "$defs": {
    "FailoverGroupProperties": {
      "type": "object",
      "description": "Properties of a failover group.",
      "properties": {
        "readWriteEndpoint": {
          "$ref": "#/$defs/FailoverGroupReadWriteEndpoint"
        },
        "readOnlyEndpoint": {
          "$ref": "#/$defs/FailoverGroupReadOnlyEndpoint"
        },
        "replicationRole": {
          "type": "string",
          "description": "Local replication role of the failover group instance.",
          "enum": [
            "Primary",
            "Secondary"
          ],
          "x-ms-enum": {
            "name": "FailoverGroupReplicationRole",
            "modelAsString": true,
            "values": [
              {
                "name": "Primary",
                "value": "Primary",
                "description": "Primary"
              },
              {
                "name": "Secondary",
                "value": "Secondary",
                "description": "Secondary"
              }
            ]
          }
        },
        "replicationState": {
          "type": "string",
          "description": "Replication state of the failover group instance.",
          "readOnly": true
        },
        "partnerServers": {
          "type": "array",
          "description": "List of partner server information for the failover group.",
          "items": {
            "$ref": "#/$defs/PartnerInfo"
          }
        },
        "databases": {
          "type": "array",
          "description": "List of databases in the failover group.",
          "items": {
            "type": "string",
            "format": "arm-id",
            "description": "A type definition that refers the id to an Azure Resource Manager resource.",
            "x-ms-arm-id-details": {
              "allowedResources": [
                {
                  "type": "Microsoft.Sql/servers/databases"
                }
              ]
            }
          }
        },
        "secondaryType": {
          "type": "string",
          "description": "Databases secondary type on partner server.",
          "enum": [
            "Geo",
            "Standby"
          ],
          "x-ms-enum": {
            "name": "FailoverGroupDatabasesSecondaryType",
            "modelAsString": true,
            "values": [
              {
                "name": "Geo",
                "value": "Geo",
                "description": "Geo"
              },
              {
                "name": "Standby",
                "value": "Standby",
                "description": "Standby"
              }
            ]
          }
        }
      },
      "required": [
        "readWriteEndpoint",
        "partnerServers"
      ]
    },
    "FailoverGroupReadOnlyEndpoint": {
      "type": "object",
      "description": "Read-only endpoint of the failover group instance.",
      "properties": {
        "failoverPolicy": {
          "type": "string",
          "description": "Failover policy of the read-only endpoint for the failover group.",
          "enum": [
            "Disabled",
            "Enabled"
          ],
          "x-ms-enum": {
            "name": "ReadOnlyEndpointFailoverPolicy",
            "modelAsString": true,
            "values": [
              {
                "name": "Disabled",
                "value": "Disabled",
                "description": "Disabled"
              },
              {
                "name": "Enabled",
                "value": "Enabled",
                "description": "Enabled"
              }
            ]
          }
        },
        "targetServer": {
          "type": "string",
          "format": "arm-id",
          "description": "The target partner server where the read-only endpoint points to.",
          "x-ms-arm-id-details": {
            "allowedResources": [
              {
                "type": "Microsoft.Sql/servers"
              }
            ]
          }
        }
      }
    },
    "FailoverGroupReadWriteEndpoint": {
      "type": "object",
      "description": "Read-write endpoint of the failover group instance.",
      "properties": {
        "failoverPolicy": {
          "type": "string",
          "description": "Failover policy of the read-write endpoint for the failover group. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required.",
          "enum": [
            "Manual",
            "Automatic"
          ],
          "x-ms-enum": {
            "name": "ReadWriteEndpointFailoverPolicy",
            "modelAsString": true,
            "values": [
              {
                "name": "Manual",
                "value": "Manual",
                "description": "Manual"
              },
              {
                "name": "Automatic",
                "value": "Automatic",
                "description": "Automatic"
              }
            ]
          }
        },
        "failoverWithDataLossGracePeriodMinutes": {
          "type": "integer",
          "format": "int32",
          "description": "Grace period before failover with data loss is attempted for the read-write endpoint. If failoverPolicy is Automatic then failoverWithDataLossGracePeriodMinutes is required."
        }
      },
      "required": [
        "failoverPolicy"
      ]
    },
    "PartnerInfo": {
      "type": "object",
      "description": "Partner server information for the failover group.",
      "properties": {
        "id": {
          "type": "string",
          "format": "arm-id",
          "description": "Resource identifier of the partner server.",
          "x-ms-arm-id-details": {
            "allowedResources": [
              {
                "type": "Microsoft.Sql/servers"
              }
            ]
          }
        },
        "location": {
          "type": "string",
          "description": "Geo location of the partner server.",
          "readOnly": true
        },
        "replicationRole": {
          "$ref": "#/$defs/replicationRole"
        }
      },
      "required": [
        "id"
      ]
    }
  }
}