azure-devops-extension-api (sdk):在管道扩展中使用时出现 API 错误

azure-devops-extension-api (sdk): APIs error when using in pipeline extension

我正在构建 Azure DevOps 管道扩展并希望使用数据 Storage feature

我正在使用 typescript 进行开发和以下 API:
- azure-devops-extension-api
- azure-devops-extension-sdk

我能够编写一个函数并且编译没有任何问题:

const extensionId = SDK.getExtensionContext().extensionId;
const accessToken = await SDK.getAccessToken();
const dataService = await SDK.getService<IExtensionDataService>(CommonServiceIds.ExtensionDataService);
const manager = await dataService.getExtensionDataManager(extensionId, accessToken);
const document = await manager.getDocument('MyCollection', 'MyDocument');
document.action = 'hello world - pipeline';
manager.updateDocument('MyCollection', document).then(function (doc) {
  LoggingUtils.logMessage(`Doc version: ${doc.__etag}`);
});

问题是在运行时出现错误:未处理:未定义定义

这个问题与模块有关,但我不知道这里有什么问题。我尝试将tsconfig中的module参数改为commonjs,amd, umd 没有帮助。

最后,我找到了如何在管道扩展应用程序中使用数据存储的解决方案。

我已经创建了一个存储库及其用法示例:
https://github.com/parkhomenko/azure-build-task/blob/master/nodeFiles/index.ts