Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Azure开发/运营-使用Python摄取分析视图数据_Python_Python 3.x_Azure_Azure Devops_Azure Devops Rest Api - Fatal编程技术网

Azure开发/运营-使用Python摄取分析视图数据

Azure开发/运营-使用Python摄取分析视图数据,python,python-3.x,azure,azure-devops,azure-devops-rest-api,Python,Python 3.x,Azure,Azure Devops,Azure Devops Rest Api,我想从Azure DevOps访问分析视图数据,以访问已注册的项目活动 有没有人能举例说明他们将如何使用azure devops python库来实现这一点 我没有发现从Analytics视图中提取数据的示例。基本上,我需要一个Python脚本来显示我的项目的所有分析视图字段。经过一些研究,我设法部分解决了我的问题,因为这个解决方案不能从分析视图中获得所有内容,此外,查询结果中有20k条记录的限制: from azure.devops.connection import Connection f

我想从Azure DevOps访问分析视图数据,以访问已注册的项目活动

有没有人能举例说明他们将如何使用azure devops python库来实现这一点


我没有发现从Analytics视图中提取数据的示例。基本上,我需要一个Python脚本来显示我的项目的所有分析视图字段。

经过一些研究,我设法部分解决了我的问题,因为这个解决方案不能从分析视图中获得所有内容,此外,查询结果中有20k条记录的限制:

from azure.devops.connection import Connection
from msrest.authentication import BasicAuthentication
from azure.devops.v5_1.work_item_tracking.models import Wiql


token = 'xxx'
team_instance = 'https://dev.azure.com/xxx'


credentials = BasicAuthentication("", token)
connection = Connection(base_url=team_instance, creds=credentials)


def print_work_items(work_items):
    for work_item in work_items:
        print(
            "{0} {1}: {2}".format(
                work_item.fields["System.WorkItemType"],
                work_item.id,
                work_item.fields["System.Title"],
            )
        )


wit_client = connection.clients.get_work_item_tracking_client()


def get_TC_from_query(query):
    query_wiql = Wiql(query=query)
    results = wit_client.query_by_wiql(query_wiql).work_items
    # WIQL query gives a WorkItemReference => we get the corresponding WorkItem from id
    work_items = (wit_client.get_work_item(int(result.id)) for result in results)
    print_work_items(work_items)

get_TC_from_query(
    """\
SELECT
        [System.Id],
        [System.WorkItemType],
        [System.Title],
        [System.State],
        [System.AreaPath],
        [System.IterationPath]
FROM workitems
WHERE
        [System.TeamProject] = 'Project'
        and [System.WorkItemType] = 'Product Backlog Item'
        and [System.State] = 'Done'
ORDER BY [System.ChangedDate] DESC
"""
)    

你的意思是先从azure devops接收数据,然后将这些数据流式传输到azure databricks吗?@MerlinLiang MSFT