|
| 1 | + |
| 2 | + .. Licensed to the Apache Software Foundation (ASF) under one |
| 3 | + or more contributor license agreements. See the NOTICE file |
| 4 | + distributed with this work for additional information |
| 5 | + regarding copyright ownership. The ASF licenses this file |
| 6 | + to you under the Apache License, Version 2.0 (the |
| 7 | + "License"); you may not use this file except in compliance |
| 8 | + with the License. You may obtain a copy of the License at |
| 9 | +
|
| 10 | + .. http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +
|
| 12 | + .. Unless required by applicable law or agreed to in writing, |
| 13 | + software distributed under the License is distributed on an |
| 14 | + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 15 | + KIND, either express or implied. See the License for the |
| 16 | + specific language governing permissions and limitations |
| 17 | + under the License. |
| 18 | +
|
| 19 | +===================================================== |
| 20 | +Google Cloud Storage to Azure Blob Storage transfer |
| 21 | +===================================================== |
| 22 | + |
| 23 | +`Google Cloud Storage <https://cloud.google.com/storage/>`__ and |
| 24 | +`Azure Blob Storage <https://learn.microsoft.com/en-us/azure/storage/blobs/>`__ |
| 25 | +are object stores commonly used for data lakes and file exchange. |
| 26 | +This guide describes copying objects from GCS into an Azure Blob container. |
| 27 | + |
| 28 | +Install the optional dependency when using this operator: |
| 29 | + |
| 30 | +.. code-block:: bash |
| 31 | +
|
| 32 | + pip install 'apache-airflow-providers-microsoft-azure[google]' |
| 33 | +
|
| 34 | +Prerequisite Tasks |
| 35 | +------------------ |
| 36 | + |
| 37 | +.. include:: ../operators/_partials/prerequisite_tasks.rst |
| 38 | + |
| 39 | +.. _howto/operator:GCSToAzureBlobStorageOperator: |
| 40 | + |
| 41 | +Operator |
| 42 | +-------- |
| 43 | + |
| 44 | +Use :class:`~airflow.providers.microsoft.azure.transfers.gcs_to_wasb.GCSToAzureBlobStorageOperator` |
| 45 | +to list objects under a GCS ``prefix`` and upload them to a container using ``blob_prefix`` as the base path. |
| 46 | +Use ``keep_directory_structure`` and ``flatten_structure`` the same way as |
| 47 | +:class:`~airflow.providers.amazon.aws.transfers.gcs_to_s3.GCSToS3Operator` (``flatten_structure`` wins when both apply). |
| 48 | +Object keys ending with ``/`` (GCS console folder markers) are not copied. |
| 49 | + |
| 50 | +Example: |
| 51 | + |
| 52 | +.. code-block:: python |
| 53 | +
|
| 54 | + copy_gcs_to_azure = GCSToAzureBlobStorageOperator( |
| 55 | + task_id="gcs_to_azure_blob", |
| 56 | + gcs_bucket="my-gcs-bucket", |
| 57 | + prefix="exports/daily/", |
| 58 | + container_name="my-container", |
| 59 | + blob_prefix="imports/daily", |
| 60 | + gcp_conn_id="google_cloud_default", |
| 61 | + wasb_conn_id="wasb_default", |
| 62 | + replace=True, |
| 63 | + ) |
| 64 | +
|
| 65 | +Reference |
| 66 | +--------- |
| 67 | + |
| 68 | +* `Google Cloud Storage Python client <https://cloud.google.com/python/docs/reference/storage/latest>`__ |
| 69 | +* `Azure Blob Storage client library <https://learn.microsoft.com/en-us/python/api/overview/azure/storage-blob-readme?view=azure-python>`__ |
0 commit comments