Merged PR 1195: debugging info for the logstream
Related work items: #8436
This commit is contained in:
+27
-1
@@ -95,4 +95,30 @@ AZURE_PEDW_CONTAINER = "pedwapplications"
|
||||
AZURE_PEDW_QUEUE_ENDPOINT = https://$AZURE_STORAGE_ACCOUNT_NAME.queue.core.windows.net
|
||||
|
||||
//gov.notify
|
||||
NOTIFY_API_KEY = pedwnextauthkey-90f93710-9dae-423e-aea1-11eccd0dc132-0c9469d9-d671-444d-9e9d-3e5a62001043
|
||||
NOTIFY_API_KEY = pedwnextauthkey-90f93710-9dae-423e-aea1-11eccd0dc132-0c9469d9-d671-444d-9e9d-3e5a62001043
|
||||
|
||||
|
||||
# //Bastion access to vnet vms
|
||||
# [13:56] Suter, Matthew (COOG - DDAT - IT Services)
|
||||
# Login is PEDWAdmin
|
||||
# [13:57] Suter, Matthew (COOG - DDAT - IT Services)
|
||||
# Pwd is -PK2_NQ-HuD2AFp
|
||||
|
||||
|
||||
# [13:41] Suter, Matthew (COOG - DDAT - IT Services)
|
||||
# so the admin login is PEDWSqlAdminPP
|
||||
# [13:41] Suter, Matthew (COOG - DDAT - IT Services)
|
||||
# password is rvJDj4ekfGSgwQpWTA38tDVJvFfSMbvmNGxd3YcII0M=
|
||||
|
||||
|
||||
|
||||
# @Microsoft.KeyVault(SecretUri=https://test-pedw-kv.vault.azure.net/secrets/PEDW-FrontEnd-Test-AppReg-Secrate/)
|
||||
|
||||
|
||||
# [12:24] Thompson, Phil (COOG - Planning & Environment Decisions Wales)
|
||||
# {"pinswg_name":"48181 Planning Appeal E PROOF8.pdf","pinswg_DocumentIds@odata.bind":"/incidents(6CD13EF8-5BC9-ED11-A997-00224800E98C)","pinswg_isharedocumentlocations":"846040009","pinswg_isharedocumentclassification":"846040000","pinswg_uploadurl":"https://pedwinternalprod.blob.core.windows.net/crm-file-upload/6CD13EF8-5BC9-ED11-A997-00224800E98C/48181 Planning Appeal E PROOF8.pdf"}
|
||||
# [12:25] Thompson, Phil (COOG - Planning & Environment Decisions Wales)
|
||||
# https://crm2016.llc.gov.wales/PEDW/api/data/v8.2/pinswg_documents
|
||||
|
||||
|
||||
# DATABASE_URL='sqlserver://pp-pedw-sql.database.windows.net:1433;database=PEDWPreProd;user=pp-pedw-ukw;password=jscw4+896w9YaiXruOA3mtpNkio1oUZxBZcFJ9Awdz4=;encrypt=true;trustservercertificate=false;hostnameincertificate=*.database.windows.net;logintimeout=30;authentication=SqlPassword'
|
||||
+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}`);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -0,0 +1,74 @@
|
||||
import { DefaultAzureCredential } from "@azure/identity";
|
||||
import { BlobServiceClient, ContainerClient } from "@azure/storage-blob";
|
||||
import { v4 as uuidv4 } from "uuid";
|
||||
import {
|
||||
createContainerSas,
|
||||
listContainers,
|
||||
listBlobHierarchical,
|
||||
} from "../actions/azurestorage";
|
||||
|
||||
import { PrismaClient } from "@prisma/client";
|
||||
|
||||
import { consoleLogger, getIP } from "../actions";
|
||||
|
||||
const ShowStorage = (props) => {
|
||||
const { container } = props;
|
||||
|
||||
return <div>hello</div>;
|
||||
};
|
||||
|
||||
export const getServerSideProps = async (ctx) => {
|
||||
const { query, req, res } = ctx;
|
||||
getIP(req);
|
||||
|
||||
console.log(
|
||||
"have these?:",
|
||||
process.env.AZURE_TENANT_ID,
|
||||
process.env.AZURE_CLIENT_ID,
|
||||
process.env.AZURE_CLIENT_SECRET
|
||||
);
|
||||
const accountName = process.env.AZURE_STORAGE_ACCOUNT_NAME;
|
||||
const showDebug = process.env.SHOW_DEBUG || false;
|
||||
|
||||
const creds = new DefaultAzureCredential();
|
||||
|
||||
const blobServiceClient = new BlobServiceClient(
|
||||
`https://${accountName}.blob.core.windows.net`,
|
||||
creds
|
||||
);
|
||||
|
||||
console.log(
|
||||
"\n\n\n=================================================\n",
|
||||
"Environment name:" + accountName,
|
||||
"\n=================================================\n"
|
||||
);
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function checkDB() {
|
||||
const allUsers = await prisma.user.findMany();
|
||||
console.log(
|
||||
"\n\n\n=================================================\n",
|
||||
"Show users in Auth DB:\n",
|
||||
allUsers,
|
||||
"\n=================================================\n"
|
||||
);
|
||||
}
|
||||
|
||||
showDebug &&
|
||||
(checkDB()
|
||||
.then(async () => {
|
||||
await prisma.$disconnect();
|
||||
})
|
||||
.catch(async (e) => {
|
||||
consoleLogger(e);
|
||||
await prisma.$disconnect();
|
||||
//process.exit(1);
|
||||
}),
|
||||
await listContainers(blobServiceClient).catch((error) =>
|
||||
consoleLogger(error)
|
||||
));
|
||||
return { props: {} };
|
||||
};
|
||||
|
||||
export default ShowStorage;
|
||||
@@ -8,7 +8,7 @@ datasource db {
|
||||
}
|
||||
|
||||
model Account {
|
||||
id String @id(map: "PK__accounts__3213E83F407D3F70") @default(cuid()) @db.VarChar(191)
|
||||
id String @id(map: "PK__accounts__3213E83FAEBDFC84") @default(cuid()) @db.VarChar(191)
|
||||
userId String @map("user_id") @db.VarChar(191)
|
||||
type String @db.VarChar(191)
|
||||
provider String @db.VarChar(191)
|
||||
@@ -27,7 +27,7 @@ model Account {
|
||||
}
|
||||
|
||||
model Session {
|
||||
id String @id(map: "PK__sessions__3213E83F3DEBC794") @default(cuid()) @db.VarChar(191)
|
||||
id String @id(map: "PK__sessions__3213E83F970AEA7D") @default(cuid()) @db.VarChar(191)
|
||||
sessionToken String @unique @map("session_token") @db.VarChar(191)
|
||||
userId String @map("user_id") @db.VarChar(191)
|
||||
expires DateTime
|
||||
@@ -37,7 +37,7 @@ model Session {
|
||||
}
|
||||
|
||||
model User {
|
||||
id String @id(map: "PK__users__3213E83F038A1396") @default(cuid()) @db.VarChar(191)
|
||||
id String @id(map: "PK__users__3213E83FC774F580") @default(cuid()) @db.VarChar(191)
|
||||
name String? @db.VarChar(191)
|
||||
email String? @unique @db.VarChar(191)
|
||||
emailVerified DateTime? @map("email_verified")
|
||||
|
||||
Reference in New Issue
Block a user