You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

使用REST API批量删除Microsoft Purview中的资产

解决方案:通过PyApacheAtlas批量删除Purview中已删除的SQL表资产
  • 核心结论:完全可以通过读取Excel中的DUID列表,结合PyApacheAtlas实现批量删除Purview资产。

具体实现步骤

  1. 读取Excel中的DUID数据
    使用pandas库读取Excel文件,提取所有需要删除的资产DUID:

    import pandas as pd
    # 读取Excel文件,假设DUID列名为"duid"
    df = pd.read_excel("你的资产列表文件.xlsx")
    duids_to_delete = df["duid"].tolist()
    
  2. 基于PyApacheAtlas批量删除资产
    参考删除逻辑修改为批量处理:

    from pyapacheatlas.auth import ServicePrincipalAuthentication
    from pyapacheatlas.core import PurviewClient
    
    # 配置认证信息
    auth = ServicePrincipalAuthentication(
        tenant_id="你的租户ID",
        client_id="你的客户端ID",
        client_secret="你的客户端密钥"
    )
    client = PurviewClient(
        account_name="你的Purview账户名",
        authentication=auth
    )
    
    # 分批次处理(Purview API建议单次不超过100个)
    batch_size = 100
    for i in range(0, len(duids_to_delete), batch_size):
        batch = duids_to_delete[i:i+batch_size]
        # 构造删除请求体
        delete_request = {"entityIds": [{"guid": duid} for duid in batch]}
        # 执行删除
        response = client.delete_entity(delete_request)
        print(f"已处理批次 {i//batch_size +1},删除状态:{response}")
    
  3. 关键注意事项

    • 确认Excel中的DUID是Purview资产的正确全局唯一标识符(GUID),避免误删有效资产
    • 执行删除前可通过client.get_entity(guid=duid)验证资产是否存在,确保操作准确性
    • 遵守Purview API的请求频率限制,分批次处理可降低触发限流的风险

内容的提问来源于stack exchange,提问作者nam

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.21 20:22:15