added db storage check debug
This commit is contained in:
+91
-7
@@ -34,6 +34,8 @@ const accountName = process.env.AZURE_STORAGE_ACCOUNT_NAME;
|
||||
export const createContainerSas = async (containerName) => {
|
||||
// Get environment variables
|
||||
|
||||
containerName.length > 0;
|
||||
|
||||
// Best practice: create time limits
|
||||
const TEN_MINUTES = 10 * 60 * 1000;
|
||||
const NOW = new Date();
|
||||
@@ -68,7 +70,7 @@ export const createContainerSas = async (containerName) => {
|
||||
expiresOn: TEN_MINUTES_AFTER_NOW,
|
||||
};
|
||||
|
||||
//conLogJSON.stringify(sasOptions));
|
||||
console.log(JSON.stringify(sasOptions));
|
||||
|
||||
const sasToken = generateBlobSASQueryParameters(
|
||||
sasOptions,
|
||||
@@ -1116,12 +1118,13 @@ export const getAllProgressBlobs = async (containerName) => {
|
||||
});
|
||||
}
|
||||
|
||||
//console.log(
|
||||
// "\n////////////////////////////\n",
|
||||
// "blobObj:",
|
||||
// blobObj,
|
||||
// "\n////////////////////////////"
|
||||
// );
|
||||
console.log(
|
||||
"\n////////////////////////////\n",
|
||||
sasUrl,
|
||||
"blobObj:",
|
||||
blobObj,
|
||||
"\n////////////////////////////"
|
||||
);
|
||||
|
||||
return blobObj;
|
||||
};
|
||||
@@ -1332,3 +1335,84 @@ export const createRepCompleteMessage = async (
|
||||
|
||||
return sendMessageResponse;
|
||||
};
|
||||
|
||||
export const listContainers = async (
|
||||
blobServiceClient,
|
||||
containerNamePrefix
|
||||
) => {
|
||||
const options = {
|
||||
includeDeleted: false,
|
||||
includeMetadata: true,
|
||||
includeSystem: true,
|
||||
prefix: containerNamePrefix,
|
||||
};
|
||||
console.log(
|
||||
"\n\n\n=================================================\n",
|
||||
"Showing storage account contents:\n\n"
|
||||
);
|
||||
for await (const containerItem of blobServiceClient.listContainers(
|
||||
options
|
||||
)) {
|
||||
// ContainerItem
|
||||
console.log(`For-await list: ${containerItem.name}`);
|
||||
|
||||
// ContainerClient
|
||||
const containerClient = blobServiceClient.getContainerClient(
|
||||
containerItem.name
|
||||
);
|
||||
|
||||
await listBlobHierarchical(containerClient).catch((error) =>
|
||||
consoleLogger(error)
|
||||
);
|
||||
// ... do something with container
|
||||
}
|
||||
console.log("\n=================================================\n\n\n\n");
|
||||
};
|
||||
|
||||
export const listBlobHierarchical = async (
|
||||
containerClient,
|
||||
virtualHierarchyDelimiter = "/"
|
||||
) => {
|
||||
// page size - artificially low as example
|
||||
const maxPageSize = 2;
|
||||
|
||||
// some options for filtering list
|
||||
const listOptions = {
|
||||
includeCopy: false, // include metadata from previous copies
|
||||
includeDeleted: false, // include deleted blobs
|
||||
includeDeletedWithVersions: false, // include deleted blobs with versions
|
||||
includeLegalHold: false, // include legal hold
|
||||
includeMetadata: true, // include custom metadata
|
||||
includeSnapshots: false, // include snapshots
|
||||
includeTags: true, // include indexable tags
|
||||
includeUncommitedBlobs: false, // include uncommitted blobs
|
||||
includeVersions: false, // include all blob version
|
||||
prefix: "", // filter by blob name prefix
|
||||
};
|
||||
|
||||
let i = 1;
|
||||
console.log(`Folder ${virtualHierarchyDelimiter}`);
|
||||
|
||||
for await (const response of containerClient
|
||||
.listBlobsByHierarchy(virtualHierarchyDelimiter, listOptions)
|
||||
.byPage({ maxPageSize })) {
|
||||
console.log(` Blob number ${i++}`);
|
||||
const segment = response.segment;
|
||||
|
||||
if (segment.blobPrefixes) {
|
||||
// Do something with each virtual folder
|
||||
for await (const prefix of segment.blobPrefixes) {
|
||||
// build new virtualHierarchyDelimiter from current and next
|
||||
await listBlobHierarchical(
|
||||
containerClient,
|
||||
`${virtualHierarchyDelimiter}${prefix.name}`
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
for (const blob of response.segment.blobItems) {
|
||||
// Do something with each blob
|
||||
console.log(`\tBlobItem: name - ${blob.name}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user