* Extract account name and key from an Azure connection string. * Connection strings have the format: DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=...
(connectionString: string)
| 31 | * Connection strings have the format: DefaultEndpointsProtocol=https;AccountName=...;AccountKey=...;EndpointSuffix=... |
| 32 | */ |
| 33 | function parseConnectionString(connectionString: string): ParsedCredentials { |
| 34 | const accountNameMatch = connectionString.match(/AccountName=([^;]+)/) |
| 35 | if (!accountNameMatch) { |
| 36 | throw new Error('Cannot extract account name from connection string') |
| 37 | } |
| 38 | |
| 39 | const accountKeyMatch = connectionString.match(/AccountKey=([^;]+)/) |
| 40 | if (!accountKeyMatch) { |
| 41 | throw new Error('Cannot extract account key from connection string') |
| 42 | } |
| 43 | |
| 44 | return { |
| 45 | accountName: accountNameMatch[1], |
| 46 | accountKey: accountKeyMatch[1], |
| 47 | } |
| 48 | } |
| 49 | |
| 50 | /** |
| 51 | * Get account credentials from BLOB_CONFIG, extracting from connection string if necessary. |
no outgoing calls
no test coverage detected