Batch

Batch

Certified
Enterprise Edition

Task runner that executes a task inside a job in Azure Batch.

yaml
type: io.kestra.plugin.ee.azure.runner.Batch
yaml
id: new_shell
namespace: company.team

tasks:
  - id: shell
    type: io.kestra.plugin.scripts.shell.Commands
    taskRunner:
      type: io.kestra.plugin.ee.azure.runner.Batch
      account: "{{secrets.account}}"
      accessKey: "{{secrets.accessKey}}"
      endpoint: "{{secrets.endpoint}}"
      poolId: "{{vars.poolId}}"
    commands:
      - echo "Hello World"

yaml
id: new_shell_with_file
namespace: company.team

inputs:
  - id: file
    type: FILE

tasks:
  - id: shell
    type: io.kestra.plugin.scripts.shell.Commands
    inputFiles:
      data.txt: "{{inputs.file}}"
    outputFiles:
      - out.txt
    containerImage: centos
    taskRunner:
      type: io.kestra.plugin.azure.ee.runner.Batch
      account: "{{secrets.account}}"
      accessKey: "{{secrets.accessKey}}"
      endpoint: "{{secrets.endpoint}}"
      poolId: "{{vars.poolId}}"
      blobStorage:
        connectionString: "{{secrets.connectionString}}"
        containerName: "{{vars.containerName}}"
    commands:
      - cp {{workingDir}}/data.txt {{workingDir}}/out.txt

yaml
                id: azure_batch_runner
                namespace: company.team

                variables:
                  pool_id: poolId
                  container_name: containerName

                tasks:
                  - id: scrape_environment_info
                    type: io.kestra.plugin.scripts.python.Commands
                    containerImage: ghcr.io/kestra-io/pydata:latest
                    taskRunner:
                      type: io.kestra.plugin.ee.azure.runner.Batch
                      account: "{{ secret('AZURE_ACCOUNT') }}"
                      accessKey: "{{ secret('AZURE_ACCESS_KEY') }}"
                      endpoint: "{{ secret('AZURE_ENDPOINT') }}"
                      poolId: "{{ vars.pool_id }}"
                      blobStorage:
                        containerName: "{{ vars.container_name }}"
                        connectionString: "{{ secret('AZURE_CONNECTION_STRING') }}"
                    commands:
                      - python {{ workingDir }}/main.py
                    namespaceFiles:
                      enabled: true
                    outputFiles:
                      - environment_info.json
                    inputFiles:
                      main.py: |
                        import platform
                        import socket
                        import sys
                        import json
import io.kestra.core.models.annotations.PluginProperty;

                        from kestra import Kestra

                        print("Hello from Azure Batch and kestra!")

                        def print_environment_info():
                            print(f"Host's network name: {platform.node()}")
                            print(f"Python version: {platform.python_version()}")
                            print(f"Platform information (instance type): {platform.platform()}")
                            print(f"OS/Arch: {sys.platform}/{platform.machine()}")

                            env_info = {
                                "host": platform.node(),
                                "platform": platform.platform(),
                                "OS": sys.platform,
                                "python_version": platform.python_version(),
                            }
                            Kestra.outputs(env_info)

                            filename = 'environment_info.json'
                            with open(filename, 'w') as json_file:
                                json.dump(env_info, json_file, indent=4)

                        if __name__ == '__main__':
                          print_environment_info()
Properties
Definitions
containerName*Requiredstring
connectionStringstring
endpointstring
sharedKeyAccountAccessKeystring
sharedKeyAccountNamestring
DefaultPT5S
Defaulttrue
Definitions
identityReference
resourceIdstring
passwordstring
registryServerstring
userNamestring
Defaulttrue
Defaultfalse
Defaultfalse
DefaultPT1H