c#:使用来自网络框架应用程序的托管身份连接到Azure应用配置

我可以使用框架4.7.2应用程序中的连接字符串连接到Azure应用程序配置。 我想使用托管身份进行连接,但是没有

options.ConnectWithManagedIdentity

as seen in many netcore samples like this (page search: Authenticate with Managed Identity, and no label) https://zimmergren.net/introduction-azure-app-configuration-store-csharp-dotnetcore/

我创建一个构建器

using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.AzureAppConfiguration;

private static IConfiguration _configuration = null;
private static IConfigurationRefresher _refresher = null;

static void Main(string[] args)
{
    var builder = new ConfigurationBuilder();
    builder.AddAzureAppConfiguration(options =>
    {
        // options.ConnectWithManagedIdentity("https://YOUR_ENDPOINT.azconfig.io")
        options.Connect(Environment.GetEnvironmentVariable("ConnectionString"))
                .ConfigureRefresh(refresh =>
                {
                    refresh.Register("Demo")
                        .SetCacheExpiration(TimeSpan.FromSeconds(10));
                });

        _refresher = options.GetRefresher();
    });

    _configuration = builder.Build();

}

(https://docs.microsoft.com/en-us/azure/azure-app-configuration/enable-dynamic-configuration-dotnet)

如果检查AzureAppConfigurationOptions对象,将看不到任何与托管身份相关的信息。

是否必须添加一个附加的nuget包?

有任何想法吗?

评论