TL;DR: How can I use Managed Service Identities in an Azure Function v1 for configuring via Azure App Configuration?
I'm trying to make use of Azure App Configuration from within an Azure Function v1 using .NET Framework. I would ideally like to make use of the ConfigurationBuilders.
This would mean using the SimpleJsonConfigBuilder
class when running on a dev machine but using AzureAppConfigurationBuilder
when hosted in Azure.
I've got it working with our Web API projects but I'm stuck when it comes to the Azure Functions.
The problem as I see it, is that the Azure Function host is using its own web.config and therefore cannot be modified with the config I would use in a web project.
<configuration>
<configSections>
<section name="configBuilders" type="System.Configuration.ConfigurationBuildersSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" restartOnExternalChanges="false" requirePermission="false" />
</configSections>
<configBuilders>
<builders>
<add name="Environment" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment, Version=1.0.0.0, Culture=neutral" />
<add name="Json" optional="true" mode="Greedy" jsonFile="~/App_Data/settings.json" type="Microsoft.Configuration.ConfigurationBuilders.SimpleJsonConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Json, Version=1.0.0.0, Culture=neutral" />
<add name="AzureViaConnectionString" optional="true" mode="Greedy" connectionString="${AppConfigConnectionString}" type="Microsoft.Configuration.ConfigurationBuilders.AzureAppConfigurationBuilder, Microsoft.Configuration.ConfigurationBuilders.AzureAppConfiguration" />
<add name="AzureViaMsi" optional="true" mode="Greedy" endPoint="${AppConfigEndpoint}" type="Microsoft.Configuration.ConfigurationBuilders.AzureAppConfigurationBuilder, Microsoft.Configuration.ConfigurationBuilders.AzureAppConfiguration" />
</builders>
</configBuilders>
<appSettings configBuilders="Environment,Json">
...
Even if I don't use the xml config, which is I'm assuming will not be possible, is there a way to modify the ConfigurationManager.AppSettings
as seems to happen with the ConfigBuilders?
ConfigurationManager.AppSettings
is readonly at the point I'm accessing, so I cannot update it myself.
We do have an IAppSettings
interface for which I have written an implementation to use the Azure App Configuration REST api. However, that means storing the secret associated with the service in the usual function app settings, rather than being able to use Managed Service Identities.
Additionally, the function runtime needs some other settings before it will even reach the point of executing any of my code, meaning that I cannot move all of the settings from the standard location.
Migrating to Azure Functions V2 is not currently feasible.