Azure data factory Azure数据工厂-清理批处理任务文件

Azure data factory Azure数据工厂-清理批处理任务文件,azure-data-factory,azure-batch,Azure Data Factory,Azure Batch,我正在使用Azure Data Factory v2,使用批处理帐户池和专用节点进行处理。我发现随着时间的推移,由于节点上的D:/temp驱动器上没有更多空间,批处理活动会失败。对于每个ADF作业,它会在节点上创建一个工作目录,作业完成后,我发现它不会清理文件。想知道以前是否有人遇到过这种情况,最好的解决方案是什么 编辑:现在似乎是ADF中的一个文件保留设置,当我提出这个问题时,它并不存在。对于将来遇到相同问题的任何人来说,这是一个可能的解决方案。在删除任务或任务保留时间过后,都会完成任务清理。

我正在使用Azure Data Factory v2,使用批处理帐户池和专用节点进行处理。我发现随着时间的推移,由于节点上的D:/temp驱动器上没有更多空间,批处理活动会失败。对于每个ADF作业,它会在节点上创建一个工作目录,作业完成后,我发现它不会清理文件。想知道以前是否有人遇到过这种情况,最好的解决方案是什么


编辑:现在似乎是ADF中的一个文件保留设置,当我提出这个问题时,它并不存在。对于将来遇到相同问题的任何人来说,这是一个可能的解决方案。

在删除任务或任务保留时间过后,都会完成任务清理。这两种方法中的任何一种都可以解决您面临的问题


注意:在最新的REST API2018-12-01.8.0中,默认保留时间已从无限期减少到7天,以允许默认情况下进行任务清理。使用之前版本创建的任务将不会有新的默认设置。

想出了一个解决方案,希望能够帮助下一个出现的人

我找到了用于批处理的Azure Python SDK,创建了一个小脚本,该脚本将遍历帐户上的所有池+节点,并删除workitems目录中早于1天的任何文件

import azure.batch as batch
import azure.batch.operations.file_operations as file_operations
from azure.batch.batch_auth import SharedKeyCredentials
import azure.batch.operations
import msrest.service_client
from datetime import datetime

program_datetime = datetime.utcnow()

batch_account = 'batchaccount001'
batch_url = 'https://batchaccount001.westeurope.batch.azure.com'
batch_key = '<BatchKeyGoesHere>'
batch_credentials = SharedKeyCredentials(batch_account, batch_key)

#Create Batch Client with which to do operations
batch_client = batch.BatchServiceClient(credentials=batch_credentials,
                                        batch_url = batch_url
                                        )

service_client = msrest.service_client.ServiceClient(batch_credentials, batch_client.config)

#List out all the pools
pools = batch_client.pool.list()
pool_list = [p.id for p in pools]

for p in pool_list:
    nodes = batch_client.compute_node.list(p)
    node_list = [n.id for n in nodes]
    for n in node_list:
        pool_id = p
        node_id = n
        print(f'Pool = {pool_id}, Node = {node_id}')
        fo_client = azure.batch.operations.FileOperations(service_client,
                                                          config=batch_client.config,
                                                          serializer=batch_client._serialize,
                                                          deserializer=batch_client._deserialize)
        files = fo_client.list_from_compute_node(pool_id,
                                                 node_id,
                                                 recursive=True,
                                                 file_list_from_compute_node_options=None,
                                                 custom_headers=None,
                                                 raw=False
                                                )

        for file in files:
            # Check to make sure it's not a directory. Directories do not have a last_modified property.
            if not file.is_directory:
                file_datetime = file.properties.last_modified.replace(tzinfo=None)
                file_age_in_seconds = (program_datetime - file_datetime).total_seconds()
                # Delete anything older than a day in the workitems directory.
                if file_age_in_seconds > 86400 and file.name.startswith('workitems'):
                    print(f'{file_age_in_seconds} : {file.name}')
                    fo_client.delete_from_compute_node(pool_id, node_id, file.name)

我是Azure数据工厂的工程师。我们使用了早于2018-12-01.8.0的Azure批处理SDK,因此通过ADF创建的批处理任务默认为前面提到的无限保留期。 我们正在推出一个修复程序,将通过ADF创建的批处理任务的保留期默认为30天,并在custom activity的typeProperties中引入一个属性retentionTimeInDays,客户可以在其ADF管道中设置该属性以覆盖此默认值。这项工作完成后,将更新上的文档,并提供更多详细信息。感谢您的耐心。

通过ARM模板部署时,您可以使用typeProperties中的retentionTimeInDays配置


请注意,您应该以双精度而非字符串形式提供config retentionTimeInDays。

有趣。这些任务是通过Azure Data Factory创建的,JSON中是否有特定属性可供活动引用?