从 Azure Function 调用时 Azure App Configuration Managed Identity 失败
Azure App Configuration Managed Identity failing when called from Azure Function
我正在关注 Use managed identities to access app configuration。对于第 5 步,我已将我的函数 FilterFunction 分配为具有应用程序配置数据 Reader 角色:
我的启动函数代码如下:
var appConfigEndpoint = Environment.GetEnvironmentVariable("Endpoint");
var environment = Environment.GetEnvironmentVariable("Environment");
var sentinelValue = Environment.GetEnvironmentVariable("ConfigSentinelKey");
builder.ConfigurationBuilder.AddAzureAppConfiguration(options =>
{
// Load the configuration using labels
options.Connect(new Uri(appConfigEndpoint), new ManagedIdentityCredential())
.ConfigureRefresh(refreshoptions => refreshoptions.Register(
key: sentinelValue,
label: environment,
true))
.Select(KeyFilter.Any, environment);
});
然而,当我将我的函数发布到 Azure 时,我看到以下错误:
为什么我会收到这个错误?
分配角色后授予对 Azure 应用程序配置的访问权限。传播最多可能需要 15 分钟。在此期间,将观察您提供的错误信息。
如果首先使用身份在没有分配角色(导致 403)的情况下发出请求,然后再添加角色,则尤其如此。
我正在关注 Use managed identities to access app configuration。对于第 5 步,我已将我的函数 FilterFunction 分配为具有应用程序配置数据 Reader 角色:
我的启动函数代码如下:
var appConfigEndpoint = Environment.GetEnvironmentVariable("Endpoint");
var environment = Environment.GetEnvironmentVariable("Environment");
var sentinelValue = Environment.GetEnvironmentVariable("ConfigSentinelKey");
builder.ConfigurationBuilder.AddAzureAppConfiguration(options =>
{
// Load the configuration using labels
options.Connect(new Uri(appConfigEndpoint), new ManagedIdentityCredential())
.ConfigureRefresh(refreshoptions => refreshoptions.Register(
key: sentinelValue,
label: environment,
true))
.Select(KeyFilter.Any, environment);
});
然而,当我将我的函数发布到 Azure 时,我看到以下错误:
为什么我会收到这个错误?
分配角色后授予对 Azure 应用程序配置的访问权限。传播最多可能需要 15 分钟。在此期间,将观察您提供的错误信息。
如果首先使用身份在没有分配角色(导致 403)的情况下发出请求,然后再添加角色,则尤其如此。