Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,29 +60,35 @@ internal static ManagedIdentitySource GetManagedIdentitySource(ILoggerAdapter lo
string msiEndpoint = EnvironmentVariables.MsiEndpoint;
string msiSecretMachineLearning = EnvironmentVariables.MsiSecret;
string imdsEndpoint = EnvironmentVariables.ImdsEndpoint;
string podIdentityEndpoint = EnvironmentVariables.PodIdentityEndpoint;

logger?.Info("[Managed Identity] Detecting managed identity source...");

if (!string.IsNullOrEmpty(identityEndpoint) && !string.IsNullOrEmpty(identityHeader))
{
if (!string.IsNullOrEmpty(identityServerThumbprint))
{
logger?.Info("[Managed Identity] Service Fabric detected.");
return ManagedIdentitySource.ServiceFabric;
}
else
{
logger?.Info("[Managed Identity] App Service detected.");
return ManagedIdentitySource.AppService;
}
}
else if (!string.IsNullOrEmpty(msiSecretMachineLearning) && !string.IsNullOrEmpty(msiEndpoint))
{
logger?.Info("[Managed Identity] Machine Learning detected.");
return ManagedIdentitySource.MachineLearning;
}
else if (!string.IsNullOrEmpty(msiEndpoint))
{
logger?.Info("[Managed Identity] Cloud Shell detected.");
return ManagedIdentitySource.CloudShell;
}
else if (ValidateAzureArcEnvironment(identityEndpoint, imdsEndpoint, logger))
{
logger?.Info("[Managed Identity] Azure Arc detected.");
return ManagedIdentitySource.AzureArc;
}
else
Expand All @@ -94,6 +100,9 @@ internal static ManagedIdentitySource GetManagedIdentitySource(ILoggerAdapter lo
// Method to return true if a file exists and is not empty to validate the Azure arc environment.
private static bool ValidateAzureArcEnvironment(string identityEndpoint, string imdsEndpoint, ILoggerAdapter logger)
{
logger?.Info("[Managed Identity] Checked for sources: Service Fabric, App Service, Machine Learning, and Cloud Shell. " +
"They are not available.");

if (!string.IsNullOrEmpty(identityEndpoint) && !string.IsNullOrEmpty(imdsEndpoint))
{
logger?.Verbose(() => "[Managed Identity] Azure Arc managed identity is available through environment variables.");
Expand All @@ -110,10 +119,6 @@ private static bool ValidateAzureArcEnvironment(string identityEndpoint, string
logger?.Verbose(() => "[Managed Identity] Azure Arc managed identity is available through file detection.");
return true;
}
else
{
logger?.Warning("[Managed Identity] Azure Arc managed identity cannot be configured on a platform other than Windows and Linux.");
}

logger?.Verbose(() => "[Managed Identity] Azure Arc managed identity is not available.");
return false;
Expand Down
Loading