{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/microsoft-azure-batch/json-schema/microsoft-azure-batch-batch-pool-replace-options-schema.json",
  "title": "BatchPoolReplaceOptions",
  "description": "Parameters for replacing properties on an Azure Batch Pool.",
  "x-generated": "2026-11-05",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_superseded/microsoft-azure-batch-pools-api-openapi.yml#/components/schemas/BatchPoolReplaceOptions",
  "type": "object",
  "properties": {
    "startTask": {
      "$ref": "#/$defs/BatchStartTask",
      "description": "A Task to run on each Compute Node as it joins the Pool. The Task runs when the Compute Node is added to the Pool or when the Compute Node is restarted. If this element is present, it overwrites any existing StartTask. If omitted, any existing StartTask is removed from the Pool."
    },
    "applicationPackageReferences": {
      "type": "array",
      "description": "The list of Application Packages to be installed on each Compute Node in the Pool. The list replaces any existing Application Package references on the Pool. Changes to Application Package references affect all new Compute Nodes joining the Pool, but do not affect Compute Nodes that are already in the Pool until they are rebooted or reimaged. There is a maximum of 10 Application Package references on any given Pool. If omitted, or if you specify an empty collection, any existing Application Packages references are removed from the Pool. A maximum of 10 references may be specified on a given Pool.",
      "items": {
        "$ref": "#/$defs/BatchApplicationPackageReference"
      }
    },
    "metadata": {
      "type": "array",
      "description": "A list of name-value pairs associated with the Pool as metadata. This list replaces any existing metadata configured on the Pool. If omitted, or if you specify an empty collection, any existing metadata is removed from the Pool.",
      "items": {
        "$ref": "#/$defs/BatchMetadataItem"
      }
    }
  },
  "required": [
    "applicationPackageReferences",
    "metadata"
  ],
  "$defs": {
    "AutoUserScope": {
      "type": "string",
      "description": "AutoUserScope enums",
      "enum": [
        "task",
        "pool"
      ],
      "x-ms-enum": {
        "name": "AutoUserScope",
        "modelAsString": true,
        "values": [
          {
            "name": "Task",
            "value": "task",
            "description": "Specifies that the service should create a new user for the Task."
          },
          {
            "name": "Pool",
            "value": "pool",
            "description": "Specifies that the Task runs as the common auto user Account which is created on every Compute Node in a Pool."
          }
        ]
      }
    },
    "AutoUserSpecification": {
      "type": "object",
      "description": "Specifies the options for the auto user that runs an Azure Batch Task.",
      "properties": {
        "scope": {
          "$ref": "#/$defs/AutoUserScope",
          "description": "The scope for the auto user. The default value is pool. If the pool is running Windows a value of Task should be specified if stricter isolation between tasks is required. For example, if the task mutates the registry in a way which could impact other tasks."
        },
        "elevationLevel": {
          "$ref": "#/$defs/ElevationLevel",
          "description": "The elevation level of the auto user. The default value is nonAdmin."
        }
      }
    },
    "BatchApplicationPackageReference": {
      "type": "object",
      "description": "A reference to an Package to be deployed to Compute Nodes.",
      "properties": {
        "applicationId": {
          "type": "string",
          "description": "The ID of the application to deploy. When creating a pool, the package's application ID must be fully qualified (/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Batch/batchAccounts/{accountName}/applications/{applicationName})."
        },
        "version": {
          "type": "string",
          "description": "The version of the application to deploy. If omitted, the default version is deployed. If this is omitted on a Pool, and no default version is specified for this application, the request fails with the error code InvalidApplicationPackageReferences and HTTP status code 409. If this is omitted on a Task, and no default version is specified for this application, the Task fails with a pre-processing error."
        }
      },
      "required": [
        "applicationId"
      ]
    },
    "BatchMetadataItem": {
      "type": "object",
      "description": "The Batch service does not assign any meaning to this metadata; it is solely\nfor the use of user code.",
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the metadata item."
        },
        "value": {
          "type": "string",
          "description": "The value of the metadata item."
        }
      },
      "required": [
        "name",
        "value"
      ]
    },
    "BatchNodeIdentityReference": {
      "type": "object",
      "description": "The reference to a user assigned identity associated with the Batch pool which\na compute node will use.",
      "properties": {
        "resourceId": {
          "type": "string",
          "format": "arm-id",
          "description": "The ARM resource id of the user assigned identity."
        }
      }
    },
    "BatchStartTask": {
      "type": "object",
      "description": "Batch will retry Tasks when a recovery operation is triggered on a Node.\nExamples of recovery operations include (but are not limited to) when an\nunhealthy Node is rebooted or a Compute Node disappeared due to host failure.\nRetries due to recovery operations are independent of and are not counted\nagainst the maxTaskRetryCount. Even if the maxTaskRetryCount is 0, an internal\nretry due to a recovery operation may occur. Because of this, all Tasks should\nbe idempotent. This means Tasks need to tolerate being interrupted and\nrestarted without causing any corruption or duplicate data. The best practice\nfor long running Tasks is to use some form of checkpointing. In some cases the\nStartTask may be re-run even though the Compute Node was not rebooted. Special\ncare should be taken to avoid StartTasks which create breakaway process or\ninstall/launch services from the StartTask working directory, as this will\nblock Batch from being able to re-run the StartTask.",
      "properties": {
        "commandLine": {
          "type": "string",
          "description": "The command line of the StartTask. The command line does not run under a shell, and therefore cannot take advantage of shell features such as environment variable expansion. If you want to take advantage of such features, you should invoke the shell in the command line, for example using \"cmd /c MyCommand\" in Windows or \"/bin/sh -c MyCommand\" in Linux. If the command line refers to file paths, it should use a relative path (relative to the Task working directory), or use the Batch provided environment variable (https://learn.microsoft.com/azure/batch/batch-compute-node-environment-variables)."
        },
        "containerSettings": {
          "$ref": "#/$defs/BatchTaskContainerSettings",
          "description": "The settings for the container under which the StartTask runs. When this is specified, all directories recursively below the AZ_BATCH_NODE_ROOT_DIR (the root of Azure Batch directories on the node) are mapped into the container, all Task environment variables are mapped into the container, and the Task command line is executed in the container. Files produced in the container outside of AZ_BATCH_NODE_ROOT_DIR might not be reflected to the host disk, meaning that Batch file APIs will not be able to access those files."
        },
        "resourceFiles": {
          "type": "array",
          "description": "A list of files that the Batch service will download to the Compute Node before running the command line.  There is a maximum size for the list of resource files. When the max size is exceeded, the request will fail and the response error code will be RequestEntityTooLarge. If this occurs, the collection of ResourceFiles must be reduced in size. This can be achieved using .zip files, Application Packages, or Docker Containers. Files listed under this element are located in the Task's working directory.",
          "items": {
            "$ref": "#/$defs/ResourceFile"
          }
        },
        "environmentSettings": {
          "type": "array",
          "description": "A list of environment variable settings for the StartTask.",
          "items": {
            "$ref": "#/$defs/EnvironmentSetting"
          }
        },
        "userIdentity": {
          "$ref": "#/$defs/UserIdentity",
          "description": "The user identity under which the StartTask runs. If omitted, the Task runs as a non-administrative user unique to the Task."
        },
        "maxTaskRetryCount": {
          "type": "integer",
          "format": "int32",
          "description": "The maximum number of times the Task may be retried. The Batch service retries a Task if its exit code is nonzero. Note that this value specifically controls the number of retries. The Batch service will try the Task once, and may then retry up to this limit. For example, if the maximum retry count is 3, Batch tries the Task up to 4 times (one initial try and 3 retries). If the maximum retry count is 0, the Batch service does not retry the Task. If the maximum retry count is -1, the Batch service retries the Task without limit, however this is not recommended for a start task or any task. The default value is 0 (no retries)."
        },
        "waitForSuccess": {
          "type": "boolean",
          "description": "Whether the Batch service should wait for the StartTask to complete successfully (that is, to exit with exit code 0) before scheduling any Tasks on the Compute Node. If true and the StartTask fails on a Node, the Batch service retries the StartTask up to its maximum retry count (maxTaskRetryCount). If the Task has still not completed successfully after all retries, then the Batch service marks the Node unusable, and will not schedule Tasks to it. This condition can be detected via the Compute Node state and failure info details. If false, the Batch service will not wait for the StartTask to complete. In this case, other Tasks can start executing on the Compute Node while the StartTask is still running; and even if the StartTask fails, new Tasks will continue to be scheduled on the Compute Node. The default is true."
        }
      },
      "required": [
        "commandLine"
      ]
    },
    "BatchTaskContainerSettings": {
      "type": "object",
      "description": "The container settings for a Task.",
      "properties": {
        "containerRunOptions": {
          "type": "string",
          "description": "Additional options to the container create command. These additional options are supplied as arguments to the \"docker create\" command, in addition to those controlled by the Batch Service."
        },
        "imageName": {
          "type": "string",
          "description": "The Image to use to create the container in which the Task will run. This is the full Image reference, as would be specified to \"docker pull\". If no tag is provided as part of the Image name, the tag \":latest\" is used as a default."
        },
        "registry": {
          "$ref": "#/$defs/ContainerRegistryReference",
          "description": "The private registry which contains the container Image. This setting can be omitted if was already provided at Pool creation."
        },
        "workingDirectory": {
          "$ref": "#/$defs/ContainerWorkingDirectory",
          "description": "The location of the container Task working directory. The default is 'taskWorkingDirectory'."
        },
        "containerHostBatchBindMounts": {
          "type": "array",
          "description": "The paths you want to mounted to container task. If this array is null or be not present, container task will mount entire temporary disk drive in windows (or AZ_BATCH_NODE_ROOT_DIR in Linux). It won't' mount any data paths into container if this array is set as empty.",
          "items": {
            "$ref": "#/$defs/ContainerHostBatchBindMountEntry"
          }
        }
      },
      "required": [
        "imageName"
      ]
    },
    "ContainerHostBatchBindMountEntry": {
      "type": "object",
      "description": "The entry of path and mount mode you want to mount into task container.",
      "properties": {
        "source": {
          "$ref": "#/$defs/ContainerHostDataPath",
          "description": "The path which be mounted to container customer can select."
        },
        "isReadOnly": {
          "type": "boolean",
          "description": "Mount this source path as read-only mode or not. Default value is false (read/write mode). For Linux, if you mount this path as a read/write mode, this does not mean that all users in container have the read/write access for the path, it depends on the access in host VM. If this path is mounted read-only, all users within the container will not be able to modify the path."
        }
      }
    },
    "ContainerHostDataPath": {
      "type": "string",
      "description": "The paths which will be mounted to container task's container.",
      "enum": [
        "Shared",
        "Startup",
        "VfsMounts",
        "Task",
        "JobPrep",
        "Applications"
      ],
      "x-ms-enum": {
        "name": "ContainerHostDataPath",
        "modelAsString": true,
        "values": [
          {
            "name": "Shared",
            "value": "Shared",
            "description": "The path for multi-instances task to shared their files."
          },
          {
            "name": "Startup",
            "value": "Startup",
            "description": "The path for start task."
          },
          {
            "name": "VfsMounts",
            "value": "VfsMounts",
            "description": "The path contains all virtual file systems are mounted on this node."
          },
          {
            "name": "Task",
            "value": "Task",
            "description": "The task path."
          },
          {
            "name": "JobPrep",
            "value": "JobPrep",
            "description": "The job-prep task path."
          },
          {
            "name": "Applications",
            "value": "Applications",
            "description": "The applications path."
          }
        ]
      }
    },
    "ContainerRegistryReference": {
      "type": "object",
      "description": "A private container registry.",
      "properties": {
        "username": {
          "type": "string",
          "description": "The user name to log into the registry server."
        },
        "password": {
          "type": "string",
          "format": "password",
          "description": "The password to log into the registry server.",
          "x-ms-secret": true
        },
        "registryServer": {
          "type": "string",
          "format": "uri",
          "description": "The registry URL. If omitted, the default is \"docker.io\"."
        },
        "identityReference": {
          "$ref": "#/$defs/BatchNodeIdentityReference",
          "description": "The reference to the user assigned identity to use to access an Azure Container Registry instead of username and password."
        }
      }
    },
    "ContainerWorkingDirectory": {
      "type": "string",
      "description": "ContainerWorkingDirectory enums",
      "enum": [
        "taskWorkingDirectory",
        "containerImageDefault"
      ],
      "x-ms-enum": {
        "name": "ContainerWorkingDirectory",
        "modelAsString": true,
        "values": [
          {
            "name": "TaskWorkingDirectory",
            "value": "taskWorkingDirectory",
            "description": "Use the standard Batch service Task working directory, which will contain the Task Resource Files populated by Batch."
          },
          {
            "name": "ContainerImageDefault",
            "value": "containerImageDefault",
            "description": "Use the working directory defined in the container Image. Beware that this directory will not contain the Resource Files downloaded by Batch."
          }
        ]
      }
    },
    "ElevationLevel": {
      "type": "string",
      "description": "ElevationLevel enums",
      "enum": [
        "nonadmin",
        "admin"
      ],
      "x-ms-enum": {
        "name": "ElevationLevel",
        "modelAsString": true,
        "values": [
          {
            "name": "NonAdmin",
            "value": "nonadmin",
            "description": "The user is a standard user without elevated access."
          },
          {
            "name": "Admin",
            "value": "admin",
            "description": "The user is a user with elevated access and operates with full Administrator permissions."
          }
        ]
      }
    },
    "EnvironmentSetting": {
      "type": "object",
      "description": "An environment variable to be set on a Task process.",
      "properties": {
        "name": {
          "type": "string",
          "description": "The name of the environment variable."
        },
        "value": {
          "type": "string",
          "description": "The value of the environment variable."
        }
      },
      "required": [
        "name"
      ]
    },
    "ResourceFile": {
      "type": "object",
      "description": "A single file or multiple files to be downloaded to a Compute Node.",
      "properties": {
        "autoStorageContainerName": {
          "type": "string",
          "description": "The storage container name in the auto storage Account. The autoStorageContainerName, storageContainerUrl and httpUrl properties are mutually exclusive and one of them must be specified."
        },
        "storageContainerUrl": {
          "type": "string",
          "format": "uri",
          "description": "The URL of the blob container within Azure Blob Storage. The autoStorageContainerName, storageContainerUrl and httpUrl properties are mutually exclusive and one of them must be specified. This URL must be readable and listable from compute nodes. There are three ways to get such a URL for a container in Azure storage: include a Shared Access Signature (SAS) granting read and list permissions on the container, use a managed identity with read and list permissions, or set the ACL for the container to allow public access."
        },
        "httpUrl": {
          "type": "string",
          "format": "uri",
          "description": "The URL of the file to download. The autoStorageContainerName, storageContainerUrl and httpUrl properties are mutually exclusive and one of them must be specified. If the URL points to Azure Blob Storage, it must be readable from compute nodes. There are three ways to get such a URL for a blob in Azure storage: include a Shared Access Signature (SAS) granting read permissions on the blob, use a managed identity with read permission, or set the ACL for the blob or its container to allow public access."
        },
        "blobPrefix": {
          "type": "string",
          "description": "The blob prefix to use when downloading blobs from an Azure Storage container. Only the blobs whose names begin with the specified prefix will be downloaded. The property is valid only when autoStorageContainerName or storageContainerUrl is used. This prefix can be a partial filename or a subdirectory. If a prefix is not specified, all the files in the container will be downloaded."
        },
        "filePath": {
          "type": "string",
          "description": "The location on the Compute Node to which to download the file(s), relative to the Task's working directory. If the httpUrl property is specified, the filePath is required and describes the path which the file will be downloaded to, including the filename. Otherwise, if the autoStorageContainerName or storageContainerUrl property is specified, filePath is optional and is the directory to download the files to. In the case where filePath is used as a directory, any directory structure already associated with the input data will be retained in full and appended to the specified filePath directory. The specified relative path cannot break out of the Task's working directory (for example by using '..')."
        },
        "fileMode": {
          "type": "string",
          "description": "The file permission mode attribute in octal format. This property applies only to files being downloaded to Linux Compute Nodes. It will be ignored if it is specified for a resourceFile which will be downloaded to a Windows Compute Node. If this property is not specified for a Linux Compute Node, then a default value of 0770 is applied to the file."
        },
        "identityReference": {
          "$ref": "#/$defs/BatchNodeIdentityReference",
          "description": "The reference to the user assigned identity to use to access Azure Blob Storage specified by storageContainerUrl or httpUrl."
        }
      }
    },
    "UserIdentity": {
      "type": "object",
      "description": "The definition of the user identity under which the Task is run. Specify either the userName or autoUser property, but not both.",
      "properties": {
        "username": {
          "type": "string",
          "description": "The name of the user identity under which the Task is run. The userName and autoUser properties are mutually exclusive; you must specify one but not both."
        },
        "autoUser": {
          "$ref": "#/$defs/AutoUserSpecification",
          "description": "The auto user under which the Task is run. The userName and autoUser properties are mutually exclusive; you must specify one but not both."
        }
      }
    }
  }
}