如何使用 rest api 在 azure pipeline 中传递参数?

how to pass parameters in azure pipeline using rest api?

我正在使用邮递员向 azure API 到 运行 一个位于突触中的管道发出休息请求,就权限和令牌而言,我已经得到它们并且它可以工作,问题是管道接收到 3 个参数,但我不知道如何传递它们,所以我有这个请求,例如:

https://hvdhgsad.dev.azuresynapse.net/pipelines/pipeName/createRun?api-version=2020-12-01

以及我在正文中添加的参数:

{
    "parameters": {
        "p_dir": {
            "type": "string",
            "defaultValue": "val1"
        },
        "container": {
            "type": "string",
            "defaultValue": "val"
        },
        "p_folder": {
            "type": "string",
            "defaultValue": "val3"
        }
    }
}

但是当我验证随请求启动的 运行 时,我得到了这个。

{
    "id": "xxxxxxxxxxxxxxx",
    "runId": "xxxxxxxxxxxxxxxxxxxxx",
    "debugRunId": null,
    "runGroupId": "xxxxxxxxxxxxxxxxxxxx",
    "pipelineName": "xxxxxxxxxxxxxxxxx",
    "parameters": {
        "p_dir": "",
        "p_folder": "",
        "container": ""
    },
    "invokedBy": {
        "id": "xxxxxxxxxxxxxxxxx",
        "name": "Manual",
        "invokedByType": "Manual"
    },
    "runStart": "2021-07-20T05:56:04.2468861Z",
    "runEnd": "2021-07-20T05:59:10.1734654Z",
    "durationInMs": 185926,
    "status": "Failed",
    "message": "Operation on target Data flow1 failed: {\"StatusCode\":\"DF-Executor-SourceInvalidPayload\",\"Message\":\"Job failed due to reason: Data preview, debug, and pipeline data flow execution failed because container does not exist\",\"Details\":\"\"}",
    "lastUpdated": "2021-07-20T05:59:10.1734654Z",
    "annotations": [],
    "runDimension": {},
    "isLatest": true
}

参数是空的,所以我不知道有什么问题或缺失。 通过它们的正确方法是什么???

参考:https://docs.microsoft.com/en-us/rest/api/synapse/data-plane/pipeline/create-pipeline-run#examples

刚刚创建了一个帐户来回答这个问题,因为我遇到了同样的问题。

我通过在正文中包含变量名称及其后续值来解决这个问题 JSON。

例如

{"variable": "value", "variable": "value"} 

按照您发布的文档找到这个,在请求正文下,它将变量的名称和值直接传递到 JSON 正文中。

{
  "OutputBlobNameList": [
    "exampleoutput.csv"
  ]
}

这个特殊的例子是 list/array 所以如果你传递的是不需要的字符串参数,它会添加方括号 [] 让我感到困惑。