NetworkInformationException
エラー文
System.Net.NetworkInformation.NetworkInformationException (13): Permission denied
at System.Net.NetworkInformation.NetworkChange.CreateSocket()
at System.Net.NetworkInformation.NetworkChange.add_NetworkAddressChanged(NetworkAddressChangedEventHandler value)
at System.Net.Http.HttpConnectionPoolManager.StartMonitoringNetworkChanges()
at System.Net.Http.HttpConnectionPool.HandleAltSvc(IEnumerable`1 altSvcHeaderValues, Nullable`1 responseAge)
at System.Net.Http.HttpConnectionPool.ProcessAltSvc(HttpResponseMessage response)
at System.Net.Http.HttpConnectionPool.SendWithVersionDetectionAndRetryAsync(HttpRequestMessage request, Boolean async, Boolean doRequestAuth, CancellationToken cancellationToken)
at System.Net.Http.DiagnosticsHandler.SendAsyncCore(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.RedirectHandler.SendAsync(HttpRequestMessage request, Boolean async, CancellationToken cancellationToken)
at System.Net.Http.HttpClient.<SendAsync>g__Core|83_0(HttpRequestMessage request, HttpCompletionOption completionOption, CancellationTokenSource cts, Boolean disposeCts, CancellationTokenSource pendingRequestsCts, CancellationToken originalCancellationToken)
at SampleNameSpace.SampleClass.SampleFunction() in /workspace/SampleClass.cs:line 101
原因
.NET Core アプリケーションがネットワークインターフェースの変更を検知する機能を使用しようとした際に Google Cloud Functions の実行環境で必要な権限が無い事。
対処法
Google Cloud Functions で実行する関数の冒頭に下記のコードを追加し、HTTP3を動的に無効化する。
AppContext.SetSwitch("System.Net.SocketsHttpHandler.Http3Support", false);