Resolve conflicts

This commit is contained in:
Senthamil Sindhu 2024-07-19 07:48:12 -07:00
parent 2e2db3c2a9
commit 521ff39eb0

View File

@ -453,19 +453,26 @@ function configureEmulator(): Explorer {
return explorer;
}
async function fetchAndUpdateKeys(subscriptionId: string, resourceGroup: string, account: string) {
try {
export async function fetchAndUpdateKeys(subscriptionId: string, resourceGroup: string, account: string) {
Logger.logInfo(`Fetching keys for ${userContext.apiType} account ${account}`, "Explorer/fetchAndUpdateKeys");
const keys = await listKeys(subscriptionId, resourceGroup, account);
let keys;
try {
keys = await listKeys(subscriptionId, resourceGroup, account);
Logger.logInfo(`Keys fetched for ${userContext.apiType} account ${account}`, "Explorer/fetchAndUpdateKeys");
updateUserContext({
masterKey: keys.primaryMasterKey,
});
} catch (error) {
if (error.code === "AuthorizationFailed") {
keys = await getReadOnlyKeys(subscriptionId, resourceGroup, account);
Logger.logInfo(
`User context updated with Master key for ${userContext.apiType} account ${account}`,
`Read only Keys fetched for ${userContext.apiType} account ${account}`,
"Explorer/fetchAndUpdateKeys",
);
} catch (error) {
updateUserContext({
masterKey: keys.primaryReadonlyMasterKey,
});
} else {
logConsoleError(`Error occurred fetching keys for the account." ${error.message}`);
Logger.logError(
`Error during fetching keys or updating user context: ${error} for ${userContext.apiType} account ${account}`,
@ -474,6 +481,7 @@ async function fetchAndUpdateKeys(subscriptionId: string, resourceGroup: string,
throw error;
}
}
}
async function configurePortal(): Promise<Explorer> {
updateUserContext({