-
Notifications
You must be signed in to change notification settings - Fork 62
Expand file tree
/
Copy pathdeleteActivityProfileContentFromAzure.ts
More file actions
34 lines (33 loc) · 1.12 KB
/
deleteActivityProfileContentFromAzure.ts
File metadata and controls
34 lines (33 loc) · 1.12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import {
Aborter,
BlobURL,
ContainerURL,
ServiceURL,
SharedKeyCredential,
StorageURL,
} from '@azure/storage-blob';
import getStorageDir from '../../utils/getStorageDir';
import { DeleteActivityProfileContentOptions } from './deleteActivityProfileContent';
import { AzureFileStorageConfig } from './utils/getFileStorageConfig/FileStorageConfig';
export async function deleteActivityProfileContentFromAzure(
config: AzureFileStorageConfig,
opts: DeleteActivityProfileContentOptions,
): Promise<void> {
const credential = new SharedKeyCredential(
config.azureAccount,
config.azureAccountKey,
);
const pipeline = StorageURL.newPipeline(credential);
const serviceURL = new ServiceURL(
`https://${config.azureAccount}.blob.core.windows.net`,
pipeline,
);
const containerUrl = ContainerURL.fromServiceURL(serviceURL, config.azureContainerName);
const profileDir = getStorageDir({
subfolder: config.azureSubFolder,
lrs_id: opts.lrs_id,
});
const filePath = `${profileDir}/${opts.key}`;
const blobUrl = BlobURL.fromContainerURL(containerUrl, filePath);
await blobUrl.delete(Aborter.none);
}