Skip to content
This repository was archived by the owner on Apr 13, 2020. It is now read-only.

Commit fa89421

Browse files
authored
Update azurecredentials.ts (#425)
1 parent 331bc30 commit fa89421

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

src/lib/azure/azurecredentials.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,21 @@ import { AzureAccessOpts } from "../../types";
1313
export const getCredentials = async (
1414
opts: AzureAccessOpts = {}
1515
): Promise<ClientSecretCredential | undefined> => {
16+
let servicePrincipalId = opts.servicePrincipalId;
17+
let servicePrincipalPassword = opts.servicePrincipalPassword;
18+
let tenantId = opts.tenantId;
19+
1620
// Load config from opts and fallback to spk config
17-
const { azure } = Config().introspection!;
21+
const config = Config();
22+
const azure =
23+
config && config.introspection ? config.introspection.azure : undefined;
1824

19-
const {
20-
servicePrincipalId = azure && azure.service_principal_id,
21-
servicePrincipalPassword = azure && azure.service_principal_secret,
22-
tenantId = azure && azure.tenant_id
23-
} = opts;
25+
if (azure) {
26+
servicePrincipalId = servicePrincipalId || azure.service_principal_id;
27+
servicePrincipalPassword =
28+
servicePrincipalPassword || azure.service_principal_secret;
29+
tenantId = tenantId || azure.tenant_id;
30+
}
2431

2532
if (
2633
!verifyConfigDefined(servicePrincipalId, servicePrincipalPassword, tenantId)

0 commit comments

Comments
 (0)