Skip to content

Commit 47e3d7e

Browse files
fix: Added Comments and fixed issues with build
1 parent d665c9b commit 47e3d7e

File tree

2 files changed

+34
-40
lines changed

2 files changed

+34
-40
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
using System;
2+
using System.Threading.Tasks;
3+
using Azure.Core;
4+
using Azure.Identity;
5+
6+
namespace Microsoft.GS.DPSHost.Helpers
7+
{
8+
/// <summary>
9+
/// The Azure Credential Helper class
10+
/// </summary>
11+
public static class AzureCredentialHelper
12+
{
13+
/// <summary>
14+
/// Get the Azure Credentials based on the environment type
15+
/// </summary>
16+
/// <param name="clientId">The client Id in case of User assigned Managed identity</param>
17+
/// <returns>The Credential Object</returns>
18+
public static TokenCredential GetAzureCredential(string? clientId = null)
19+
{
20+
var env = Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Production";
21+
22+
if (string.Equals(env, "Development", StringComparison.OrdinalIgnoreCase))
23+
{
24+
return new DefaultAzureCredential(); // CodeQL [SM05139] Okay use of DefaultAzureCredential as it is only used in development
25+
}
26+
else
27+
{
28+
return clientId != null
29+
? new ManagedIdentityCredential(clientId)
30+
: new ManagedIdentityCredential();
31+
}
32+
}
33+
}
34+
}

App/backend-api/Microsoft.GS.DPS.Host/Helpers/azure_credential_utils.cs

Lines changed: 0 additions & 40 deletions
This file was deleted.

0 commit comments

Comments
 (0)