Skip to content
Merged
Show file tree
Hide file tree
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 @@ -125,10 +125,11 @@ public static IHostApplicationBuilder ConfigureAzureAppConfiguration(this IHostA
if (!Uri.TryCreate(envEndpoint, UriKind.Absolute, out endpointUri))
{
throw new InvalidOperationException($"""
ConnectionString is missing.
It should be provided in 'ConnectionStrings:AzureAppConfig'
or '{configSectionName}:Endpoint' key
configuration section or 'AZURE_APP_CONFIG_ENDPOINT' environment variable.
Unable to find a valid Azure App Configuration endpoint.
Please provide a valid endpoint using one of the following sources:
- 'ConnectionStrings:AzureAppConfig' (connection string)
- '${configSectionName}:Endpoint' configuration section
- 'AZURE_APP_CONFIG_ENDPOINT' environment variable
""");
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Infinity.Toolkit.Azure/EnvironmentHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ internal static class EnvironmentHelper
{
public static bool IsRunningInContainer => Equals(Environment.GetEnvironmentVariable("DOTNET_RUNNING_IN_CONTAINER"), "true");

public static bool IsRunningInAzureAppService => Equals(Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME"), "true");
public static bool IsRunningInAzureAppService => !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WEBSITE_SITE_NAME"));

public static bool IsRunningInAzureContainerApps => IsRunningInContainer && !string.IsNullOrEmpty(Environment.GetEnvironmentVariable("CONTAINER_APP_NAME"));

Expand Down
6 changes: 5 additions & 1 deletion src/Infinity.Toolkit.Azure/Identity/TokenCredentialHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,13 @@ public static TokenCredential GetTokenCredential(string? clientId = null)
// First check if the app is running in Azure
if (EnvironmentHelper.IsRunningInAzure)
{
var userAssignedClientId = clientId ?? Environment.GetEnvironmentVariable("AZURE_CLIENT_ID");
tokenCredentials = [
new EnvironmentCredential(),
new ManagedIdentityCredential(ManagedIdentityId.FromUserAssignedClientId(clientId ?? Environment.GetEnvironmentVariable("AZURE_CLIENT_ID") ?? string.Empty))];
string.IsNullOrWhiteSpace(userAssignedClientId)
? new ManagedIdentityCredential()
: new ManagedIdentityCredential(ManagedIdentityId.FromUserAssignedClientId(userAssignedClientId))
];

var tokenCredential = new ChainedTokenCredential(tokenCredentials);
return tokenCredential;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,6 @@ private static void RegisterModules(IEnumerable<TypeInfo> discoveredModules, IHo

foreach (var module in modules)
{
if (registeredFeatureModules.ContainsKey(module.GetType()))
{
logger?.LogWarning(new EventId(1001, "RegisteringModules"), "Module {module} is already registered. Skipping duplicate registration.", module.GetType().FullName);
continue;
}

registeredFeatureModules.Add(module.GetType(), module);

if (module is IWebFeatureModule webModule)
Expand Down