File size: 725 Bytes
97dab2a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import { Injectable } from '@nestjs/common';
import { AzureTokenService } from '@bpm/common';
import { SecretClient } from '@azure/keyvault-secrets';

@Injectable()
export class AzureApiService {
  constructor(private readonly azureTokenService: AzureTokenService) {}


  readSecret({ kvName, secretName }: { kvName: string; secretName: string }) {
    //console.log('Token:', this.azureTokenService.getToken());
    const credential = this.azureTokenService.getTokenCredential();
    if (!credential) {
      console.error('Token is not available');
      return null;  
    }
    else {
      return {
        kvName,
        secretName,
        secretValue: `Value-of-${secretName}-from-${kvName}`,
      };
    }  
  }
}