HTTP Error 500.30 Azure.RequestFailedException



我使用Visual Studio 4.8.04084将我的应用程序推送到Azure应用程序服务。我已经为配置了连接

  • Azure应用程序配置
  • Azure密钥保管库
  • Azure SQL数据库:我的数据
  • Azure SQL数据库:身份服务
  • Azure存储
  • Secrets.json

当我在本地通过Kestrel服务运行应用程序时,一切都很好。然而,当我通过IIS运行它时,我会遇到以下问题:

Visual Studio异常消息:

引发异常:Microsoft.Extension.Configuration.AzureAppConfiguration.dll 中的"Azure.RequestFailedException">

引发异常:Navrae.WebApp.dll 中的"Azure.RequestFailedException">

Navrae.WebApp.dll中发生类型为"Azure.RequestFailedException"的异常,但未在用户代码中进行处理
服务请求失败
状态:403(禁止(

标题:
服务器:openresty/1.17.8.2
日期:周三,2021年3月31日15:39:42 GMT
连接:保持活动
x-ms-request-id:09275563-49a0-40e6-88e2-***true
访问控制公开标头:DNT,X-CustomHeader,Keep Alive,User Agent,X-Requested-Wise,If Modified Since,Cache Control,Content Type,Authorization,X-ms-client-request-id,X-ms-useragent,X-ms-Content-sha256,X-ms-date,host,Accept,Accept Datetime,date,If Match,If None Match,Sync Token,X-ms-return-client-request-iid,ETag,Last Modified,Link,Memento Datetime,在ms、x-ms-request-id、x-ms-client-session-id、x-ms-effective-locale、WWW-Authenticate之后重试
严格的传输安全性:最大年龄=15724800;includeSubDomains内容长度:0

"iisexpress.exe"(CoreCLR:clrhost(:已加载"C:\Program Files(x86(\Microsoft Visual Studio\2019\Community\Common7\IDE\Remote Debugger\x64\Runtime\MicrosoftMicrosoft.VisualStudio.Debugger.Runtime.NetCoreApp.dll"。已跳过加载符号。模块已优化,调试器选项"仅我的代码"已启用。

程序'[222720]iisexpress.exe'已退出,代码为-1(0xffffffff(。

Azure应用程序服务日志:

at Azure.Data.AppConfiguration.ConfigurationClient.d__42.MoveNext() at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at 
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at
Azure.Core.PageResponseEnumerator.FuncAsyncPageable`1.d__2.MoveNext() at 
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at 
System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore`1.GetResult(Int16 token) at 
Azure.Core.PageResponseEnumerator.FuncAsyncPageable`1.d__2.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at Azure.AsyncPageable`1.d__6.MoveNext() at 
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at Azure.AsyncPageable`1.d__6.MoveNext() at 
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at 
System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore`1.GetResult(Int16 token) at 
Azure.AsyncPageable`1.d__6.System.Threading.Tasks.Sources.IValueTaskSource.GetResult(Int16 token) at 
Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.<>c__DisplayClass20_1.<b__2>d.MoveNext() at
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at 
Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.<>c__DisplayClass20_1.<b__2>d.MoveNext() at 
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at 
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at 
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at 
System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at 
Microsoft.Extensions.Configuration.AzureAppConfiguration.TracingUtils.d__2.MoveNext() at 
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at 
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at 
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at 
System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at 
Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.d__28.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at 
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at 
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at 
Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.d__20.MoveNext() at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() at 
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at 
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at 
System.Runtime.CompilerServices.ConfiguredTaskAwaitable.ConfiguredTaskAwaiter.GetResult() at 
Microsoft.Extensions.Configuration.AzureAppConfiguration.AzureAppConfigurationProvider.Load() at 
Microsoft.Extensions.Configuration.ConfigurationRoot..ctor(IList`1 providers) at 
Microsoft.Extensions.Configuration.ConfigurationBuilder.Build() at 
Microsoft.Extensions.Hosting.HostBuilder.BuildAppConfiguration() at
Microsoft.Extensions.Hosting.HostBuilder.Build() at Navrae.WebApp.Program.d__0.MoveNext() in C:UsersWork LaptopsourcereposNavraeNavrae.WebAppProgram.cs:line 19

Azure日志链接消息*

{"error":{"code":"AuthenticationFailed","message":"Authentication failed. The 'Authorization' header is missing."}}

当我调试应用程序时,它基本上在CreateHostBuilder中失败。我的ConnectionStrings都没有填充,我不知道在哪里或如何进一步调试它。

CreateHostBuilder

public static IHostBuilder CreateHostBuilder(string[] args) =>
Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((context, config) =>
{
var azConfigSettings = config.Build();
var azConfigConnection = azConfigSettings.GetConnectionString("REMOVED");
if (!string.IsNullOrEmpty(azConfigConnection))
{
// Use the connection string if it is available.
config.AddAzureAppConfiguration(azConfigConnection);
}
else if (Uri.TryCreate(azConfigSettings["Endpoints:REMOVED"], UriKind.Absolute, out var endpoint))
{
// Use Azure Active Directory authentication.
config.AddAzureAppConfiguration(options =>
{
options.Connect(endpoint, new DefaultAzureCredential());
});
}
var keyVaultEndpoint = new Uri(Environment.GetEnvironmentVariable("REMOVED")!);
config.AddAzureKeyVault(
keyVaultEndpoint,
new DefaultAzureCredential());
})
.ConfigureWebHostDefaults(webBuilder =>
{
webBuilder.UseStartup<Startup>();
});

您得到的错误是HTTP 403 Forbidden。

可能发生的情况是:

  • 当您在本地运行时,您使用的是可以访问Azure服务的身份
  • 当您在IIS中运行时,您使用的是无法访问Azure服务的网络服务标识

在Azure应用程序服务中,您可以将其配置为以";"管理身份";,然后,您可以授予该托管身份对您正在使用的服务的访问权限。

最新更新