diff --git a/airflow/providers/microsoft/azure/operators/batch.py b/airflow/providers/microsoft/azure/operators/batch.py index 06122ed1f9f00..0c1a0849b5b05 100644 --- a/airflow/providers/microsoft/azure/operators/batch.py +++ b/airflow/providers/microsoft/azure/operators/batch.py @@ -21,8 +21,9 @@ from typing import TYPE_CHECKING, Any, Sequence from azure.batch import models as batch_models +from deprecated.classic import deprecated -from airflow.exceptions import AirflowException +from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning from airflow.models import BaseOperator from airflow.providers.microsoft.azure.hooks.batch import AzureBatchHook @@ -181,7 +182,12 @@ def __init__( @cached_property def hook(self) -> AzureBatchHook: """Create and return an AzureBatchHook (cached).""" - return self.get_hook() + return AzureBatchHook(self.azure_batch_conn_id) + + @deprecated(reason="use `hook` property instead.", category=AirflowProviderDeprecationWarning) + def get_hook(self) -> AzureBatchHook: + """Create and return an AzureBatchHook.""" + return self.hook def _check_inputs(self) -> Any: if not self.os_family and not self.vm_publisher: @@ -315,10 +321,6 @@ def on_kill(self) -> None: ) self.log.info("Azure Batch job (%s) terminated: %s", self.batch_job_id, response) - def get_hook(self) -> AzureBatchHook: - """Create and return an AzureBatchHook.""" - return AzureBatchHook(azure_batch_conn_id=self.azure_batch_conn_id) - def clean_up(self, pool_id: str | None = None, job_id: str | None = None) -> None: """ Delete the given pool and job in the batch account.