chore: update task versions and add maxResults input to ListBlobs task

This commit is contained in:
2026-02-25 08:23:19 +01:00
parent d08e6c8958
commit b3a78980f7
6 changed files with 23 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "list-blobs-task",
"version": "1.0.0",
"version": "1.0.1",
"private": true,
"author": "Slawomir Koszewski",
"license": "MIT",

View File

@@ -26,10 +26,11 @@ function parseBlobNames(xml: string): string[] {
return names;
}
function buildListUrl(storageAccountName: string, containerName: string, prefix: string): string {
function buildListUrl(storageAccountName: string, containerName: string, prefix: string, maxResults: number): string {
const url = new URL(`https://${storageAccountName}.blob.core.windows.net/${encodeURIComponent(containerName)}`);
url.searchParams.set('restype', 'container');
url.searchParams.set('comp', 'list');
url.searchParams.set('maxresults', String(maxResults));
if (prefix) {
url.searchParams.set('prefix', prefix);
@@ -63,12 +64,18 @@ async function run(): Promise<void> {
const storageAccountName = requireInput('storageAccountName');
const containerName = requireInput('containerName');
const prefix = tl.getInput('prefix', false)?.trim() || '';
const maxResultsRaw = tl.getInput('maxResults', false)?.trim() || '1000';
const maxResults = Number.parseInt(maxResultsRaw, 10);
if (!Number.isInteger(maxResults) || maxResults <= 0) {
throw new Error(`Invalid maxResults value: ${maxResultsRaw}. Expected a positive integer.`);
}
console.log('Requesting storage access token from Microsoft Entra ID...');
const accessToken = await requestStorageAccessToken(endpointId);
const listUrl = buildListUrl(storageAccountName, containerName, prefix);
const blobNames = await listBlobs(listUrl, accessToken);
const listUrl = buildListUrl(storageAccountName, containerName, prefix, maxResults);
const blobNames = (await listBlobs(listUrl, accessToken)).slice(0, maxResults);
const serialized = JSON.stringify(blobNames);
tl.setVariable('LIST_BLOBS_JSON', serialized);

View File

@@ -10,7 +10,7 @@
"version": {
"Major": 1,
"Minor": 0,
"Patch": 0
"Patch": 1
},
"instanceNameFormat": "List blobs: $(storageAccountName)/$(containerName)",
"inputs": [
@@ -45,6 +45,14 @@
"defaultValue": "",
"required": false,
"helpMarkDown": "Optional blob name prefix used to filter results."
},
{
"name": "maxResults",
"type": "string",
"label": "Maximum Blob Count",
"defaultValue": "1000",
"required": false,
"helpMarkDown": "Maximum number of blobs to return. Default is 1000."
}
],
"execution": {