Refactored azureBlobStorage, changelog, techdocs-backend config
Signed-off-by: titanventura <aswath7862001@gmail.com>
This commit is contained in:
@@ -66,6 +66,7 @@ export class AzureBlobStoragePublish implements PublisherBase {
|
||||
}
|
||||
|
||||
static fromConfig(config: Config, logger: Logger): PublisherBase {
|
||||
let storageClient: BlobServiceClient;
|
||||
let containerName = '';
|
||||
try {
|
||||
containerName = config.getString(
|
||||
@@ -87,49 +88,43 @@ export class AzureBlobStoragePublish implements PublisherBase {
|
||||
const connectionStringKey =
|
||||
'techdocs.publisher.azureBlobStorage.connectionString';
|
||||
const connectionString = config.getOptionalString(connectionStringKey);
|
||||
|
||||
if (connectionString) {
|
||||
logger.info(
|
||||
`using ${connectionStringKey} string to create BlobServiceClient`,
|
||||
`Using '${connectionStringKey}' configuration to create storage client`,
|
||||
);
|
||||
const storageClient =
|
||||
BlobServiceClient.fromConnectionString(connectionString);
|
||||
return new AzureBlobStoragePublish({
|
||||
storageClient: storageClient,
|
||||
containerName: containerName,
|
||||
legacyPathCasing: legacyPathCasing,
|
||||
logger: logger,
|
||||
});
|
||||
}
|
||||
|
||||
let accountName = '';
|
||||
try {
|
||||
accountName = config.getString(
|
||||
'techdocs.publisher.azureBlobStorage.credentials.accountName',
|
||||
);
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
"Since techdocs.publisher.type is set to 'azureBlobStorage' in your app config, " +
|
||||
'techdocs.publisher.azureBlobStorage.credentials.accountName is required.',
|
||||
);
|
||||
}
|
||||
|
||||
// Credentials is an optional config. If missing, default Azure Blob Storage environment variables will be used.
|
||||
// https://docs.microsoft.com/en-us/azure/storage/common/storage-auth-aad-app
|
||||
const accountKey = config.getOptionalString(
|
||||
'techdocs.publisher.azureBlobStorage.credentials.accountKey',
|
||||
);
|
||||
|
||||
let credential;
|
||||
if (accountKey) {
|
||||
credential = new StorageSharedKeyCredential(accountName, accountKey);
|
||||
storageClient = BlobServiceClient.fromConnectionString(connectionString);
|
||||
} else {
|
||||
credential = new DefaultAzureCredential();
|
||||
}
|
||||
let accountName = '';
|
||||
try {
|
||||
accountName = config.getString(
|
||||
'techdocs.publisher.azureBlobStorage.credentials.accountName',
|
||||
);
|
||||
} catch (error) {
|
||||
throw new Error(
|
||||
"Since techdocs.publisher.type is set to 'azureBlobStorage' in your app config, " +
|
||||
'techdocs.publisher.azureBlobStorage.credentials.accountName is required.',
|
||||
);
|
||||
}
|
||||
|
||||
const storageClient = new BlobServiceClient(
|
||||
`https://${accountName}.blob.core.windows.net`,
|
||||
credential,
|
||||
);
|
||||
// Credentials is an optional config. If missing, default Azure Blob Storage environment variables will be used.
|
||||
// https://docs.microsoft.com/en-us/azure/storage/common/storage-auth-aad-app
|
||||
const accountKey = config.getOptionalString(
|
||||
'techdocs.publisher.azureBlobStorage.credentials.accountKey',
|
||||
);
|
||||
|
||||
let credential;
|
||||
if (accountKey) {
|
||||
credential = new StorageSharedKeyCredential(accountName, accountKey);
|
||||
} else {
|
||||
credential = new DefaultAzureCredential();
|
||||
}
|
||||
|
||||
storageClient = new BlobServiceClient(
|
||||
`https://${accountName}.blob.core.windows.net`,
|
||||
credential,
|
||||
);
|
||||
}
|
||||
|
||||
return new AzureBlobStoragePublish({
|
||||
storageClient: storageClient,
|
||||
|
||||
Reference in New Issue
Block a user