Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Provider Deprecations in Microsoft-AZURE #44763

Merged
merged 6 commits into from
Dec 7, 2024
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

This file was deleted.

1 change: 0 additions & 1 deletion generated/provider_dependencies.json
Original file line number Diff line number Diff line change
Expand Up @@ -847,7 +847,6 @@
"cross-providers-deps": [
"amazon",
"common.compat",
"google",
"oracle",
"sftp"
],
Expand Down
27 changes: 27 additions & 0 deletions providers/src/airflow/providers/microsoft/azure/CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,33 @@
Changelog
---------

main
....

.. warning::
All deprecated classes, parameters and features have been removed from the microsoft azure provider package.
The following breaking changes were introduced:

* Removed deprecated ``extra__azure_data_explorer__foo`` in azure connection extra.
* Removed deprecated ``extra__azure__tenantId`` in azure connection extra. Use ``tenantId`` instead.
* Removed deprecated ``get_state_exitcode_details`` method. Use ``get_state`` instead.
* Removed deprecated ``get_messages`` method. Use ``get_state`` instead.
* Removed deprecated ``extra__azure_data_factory__foo`` in azure connection extra.
* Usage of `default_conn_name=azure_synapse_connection` is deprecated in ``AzureSynapsePipelineHook``. Use ``default_conn_name=azure_synapse_default`` instead.
* Removed deprecated method ``get_hook`` to get instance of ``AzureDataExplorerHook``. Use ``hook`` property instead.
* Removed deprecated method ``get_hook`` to get instance of ``AzureBatchHook``. Use ``hook`` property instead.
* Removed deprecated method ``AzureKeyVaultBackend.get_conn_uri``. Use ``get_conn_value`` instead.
* Removed deprecated class ``WasbBlobAsyncSensor``. Use ``WasbBlobSensor`` with ``deferrable=True`` instead.
* Removed deprecated operator `AzureBlobStorageToGCSOperator`. Use ``airflow.providers.google.cloud.transfers.azure_blob_to_gcs.AzureBlobStorageToGCSOperator`` instead.









11.1.0
......

Expand Down
10 changes: 1 addition & 9 deletions providers/src/airflow/providers/microsoft/azure/hooks/adx.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
from azure.kusto.data import ClientRequestProperties, KustoClient, KustoConnectionStringBuilder
from azure.kusto.data.exceptions import KustoServiceError

from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
from airflow.exceptions import AirflowException
from airflow.hooks.base import BaseHook
from airflow.providers.microsoft.azure.utils import (
add_managed_identity_connection_widgets,
Expand Down Expand Up @@ -161,14 +161,6 @@ def get_required_param(name: str) -> str:
value = extras.get(name)
if value:
warn_if_collison(name, backcompat_key)
if not value and extras.get(backcompat_key):
warnings.warn(
f"`{backcompat_key}` is deprecated in azure connection extra,"
f" please use `{name}` instead",
AirflowProviderDeprecationWarning,
stacklevel=2,
)
value = extras.get(backcompat_key)
if not value:
raise AirflowException(f"Required connection parameter is missing: `{name}`")
return value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,12 @@
# under the License.
from __future__ import annotations

import warnings
from typing import Any

from azure.common.client_factory import get_client_from_auth_file, get_client_from_json_dict
from azure.common.credentials import ServicePrincipalCredentials

from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
from airflow.exceptions import AirflowException
from airflow.hooks.base import BaseHook
from airflow.providers.microsoft.azure.utils import (
AzureIdentityCredentialAdapter,
Expand Down Expand Up @@ -99,24 +98,7 @@ def get_conn(self) -> Any:
"""
conn = self.get_connection(self.conn_id)
tenant = conn.extra_dejson.get("tenantId")
if not tenant and conn.extra_dejson.get("extra__azure__tenantId"):
warnings.warn(
"`extra__azure__tenantId` is deprecated in azure connection extra, "
"please use `tenantId` instead",
AirflowProviderDeprecationWarning,
stacklevel=2,
)
tenant = conn.extra_dejson.get("extra__azure__tenantId")
subscription_id = conn.extra_dejson.get("subscriptionId")
if not subscription_id and conn.extra_dejson.get("extra__azure__subscriptionId"):
warnings.warn(
"`extra__azure__subscriptionId` is deprecated in azure connection extra, "
"please use `subscriptionId` instead",
AirflowProviderDeprecationWarning,
stacklevel=2,
)
subscription_id = conn.extra_dejson.get("extra__azure__subscriptionId")

key_path = conn.extra_dejson.get("key_path")
if key_path:
if not key_path.endswith(".json"):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,14 @@
from azure.common.client_factory import get_client_from_auth_file, get_client_from_json_dict
from azure.identity import ClientSecretCredential, DefaultAzureCredential
from azure.mgmt.containerinstance import ContainerInstanceManagementClient
from deprecated import deprecated

from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
from airflow.exceptions import AirflowException
from airflow.providers.microsoft.azure.hooks.base_azure import AzureBaseHook
from airflow.providers.microsoft.azure.utils import get_sync_default_azure_credential

if TYPE_CHECKING:
from azure.mgmt.containerinstance.models import (
ContainerGroup,
ContainerPropertiesInstanceView,
ContainerState,
Event,
)


Expand Down Expand Up @@ -116,43 +112,6 @@ def create_or_update(self, resource_group: str, name: str, container_group: Cont
"""
self.connection.container_groups.begin_create_or_update(resource_group, name, container_group)

@deprecated(
reason="get_state_exitcode_details() is deprecated. Related method is get_state()",
category=AirflowProviderDeprecationWarning,
)
def get_state_exitcode_details(self, resource_group: str, name: str) -> tuple:
"""
Get the state and exitcode of a container group.

:param resource_group: the name of the resource group
:param name: the name of the container group
:return: A tuple with the state, exitcode, and details.
If the exitcode is unknown 0 is returned.
"""
cg_state = self.get_state(resource_group, name)
container = cg_state.containers[0]
instance_view: ContainerPropertiesInstanceView = container.instance_view # type: ignore[assignment]
c_state: ContainerState = instance_view.current_state # type: ignore[assignment]
return c_state.state, c_state.exit_code, c_state.detail_status

@deprecated(
reason="get_messages() is deprecated. Related method is get_state()",
category=AirflowProviderDeprecationWarning,
)
def get_messages(self, resource_group: str, name: str) -> list:
"""
Get the messages of a container group.

:param resource_group: the name of the resource group
:param name: the name of the container group
:return: A list of the event messages
"""
cg_state = self.get_state(resource_group, name)
container = cg_state.containers[0]
instance_view: ContainerPropertiesInstanceView = container.instance_view # type: ignore[assignment]
events: list[Event] = instance_view.events # type: ignore[assignment]
return [event.message for event in events]

def get_state(self, resource_group: str, name: str) -> ContainerGroup:
"""
Get the state of a container group.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@

import inspect
import time
import warnings
from functools import wraps
from typing import IO, TYPE_CHECKING, Any, Callable, TypeVar, Union, cast

Expand All @@ -48,7 +47,7 @@
from azure.mgmt.datafactory import DataFactoryManagementClient
from azure.mgmt.datafactory.aio import DataFactoryManagementClient as AsyncDataFactoryManagementClient

from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
from airflow.exceptions import AirflowException
from airflow.hooks.base import BaseHook
from airflow.providers.microsoft.azure.utils import (
add_managed_identity_connection_widgets,
Expand Down Expand Up @@ -1095,14 +1094,6 @@ async def bind_argument(arg: Any, default_key: str) -> None:
default_value = extras.get(default_key) or extras.get(
f"extra__azure_data_factory__{default_key}"
)
if not default_value and extras.get(f"extra__azure_data_factory__{default_key}"):
warnings.warn(
f"`extra__azure_data_factory__{default_key}` is deprecated in azure connection extra,"
f" please use `{default_key}` instead",
AirflowProviderDeprecationWarning,
stacklevel=2,
)
default_value = extras.get(f"extra__azure_data_factory__{default_key}")
if not default_value:
raise AirflowException("Could not determine the targeted data factory.")

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,14 @@
from __future__ import annotations

import time
import warnings
from typing import TYPE_CHECKING, Any, Union

from azure.core.exceptions import ServiceRequestError
from azure.identity import ClientSecretCredential, DefaultAzureCredential
from azure.synapse.artifacts import ArtifactsClient
from azure.synapse.spark import SparkClient

from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning, AirflowTaskTimeout
from airflow.exceptions import AirflowException, AirflowTaskTimeout
from airflow.hooks.base import BaseHook
from airflow.providers.microsoft.azure.utils import (
add_managed_identity_connection_widgets,
Expand Down Expand Up @@ -307,13 +306,6 @@ def __init__(
azure_synapse_conn_id: str = default_conn_name,
**kwargs,
):
# Handling deprecation of "default_conn_name"
if azure_synapse_conn_id == self.default_conn_name:
warnings.warn(
"The usage of `default_conn_name=azure_synapse_connection` is deprecated and will be removed in future. Please update your code to use the new default connection name: `default_conn_name=azure_synapse_default`. ",
AirflowProviderDeprecationWarning,
stacklevel=2,
)
self._conn: ArtifactsClient | None = None
self.azure_synapse_workspace_dev_endpoint = azure_synapse_workspace_dev_endpoint
super().__init__(azure_synapse_conn_id=azure_synapse_conn_id, **kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,7 @@
from functools import cached_property
from typing import TYPE_CHECKING

from deprecated.classic import deprecated

from airflow.configuration import conf
from airflow.exceptions import AirflowProviderDeprecationWarning
from airflow.models import BaseOperator
from airflow.providers.microsoft.azure.hooks.adx import AzureDataExplorerHook

Expand Down Expand Up @@ -72,11 +69,6 @@ def hook(self) -> AzureDataExplorerHook:
"""Return new instance of AzureDataExplorerHook."""
return AzureDataExplorerHook(self.azure_data_explorer_conn_id)

@deprecated(reason="use `hook` property instead.", category=AirflowProviderDeprecationWarning)
def get_hook(self) -> AzureDataExplorerHook:
"""Return new instance of AzureDataExplorerHook."""
return self.hook

def execute(self, context: Context) -> KustoResultTable | str:
"""
Run KQL Query on Azure Data Explorer (Kusto).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,8 @@
from typing import TYPE_CHECKING, Any

from azure.batch import models as batch_models
from deprecated.classic import deprecated

from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
from airflow.exceptions import AirflowException
from airflow.models import BaseOperator
from airflow.providers.microsoft.azure.hooks.batch import AzureBatchHook

Expand Down Expand Up @@ -184,11 +183,6 @@ def hook(self) -> AzureBatchHook:
"""Create and return an AzureBatchHook (cached)."""
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:
raise AirflowException("You must specify either vm_publisher or os_family")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -328,10 +328,7 @@ transfers:
target-integration-name: Microsoft Azure Blob Storage
how-to-guide: /docs/apache-airflow-providers-microsoft-azure/transfer/s3_to_wasb.rst
python-module: airflow.providers.microsoft.azure.transfers.s3_to_wasb
- source-integration-name: Microsoft Azure Blob Storage
target-integration-name: Google Cloud Storage (GCS)
how-to-guide: /docs/apache-airflow-providers-microsoft-azure/transfer/azure_blob_to_gcs.rst
python-module: airflow.providers.microsoft.azure.transfers.azure_blob_to_gcs


connection-types:
- hook-class-name: airflow.providers.microsoft.azure.hooks.base_azure.AzureBaseHook
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@
from azure.core.exceptions import ResourceNotFoundError
from azure.identity import ClientSecretCredential, DefaultAzureCredential
from azure.keyvault.secrets import SecretClient
from deprecated import deprecated

from airflow.exceptions import AirflowProviderDeprecationWarning
from airflow.providers.microsoft.azure.utils import get_sync_default_azure_credential
from airflow.secrets import BaseSecretsBackend
from airflow.utils.log.logging_mixin import LoggingMixin
Expand Down Expand Up @@ -154,24 +152,6 @@ def get_conn_value(self, conn_id: str) -> str | None:

return self._get_secret(self.connections_prefix, conn_id)

@deprecated(
reason=(
"Method `AzureKeyVaultBackend.get_conn_uri` is deprecated and will be removed "
"in a future release. Please use method `get_conn_value` instead."
),
category=AirflowProviderDeprecationWarning,
)
def get_conn_uri(self, conn_id: str) -> str | None:
"""
Return URI representation of Connection conn_id.

As of Airflow version 2.3.0 this method is deprecated.

:param conn_id: the connection id
:return: deserialized Connection
"""
return self.get_conn_value(conn_id)

def get_variable(self, key: str) -> str | None:
"""
Get an Airflow Variable from an Azure Key Vault secret.
Expand Down
36 changes: 2 additions & 34 deletions providers/src/airflow/providers/microsoft/azure/sensors/wasb.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,10 @@

from collections.abc import Sequence
from datetime import timedelta
from typing import TYPE_CHECKING, Any

from deprecated import deprecated
from typing import TYPE_CHECKING

from airflow.configuration import conf
from airflow.exceptions import AirflowException, AirflowProviderDeprecationWarning
from airflow.exceptions import AirflowException
from airflow.providers.microsoft.azure.hooks.wasb import WasbHook
from airflow.providers.microsoft.azure.triggers.wasb import WasbBlobSensorTrigger, WasbPrefixSensorTrigger
from airflow.sensors.base import BaseSensorOperator
Expand Down Expand Up @@ -111,36 +109,6 @@ def execute_complete(self, context: Context, event: dict[str, str]) -> None:
raise AirflowException("Did not receive valid event from the triggerer")


@deprecated(
reason=(
"Class `WasbBlobAsyncSensor` is deprecated and "
"will be removed in a future release. "
"Please use `WasbBlobSensor` and "
"set `deferrable` attribute to `True` instead"
),
category=AirflowProviderDeprecationWarning,
)
class WasbBlobAsyncSensor(WasbBlobSensor):
"""
Poll asynchronously for the existence of a blob in a WASB container.

This class is deprecated and will be removed in a future release.

Please use :class:`airflow.providers.microsoft.azure.sensors.wasb.WasbBlobSensor`
and set *deferrable* attribute to *True* instead.

:param container_name: name of the container in which the blob should be searched for
:param blob_name: name of the blob to check existence for
:param wasb_conn_id: the connection identifier for connecting to Azure WASB
:param poke_interval: polling period in seconds to check for the status
:param public_read: whether an anonymous public read access should be used. Default is False
:param timeout: Time, in seconds before the task times out and fails.
"""

def __init__(self, **kwargs: Any) -> None:
super().__init__(**kwargs, deferrable=True)


class WasbPrefixSensor(BaseSensorOperator):
"""
Wait for blobs matching a prefix to arrive on Azure Blob Storage.
Expand Down
Loading