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

Azure Storage REST API含BOM致VSTS扩展下拉列表无法加载求助

自定义Azure DevOps发布任务下拉列表无法加载Blob数据的问题

我正在开发一个自定义Azure DevOps(原VSTS)发布任务扩展,核心需求是让任务中的下拉列表从我的Azure存储账户REST端点拉取Blob数据。目前已经完成配置并上传了扩展,但下拉列表始终加载不出任何内容,实在卡在这里了,希望能得到大家的帮助。

已完成的配置文件

vss-extension.json

{ 
  "manifestVersion": 1, 
  "id": "build-release-task", 
  "name": "My Custom release task", 
  "version": ".0.1", 
  "publisher": "custext", 
  "public": false, 
  "targets": [ { "id": "Microsoft.VisualStudio.Services"} ], 
  "description": "A picklist which has values populated from the REST endpoint data source. Includes one build/release task.", 
  "categories": ["Build and release"], 
  "icons": { "default": "images/extension-icon.png"}, 
  "files": [ { "path": "buildAndReleaseTask"} ], 
  "contributions": [ 
    { 
      "id": "service-endpoint", 
      "description": "Service Endpoint type for custom Storage connection", 
      "type": "ms.vss-endpoint.service-endpoint-type", 
      "targets": ["ms.vss-endpoint.endpoint-types"], 
      "properties": { 
        "name": "custom", 
        "displayName": "Custom server connection", 
        "url": { 
          "displayName": "Server Url", 
          "helpText": "storage end point url."
        }, 
        "dataSources": [ 
          { 
            "name": "Storage Account", 
            "endpointUrl": "{{endpoint.url}}test/?restype=container&comp=list", 
            "resultSelector": "xpath://EnumerationResults/Blobs/Blob/Name"
          } 
        ] 
      } 
    }, 
    { 
      "id": "custom-build-release-task", 
      "type": "ms.vss-distributed-task.task", 
      "description": "Task with a dynamic property getting data from an endpoint REST data source", 
      "targets": ["ms.vss-distributed-task.tasks"], 
      "properties": { "name": "buildAndReleaseTask"} 
    } 
  ], 
  "helpMarkDown": "Learn More"
} 

task.json

{ 
  "id": "25958a0-63b7-11e6-88a5-f7c7f66e6264", 
  "name": "dropdownlist", 
  "friendlyName": "Drop down list", 
  "description": "Lists the db files", 
  "helpMarkDown": "Custom release task.Drop down list", 
  "category": "Utility", 
  "visibility": ["Release"], 
  "author": "satyam", 
  "version": { "Major": 0, "Minor": 1, "Patch": 0 }, 
  "instanceNameFormat": "dropdownlist $(message)", 
  "groups": [ { "name": "advanced", "displayName": "Advanced", "isExpanded": false } ], 
  "inputs": [ 
    { 
      "name": "CustomService", 
      "type": "connectedService:custom", 
      "label": "Storage end point", 
      "defaultValue": "", 
      "required": true, 
      "helpMarkDown": "Select the storage account to use. If needed, click on 'Manage' and add a new Service Endpoint of type 'Custom server connection'"
    }, 
    { 
      "name": "Scripts", 
      "type": "pickList", 
      "label": "saasscripts", 
      "required": true, 
      "helpMarkDown": "Select the name of the saas script.", 
      "properties": { "EditableOptions": "True"} 
    } 
  ], 
  "dataSourceBindings": [ 
    { 
      "target": "Scripts", 
      "endpointId": "$(CustomService)", 
      "dataSourceName": "Storage Account"
    } 
  ], 
  "outputVariables": [ { "name": "dbfile", "description": "Application URL of the selected App Service."} ], 
  "execution": { "Node": { "target": "powershell.js"} } 
} 

已尝试的调整

为了排查问题,我针对endpointUrl尝试了两种写法:

  • 使用变量引用:{{endpoint.url}}test/?restype=container&comp=list
  • 直接写完整URL:https://mycontainername.blob.core.windows.net/test/restype=container&comp=list

但两种方式都没能让下拉列表加载出Blob内容。

我的猜测和疑问

我现在怀疑问题出在响应解析环节——Azure Storage Blob列表的REST API返回的XML开头带有BOM(),这可能导致xpath选择器无法正确解析内容。所以想请教大家:

  1. 有没有办法让Azure Blob REST API返回的XML响应不带BOM?
  2. 或者有没有办法让API直接返回JSON格式的响应,绕过XML解析的问题?

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 08:46:25