How to use Service Principal/Managed Identities to access Azure App Configuration from .NET Framework Application?

Aayush Suresh Jain 136 Reputation points
2023-01-12T12:30:34.1466667+00:00

I need to disable Local Authentication Methods (Access Keys) for Azure App Configuration Stores. Currently for an ASP.NET Framework application, I am using the following for accessing the App Configuration Store from my application:

<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="MyConfigStore" mode="Greedy" connectionString="${ConnectionString}" type="Microsoft.Configuration.ConfigurationBuilders.AzureAppConfigurationBuilder, Microsoft.Configuration.ConfigurationBuilders.AzureAppConfiguration" />
        <add name="Environment" mode="Greedy" type="Microsoft.Configuration.ConfigurationBuilders.EnvironmentConfigBuilder, Microsoft.Configuration.ConfigurationBuilders.Environment" />
    </builders>
</configBuilders>

Here the value of

${ConnectionString} = "Endpoint=https://<app_config>.azconfig.io;Id=<Id>;Secret=<Access Key>"

Now in order to access the App Configuration through the ASP.NET application, I created a Service Principal, generated a secret to use.

I have stored the CLIENT_ID, TENANT_ID and CLIENT_SECRET values. I have also assigned the App Configuration Data Reader role to the Service Principal.

I also have a managed identity which I can use.

Now what change do I need to make at the application side in order to access the App Configuration through the ASP.NET Framework application?

Azure App Configuration
Azure App Configuration
An Azure service that provides hosted, universal storage for Azure app configurations.
207 questions
ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,249 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,223 questions
0 comments No comments
{count} votes

Accepted answer
  1. MuthuKumaranMurugaachari-MSFT 22,141 Reputation points
    2023-01-12T22:49:05.2866667+00:00

    @Aayush Suresh Jain Thank you for reaching out to Microsoft Q&A. Please find the answers below:

    1. To disable access key authentication, follow doc: Disable access key authentication for an Azure App Configuration instance.
    2. App Configuration and .NET framework has managed identity built-in support and here is step by step guide Use managed identities to access App Configuration for ASP.NET Core app which includes role assignment for managed identity, adding Azure.Identity package and code snippet to access app configuration with managed identity. You can also use it for ASP.NET Framework app with the below snippet (refer ASP.NET Framework tutorial for more info)
       config.AddAzureAppConfiguration(options =>
                           options.Connect(new Uri(settings["AppConfig:Endpoint"]), new ManagedIdentityCredential()));
    

    Just note, Managed Identity can't be used when running application locally and the application must be deployed to azure service. I hope this helps with your question and feel free to add a comment if you have any other questions. We would be happy to assist you.

    Please 'Accept as answer' and ‘Upvote’ if it helped so that it can help others in the community.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful