I'm building an Azure DevOps pipeline extension and want to use Data Storage feature
I'm using typescript for development and the following API:
- azure-devops-extension-api
- azure-devops-extension-sdk
I was able to write a function and it compiles without any issues:
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}`);
});
The issue is that at runtime I'm getting an error: Unhandled: define is not defined
The issue has something to do with modules, but I can't get what can be wrong here. I tried to change the module parameter in tsconfig to commonjs, amd, umd which didn't help.
Finally, I have found a solution of how to use a Data Storage inside pipelines extension application.
I've created a repository and example of its usage:
https://github.com/parkhomenko/azure-build-task/blob/master/nodeFiles/index.ts