如何在azure数据湖gen2中并行读写文件?

时间:2021-03-25 05:45:31

标签: azure azure-storage azure-data-lake-gen2

我在 kubernetes 环境中有一个 azure 函数服务,用于将文件读取和写入 azure datalake 存储 gen2。当写入 blob 存储触发器的新文件发生并读取该文件时。并对文件进行一些更改并写回存储。当一次更改多个文件时,kubernetes 中会生成多个 pod 并访问这些文件。对 ETAG 的差异做些什么,我从 azure 服务中得到了错误

The condition specified using HTTP conditional header(s) is not met.
ErrorCode:ConditionNotMet 

在读写操作中避免ETAG变化的最佳方法是什么?

下面是我的代码 读取绑定配置 trigger binding link

def main(blobdata: func.InputStream):
    print(blobdata.name)
    

写操作

def set_file_content(self, file_path: str, data: Union[str, bytes, bytearray]) -> None:
        file = DataLakeFileClient(
            account_url=self.account_url,
            credential=self.account_key,
            file_system_name=self.fs_name,
            file_path=file_path) 
        file.upload_data(data, length=len(data), overwrite=True)

我看到一些基于Etag配置的文章,

Azure Blob Error: StorageException: The condition specified using HTTP conditional header(s) is not met

读写操作中如何设置Etag?

我尝试按如下方式设置写入操作,但缺少某些内容。出现错误 condition not specified

file.upload_data(data, length=len(data), overwrite=True,etag="*",match_condition="IfPresent")

0 个答案:

没有答案