Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
"""
Example Airflow DAG that trigger a task in Azure Batch.

This DAG relies on the following OS environment variables

* POOL_ID - The Pool ID in Batch accounts.
"""


from __future__ import annotations

import os
from datetime import datetime

from airflow import DAG
from airflow.providers.microsoft.azure.operators.batch import AzureBatchOperator

POOL_ID = os.environ.get("POOL_ID", "example-pool")

with DAG(
dag_id="example_azure_batch",
start_date=datetime(2021, 1, 1),
catchup=False,
doc_md=__doc__,
tags=["example"],
) as dag:
# [START howto_azure_batch_operator]
azure_batch_operator = AzureBatchOperator(
task_id="azure_batch",
batch_pool_id=POOL_ID,
batch_pool_vm_size="standard_d2s_v3",
batch_job_id="example-job",
batch_task_command_line="/bin/bash -c 'set -e; set -o pipefail; echo hello world!; wait'",
batch_task_id="example-task",
vm_node_agent_sku_id="batch.node.ubuntu 22.04",
vm_publisher="Canonical",
vm_offer="0001-com-ubuntu-server-jammy",
vm_sku="22_04-lts-gen2",
target_dedicated_nodes=1,
)
# [END howto_azure_batch_operator]
2 changes: 2 additions & 0 deletions airflow/providers/microsoft/azure/provider.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ dependencies:
integrations:
- integration-name: Microsoft Azure Batch
external-doc-url: https://azure.microsoft.com/en-us/services/batch/
how-to-guide:
- /docs/apache-airflow-providers-microsoft-azure/operators/batch.rst
logo: /integration-logos/azure/Microsoft-Azure-Batch.png
tags: [azure]
- integration-name: Microsoft Azure Blob Storage
Expand Down
41 changes: 41 additions & 0 deletions docs/apache-airflow-providers-microsoft-azure/operators/batch.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
.. Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

.. http://www.apache.org/licenses/LICENSE-2.0

.. Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.


Azure Batch Operator
=================================

AzureBatchOperator
----------------------------------
Use the
:class:`~airflow.providers.microsoft.azure.operators.batch.AzureBatchOperator` to trigger a task on Azure Batch

Below is an example of using this operator to trigger a task on Azure Batch

.. exampleinclude:: /../../airflow/providers/microsoft/azure/example_dag/example_azure_batch_operator.py
:language: python
:dedent: 0
:start-after: [START howto_azure_batch_operator]
:end-before: [END howto_azure_batch_operator]


Reference
---------

For further information, look at:

* `Azure Batch Documentation <https://azure.microsoft.com/en-us/products/batch/>`__