From 2b73c3336a2cb0d311a48a251d19b13d92c781c5 Mon Sep 17 00:00:00 2001 From: Andy Chase Date: Tue, 1 Oct 2024 21:23:23 -0700 Subject: [PATCH] Revert "Changes to make api work and also better errors for no managed identity" This reverts commit 9aaf6b078c8883c7704e6442e106b190a41fa60e. --- utils/lib/azure.js | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/utils/lib/azure.js b/utils/lib/azure.js index e9eaff6294..6b717cbca9 100644 --- a/utils/lib/azure.js +++ b/utils/lib/azure.js @@ -1,17 +1,14 @@ // lib/azure.js +import { DefaultAzureCredential } from "@azure/identity"; //import { getCache, setCache } from "./cache"; export async function getAuthToken() { - if (process.env.AZURE_USE_MANAGED_IDENTITY != "true") { - return ""; - } - const { ManagedIdentityCredential } = require("@azure/identity"); let cachedToken = process.env.AUTH_TOKEN ? JSON.parse(process.env.AUTH_TOKEN) : ''; if (!cachedToken || cachedToken.expiresOnTimestamp < Date.now()) { - let cachedCredential = new ManagedIdentityCredential(); + let cachedCredential = new DefaultAzureCredential(); cachedToken = await cachedCredential.getToken("https://cognitiveservices.azure.com/.default"); process.env.AUTH_TOKEN = JSON.stringify(cachedToken); return cachedToken; @@ -19,3 +16,4 @@ export async function getAuthToken() { // console.log("cachedToken from memory", cachedToken); return process.env.AUTH_TOKEN ? JSON.parse(process.env.AUTH_TOKEN) : '';; } + \ No newline at end of file