如何解决Azure存储错误:“尝试以其访问权限禁止的方式访问套接字”
问题:
我在Azure Web应用程序(开发/测试F1层)中托管了一个Web API,该文件将文件上传到Azure存储Blob容器并保存到Azure存储表,但是这样做时,出现以下错误:
"An attempt was made to access a socket in a way forbidden by its access permissions."
。如果有人可以提供帮助或对我的目光有所了解,我将不胜感激。谢谢。
我已经尝试过:
我使用了VS 2019中的Application Insights和附加的调试器,底部是完整的堆栈跟踪。
连接字符串(注意“ ...”以替换完整的AccountName和AccountKey):
"StorageConnectionString": "DefaultEndpointsProtocol=https;AccountName=s...001;AccountKey=TJi...nDkw==;EndpointSuffix=core.windows.net"
在Azure Web应用程序方面,我已执行以下操作:
我已允许所有CORS
我不使用任何VNet的
我没有任何访问限制
我正在使用从Azure存储中Access keys
下的Settings
提取的连接字符串
在Azure存储方面,我已执行以下操作:
帐户类型:StorageV2(通用v2)
我已允许所有CORS
我不使用任何VNet的
“允许访问自”设置为“所有网络”
BlobContainerClient container = new BlobContainerClient(_AppSettings.StorageConnectionString,$"patient-notes-{patientid}");
container.CreateIfNotExists(PublicAccesstype.Blob);
var blockBlob = container.GetBlobClient(fileName);
blockBlob.Upload(stream);
return blockBlob.Uri;
表存储代码:
private readonly AppSettings _AppSettings;
private readonly CloudStorageAccount _storageAccount;
private readonly CloudTableClient _tableClient;
private readonly TelemetryClient _telemetry;
public ErrorLogTableStorage(IOptions<AppSettings> appSettings,TelemetryClient telemetry)
{
_telemetry = telemetry;
_AppSettings = appSettings?.Value;
_storageAccount = CloudStorageAccount.Parse(_AppSettings.AzureTableStorageConnectionString);
_tableClient = _storageAccount.CreateCloudTableClient();
CloudTable table = _tableClient.GetTableReference(AzureStorageTable.ErrorLog.ToString());
table.CreateIfNotExistsAsync();
}
public async Task CreateErrorLog(ErrorLogEntity errorLog)
{
try
{
CloudTable table = _tableClient.GetTableReference(AzureStorageTable.ErrorLog.ToString());
TableOperation insertOperation = TableOperation.InsertOrMerge(errorLog);
await table.ExecuteAsync(insertOperation);
}
catch (Exception ex)
{
_telemetry.TrackException(ex);
}
}
用于表存储的堆栈跟踪:
Microsoft.Azure.Cosmos.Table.StorageException:
at Microsoft.Azure.Cosmos.Table.RestExecutor.TableCommand.Executor+<ExecuteAsync>d__1`1.MoveNext (Microsoft.Azure.Cosmos.Table,Version=1.0.8.0,Culture=neutral,PublicKeyToken=31bf3856ad364e35)
at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw (System.Private.CoreLib,Version=4.0.0.0,PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Private.CoreLib,PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Private.CoreLib,PublicKeyToken=7cec85d7bea7798e)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult (System.Private.CoreLib,PublicKeyToken=7cec85d7bea7798e)
at Infrastructure.AzureTableStorage.ErrorLogTableStorage+<CreateErrorLog>d__5.MoveNext (Infrastructure,Version=1.0.0.0,PublicKeyToken=nullInfrastructure,PublicKeyToken=null: AzureTableStorage\ErrorLogTableStorage.csInfrastructure,PublicKeyToken=null: 46)
Inner exception System.Net.Http.HttpRequestException handled at Microsoft.Azure.Cosmos.Table.RestExecutor.TableCommand.Executor+<ExecuteAsync>d__1`1.MoveNext:
at System.Net.Http.ConnectHelper+<ConnectAsync>d__1.MoveNext (System.Net.Http,Version=4.2.2.0,PublicKeyToken=b03f5f7f11d50a3a)
at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw (System.Private.CoreLib,PublicKeyToken=7cec85d7bea7798e)
at System.Net.Http.httpconnectionPool+<ConnectAsync>d__52.MoveNext (System.Net.Http,PublicKeyToken=7cec85d7bea7798e)
at System.Net.Http.httpconnectionPool+<CreateHttp11ConnectionAsync>d__53.MoveNext (System.Net.Http,PublicKeyToken=7cec85d7bea7798e)
at System.Net.Http.httpconnectionPool+<GethttpconnectionAsync>d__45.MoveNext (System.Net.Http,PublicKeyToken=7cec85d7bea7798e)
at System.Net.Http.httpconnectionPool+<SendWithRetryAsync>d__47.MoveNext (System.Net.Http,PublicKeyToken=7cec85d7bea7798e)
at System.Net.Http.RedirectHandler+<SendAsync>d__4.MoveNext (System.Net.Http,PublicKeyToken=7cec85d7bea7798e)
at System.Net.Http.DiagnosticsHandler+<SendAsync>d__2.MoveNext (System.Net.Http,PublicKeyToken=7cec85d7bea7798e)
at System.Net.Http.HttpClient+<FinishSendAsyncUnbuffered>d__71.MoveNext (System.Net.Http,PublicKeyToken=7cec85d7bea7798e)
at Microsoft.Azure.Cosmos.Table.RestExecutor.TableCommand.Executor+<ExecuteAsync>d__1`1.MoveNext (Microsoft.Azure.Cosmos.Table,PublicKeyToken=31bf3856ad364e35)
Inner exception System.Net.sockets.socketException handled at System.Net.Http.ConnectHelper+<ConnectAsync>d__1.MoveNext:
at System.Runtime.ExceptionServices.ExceptiondispatchInfo.Throw (System.Private.CoreLib,PublicKeyToken=7cec85d7bea7798e)
at System.Net.Http.ConnectHelper+<ConnectAsync>d__1.MoveNext (System.Net.Http,PublicKeyToken=b03f5f7f11d50a3a)
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。