(key: string, customConfig?: BlobConfig)
| 451 | export async function deleteFromBlob(key: string, customConfig: BlobConfig): Promise<void> |
| 452 | |
| 453 | export async function deleteFromBlob(key: string, customConfig?: BlobConfig): Promise<void> { |
| 454 | const { BlobServiceClient, StorageSharedKeyCredential } = await import('@azure/storage-blob') |
| 455 | let blobServiceClient: BlobServiceClientType |
| 456 | let containerName: string |
| 457 | |
| 458 | if (customConfig) { |
| 459 | if (customConfig.connectionString) { |
| 460 | blobServiceClient = BlobServiceClient.fromConnectionString(customConfig.connectionString) |
| 461 | } else if (customConfig.accountName && customConfig.accountKey) { |
| 462 | const credential = new StorageSharedKeyCredential( |
| 463 | customConfig.accountName, |
| 464 | customConfig.accountKey |
| 465 | ) |
| 466 | blobServiceClient = new BlobServiceClient( |
| 467 | `https://${customConfig.accountName}.blob.core.windows.net`, |
| 468 | credential |
| 469 | ) |
| 470 | } else { |
| 471 | throw new Error('Invalid custom blob configuration') |
| 472 | } |
| 473 | containerName = customConfig.containerName |
| 474 | } else { |
| 475 | blobServiceClient = await getBlobServiceClient() |
| 476 | containerName = BLOB_CONFIG.containerName |
| 477 | } |
| 478 | |
| 479 | const containerClient = blobServiceClient.getContainerClient(containerName) |
| 480 | const blockBlobClient = containerClient.getBlockBlobClient(key) |
| 481 | |
| 482 | await blockBlobClient.deleteIfExists() |
| 483 | } |
| 484 | |
| 485 | /** |
| 486 | * Derive the deterministic Azure block id for a given part number. |
no test coverage detected