Created
January 29, 2020 14:41
-
-
Save kasunkv/f9ed65da3fb44c0098fb730810589613 to your computer and use it in GitHub Desktop.
Using System Assigned Managed identity to access Azure App Configuration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Azure.Identity; | |
| namespace MusicStore.Web | |
| { | |
| public class Program | |
| { | |
| ... | |
| public static IHostBuilder CreateHostBuilder(string[] args) => | |
| Host.CreateDefaultBuilder(args) | |
| .ConfigureWebHostDefaults(webBuilder => { | |
| webBuilder.UseStartup<Startup>(); | |
| }) | |
| .ConfigureAppConfiguration((context, config) => { | |
| var settings = config.Build(); | |
| var appConfigEndpoint = settings["AppSettings:AppConfiguration:Endpoint"]; | |
| if (!string.IsNullOrEmpty(appConfigEndpoint)) | |
| { | |
| var endpoint = new Uri(appConfigEndpoint); // Create the endpoint object of type Uri | |
| config.AddAzureAppConfiguration(options => | |
| { | |
| options | |
| .Connect(endpoint, new ManagedIdentityCredential()) | |
| .UseFeatureFlags(); | |
| }); | |
| } | |
| }); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment