SignalR对Azure应用服务的访问限制

时间:2020-06-25 12:05:13

标签: azure networking signalr azure-web-app-service

我在Azure App Service中托管了Blazor Server asp.net Core应用程序。我正在尝试使用Azure门户刀片服务器中“网络”选项卡下的“访问限制”来限制对我IP地址的访问。

这有效,但是在我建立了SignalR连接的页面上,由于IP限制,我得到403。

System.Net.Http.HttpRequestException: Response status code does not indicate success: 403 (Ip Forbidden).
2020-06-25T12:01:55.897406435Z: [INFO]     at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
2020-06-25T12:01:55.897410435Z: [INFO]     at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.NegotiateAsync(Uri url, HttpClient httpClient, ILogger logger, CancellationToken cancellationToken)
2020-06-25T12:01:55.897414535Z: [INFO]     at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.GetNegotiationResponseAsync(Uri uri, CancellationToken cancellationToken)
2020-06-25T12:01:55.897418435Z: [INFO]     at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.SelectAndStartTransport(TransferFormat transferFormat, CancellationToken cancellationToken)
2020-06-25T12:01:55.897422335Z: [INFO]     at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsyncCore(TransferFormat transferFormat, CancellationToken cancellationToken)
2020-06-25T12:01:55.897432236Z: [INFO]     at System.Threading.Tasks.ForceAsyncAwaiter.GetResult()
2020-06-25T12:01:55.897435936Z: [INFO]     at Microsoft.AspNetCore.Http.Connections.Client.HttpConnection.StartAsync(TransferFormat transferFormat, CancellationToken cancellationToken)
2020-06-25T12:01:55.897439636Z: [INFO]     at Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory.ConnectAsync(EndPoint endPoint, CancellationToken cancellationToken)
2020-06-25T12:01:55.897443236Z: [INFO]     at Microsoft.AspNetCore.Http.Connections.Client.HttpConnectionFactory.ConnectAsync(EndPoint endPoint, CancellationToken cancellationToken)
2020-06-25T12:01:55.897446936Z: [INFO]     at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncCore(CancellationToken cancellationToken)
2020-06-25T12:01:55.897450436Z: [INFO]     at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsyncInner(CancellationToken cancellationToken)
2020-06-25T12:01:55.897454036Z: [INFO]     at System.Threading.Tasks.ForceAsyncAwaiter.GetResult()
2020-06-25T12:01:55.897457536Z: [INFO]     at Microsoft.AspNetCore.SignalR.Client.HubConnection.StartAsync(CancellationToken cancellationToken)

SignalR尝试使用哪个IP,我该如何解决? (使用本地SignalR而不是Azure SignalR服务)。

1 个答案:

答案 0 :(得分:0)

您可以在运行本地SignalR的计算机上检查whatismyipaddress。将公共外部IP地址添加到Azure App服务的Access Restrictions中。公共IP地址可能会定期更改。

如果要私下通过Azure应用服务访问本地SignalR,可以integrate your app with an Azure virtual network并在本地网络和Azure虚拟网络之间建立VPN gateway连接。在这种情况下,您可以选择列出本地IP地址。请参阅How to Find Your Local and External IP Address