You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by GitBox <gi...@apache.org> on 2020/01/20 13:17:47 UTC

[GitHub] [airflow] spektom commented on a change in pull request #5785: [AIRFLOW-5176] Add Azure Data Explorer (Kusto) operator

spektom commented on a change in pull request #5785: [AIRFLOW-5176] Add Azure Data Explorer (Kusto) operator
URL: https://github.com/apache/airflow/pull/5785#discussion_r368542098
 
 

 ##########
 File path: airflow/providers/microsoft/azure/hooks/adx.py
 ##########
 @@ -0,0 +1,146 @@
+# -*- coding: utf-8 -*-
+#
+# 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.
+#
+"""This module contains Azure Data Explorer hook"""
+
+from azure.kusto.data.exceptions import KustoServiceError
+from azure.kusto.data.request import ClientRequestProperties, KustoClient, KustoConnectionStringBuilder
+
+from airflow.exceptions import AirflowException
+from airflow.hooks.base_hook import BaseHook
+
+
+class AzureDataExplorerHook(BaseHook):
+    """
+    Interacts with Azure Data Explorer (Kusto).
+
+    Extra JSON field contains the following parameters:
+
+    .. code-block:: json
+
+        {
+            "tenant": "<Tenant ID>",
+            "auth_method": "<Authentication method>",
+            "certificate": "<Application PEM certificate>",
+            "thumbprint": "<Application certificate thumbprint>"
+        }
+
+    **Cluster**:
+
+    Azure Data Explorer cluster is specified by a URL, for example: "https://help.kusto.windows.net".
+    The parameter must be provided through `Host` connection detail.
+
+    **Tenant ID**:
+
+    To learn about tenants refer to: https://docs.microsoft.com/en-us/onedrive/find-your-office-365-tenant-id
+
+    **Authentication methods**:
+
+    Authentication method must be provided through "auth_method" extra parameter.
+    Available authentication methods are:
+
+      - AAD_APP : Authentication with AAD application certificate. Extra parameters:
+                  "tenant" is required when using this method. Provide application ID
+                  and application key through username and password parameters.
+
+      - AAD_APP_CERT: Authentication with AAD application certificate. Extra parameters:
+                      "tenant", "certificate" and "thumbprint" are required
+                      when using this method.
+
+      - AAD_CREDS : Authentication with AAD username and password. Extra parameters:
+                    "tenant" is required when using this method. Username and password
+                    parameters are used for authentication with AAD.
+
+      - AAD_DEVICE : Authenticate with AAD device code. Please note that if you choose
+                     this option, you'll need to authenticate for every new instance
+                     that is initialized. It is highly recommended to create one instance
+                     and use it for all queries.
+
+    :param azure_data_explorer_conn_id: Reference to the Azure Data Explorer connection.
+    :type azure_data_explorer_conn_id: str
+    """
+    def __init__(self,
+                 azure_data_explorer_conn_id='azure_data_explorer_default'):
+        self.conn_id = azure_data_explorer_conn_id
+        self.connection = self.get_conn()
+
+    def get_conn(self):
 
 Review comment:
   For some reason, cached_property swallows exceptions thrown by this method.. Moreover, I don't think using special decorator really makes it simpler and/or more efficient in this case.

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services