dabla opened a new pull request, #37821:
URL: https://github.com/apache/airflow/pull/37821

   <!--
    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.
    -->
   
   <!--
   Thank you for contributing! Please make sure that your code changes
   are covered with tests. And in case of new features or big changes
   remember to adjust the documentation.
   
   Feel free to ping committers for the review!
   
   In case of an existing issue, reference it using one of the following:
   
   closes: #ISSUE
   related: [fix: Pass proxies config when using ClientSecretCredential in 
AzureDataLakeStorageV2Hook](https://github.com/apache/airflow/pull/37103)
   
   How to write a good git commit message:
   http://chris.beams.io/posts/git-commit/
   -->
   
   Hello, as discussed in the previous 
[PR](https://github.com/apache/airflow/pull/37103) I created this new PR for 
introducing the DataToADLSOperator.  This operator allows you to use the 
AzureDataLakeStorageV2Hook without the need to write custom python code to 
interact with the Hook. 
   
   There is already a LocalFilesystemToADLSOperator which uses the older 
AzureDataLakeHook, but that operator doesn't allow you to directly store an 
XCom to Fabric, you need to create a local file first before uploading it, 
which in this case would mean creating an additional task to do it while in 
fact it's not necessary as the AzureDataLakeStorageV2Hook allows you to achieve 
the same without that intermediate step.
   
   That's why I introduced this DataToADLSOperator, we already use it at our 
company as a custom operator and it works great as this easily allows you to 
upload an XCom to Fabric, without the need to write python code interacting 
with the AzureDataLakeStorageV2Hook.  This means a more consice DAG, less code 
which improves readability and reduces complexity and of course makes it easy 
to use.
   
   Here is a simplified example on how to use the operator:
   
   ```python
   from airflow import DAG
   from airflow.operators.jira_plugin import JiraOperator
   from airflow.providers.microsoft.azure.transfers.data_to_local import 
DataToADLSOperator
   from datetime import datetime
   
   default_args = {
       'owner': 'airflow',
       'start_date': datetime(2024, 1, 1),
   }
   
   with DAG('jira_example_dag', default_args=default_args, 
schedule_interval=None) as dag:
       create_issue_task = JiraOperator(
           task_id='create_issue',
           jira_conn_id='jira_connection',
           method='POST',
           endpoint='issue',
           json={
               'fields': {
                   'project': {'key': 'PROJ'},
                   'summary': 'This is a test issue created from Airflow',
                   'description': 'This is the description of the test issue.',
                   'issuetype': {'name': 'Task'},
               }
           },
        dag=dag,
       )
   
       get_issue_task = JiraOperator(
           task_id='get_issue',
           jira_conn_id='jira_connection',
           method='GET',
           endpoint='issue/AIRFLOW-123',
        dag=dag,
       )
   
      write_to_azure_task = DataToADLSOperator(
           task_id="write_to_azure",
        azure_data_lake_conn_id="ms_azure_data_lake_connection",
        file_system_name="JIRA Monitoring",
        file_name="Files/JIRA/issues/Airflow/AIRFLOW-123.json",
        data=get_issue_task.output,
        overwrite=True,
        dag=dag,
       )
   
       create_issue_task >> get_issue_task >> write_to_azure_task
   ```
   
   ---
   **^ Add meaningful description above**
   Read the **[Pull Request 
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
 for more information.
   In case of fundamental code changes, an Airflow Improvement Proposal 
([AIP](https://cwiki.apache.org/confluence/display/AIRFLOW/Airflow+Improvement+Proposals))
 is needed.
   In case of a new dependency, check compliance with the [ASF 3rd Party 
License Policy](https://www.apache.org/legal/resolved.html#category-x).
   In case of backwards incompatible changes please leave a note in a 
newsfragment file, named `{pr_number}.significant.rst` or 
`{issue_number}.significant.rst`, in 
[newsfragments](https://github.com/apache/airflow/tree/main/newsfragments).
   


-- 
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.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to