Microsoft.WindowsAzure.Storage.StorageException:远程服务器返回错误:(403) [英] Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (403)

查看:518
本文介绍了Microsoft.WindowsAzure.Storage.StorageException:远程服务器返回错误:(403)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在重新发布后,这是最初的错误:

upon fresh publish this is the initial error:

System.ApplicationException:跟踪侦听器AzureBlobTraceListener 被禁用. ---> System.InvalidOperationException:的SAS URL 未指定云存储帐户.使用环境 变量'DIAGNOSTICS_AZUREBLOBCONTAINERSASURL'对其进行定义. Microsoft.WindowsAzure.WebSites.Diagnostics.AzureBlobTraceLi‌stener.RefreshConfig‌()

System.ApplicationException: The trace listener AzureBlobTraceListener is disabled. ---> System.InvalidOperationException: The SAS URL for the cloud storage account is not specified. Use the environment variable 'DIAGNOSTICS_AZUREBLOBCONTAINERSASURL' to define it.at Microsoft.WindowsAzure.WebSites.Diagnostics.AzureBlobTraceLi‌​stener.RefreshConfig‌​()

然后我将DIAGNOSTICS_AZUREBLOBCONTAINERSASURL添加到应用程序设置中,其值设置为 生成的Blob服务SAS URL.在此我得到一个新的错误:

I then added DIAGNOSTICS_AZUREBLOBCONTAINERSASURL to the application settings having its value set to the Blob service SAS URL generated. At this I get a new error:

System.ApplicationException:跟踪侦听器AzureBlobTraceListener 被禁用. ---> System.ArgumentException:缺少必需 有效共享访问签名的参数位于 Microsoft.WindowsAzure.Storage.Core.Auth.SharedAccessSignatureHelper.ParseQuery(IDictionary 2 queryParameters, Boolean mandatorySignedResource) at Microsoft.WindowsAzure.Storage.Core.Util.NavigationHelper.ParseBlobQueryAndVerify(Uri address, StorageCredentials& parsedCredentials, Nullable 1& parsedSnapshot) Microsoft.WindowsAzure.Storage.Core.Util.NavigationHelper.ParseBlobQueryAndVerify(StorageUri 地址,StorageCredentials& parsedCredentials,为Nullable`1& parsedSnapshot) Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.ParseQueryAndVerify(StorageUri 地址,StorageCredentials凭据) Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer..ctor(StorageUri containerAddress,StorageCredentials凭证)位于 Microsoft.WindowsAzure.WebSites.Diagnostics.AzureBlobTraceListener.RefreshConfig()

System.ApplicationException: The trace listener AzureBlobTraceListener is disabled. ---> System.ArgumentException: Missing mandatory parameters for valid Shared Access Signature at Microsoft.WindowsAzure.Storage.Core.Auth.SharedAccessSignatureHelper.ParseQuery(IDictionary2 queryParameters, Boolean mandatorySignedResource) at Microsoft.WindowsAzure.Storage.Core.Util.NavigationHelper.ParseBlobQueryAndVerify(Uri address, StorageCredentials& parsedCredentials, Nullable1& parsedSnapshot) at Microsoft.WindowsAzure.Storage.Core.Util.NavigationHelper.ParseBlobQueryAndVerify(StorageUri address, StorageCredentials& parsedCredentials, Nullable`1& parsedSnapshot) at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer.ParseQueryAndVerify(StorageUri address, StorageCredentials credentials) at Microsoft.WindowsAzure.Storage.Blob.CloudBlobContainer..ctor(StorageUri containerAddress, StorageCredentials credentials) at Microsoft.WindowsAzure.WebSites.Diagnostics.AzureBlobTraceListener.RefreshConfig()

然后我将sr=b添加到'DIAGNOSTICS_AZUREBLOBCONTAINERSASURL',这导致以下错误:

I then added sr=b to the 'DIAGNOSTICS_AZUREBLOBCONTAINERSASURL' which result in the below error:

Microsoft.WindowsAzure.Storage.StorageException:远程服务器 返回错误:(403)禁止. ---> System.Net.WebException: 远程服务器返回错误:(403)禁止.在 System.Net.HttpWebRequest.GetResponse()在 Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync [T](RESTCommand 1 cmd, IRetryPolicy policy, OperationContext operationContext) --- End of inner exception stack trace --- at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand 1 cmd,IRetryPolicy策略,OperationContext operationContext)位于 Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.DownloadBlockList(BlockListingFilter blockListingFilter,AccessCondition,accessCondition, BlobRequestOptions选项,OperationContext operationContext)位于 Microsoft.WindowsAzure.WebSites.Diagnostics.AzureBlobTraceListener.AppendStreamToBlob(Stream 流) Microsoft.WindowsAzure.WebSites.Diagnostics.AzureBlobTraceListener.ConsumeBuffer() 请求信息RequestID:5225782d-0001-0175-6d94-fc82dd000000 RequestDate:Fri,14 Jul 2017 11:33:16 GMT StatusMessage:服务器失败 验证请求.确保授权值 标头格式正确,包括签名. ErrorCode:AuthenticationFailed

Microsoft.WindowsAzure.Storage.StorageException: The remote server returned an error: (403) Forbidden. ---> System.Net.WebException: The remote server returned an error: (403) Forbidden. at System.Net.HttpWebRequest.GetResponse() at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand1 cmd, IRetryPolicy policy, OperationContext operationContext) --- End of inner exception stack trace --- at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.ExecuteSync[T](RESTCommand1 cmd, IRetryPolicy policy, OperationContext operationContext) at Microsoft.WindowsAzure.Storage.Blob.CloudBlockBlob.DownloadBlockList(BlockListingFilter blockListingFilter, AccessCondition accessCondition, BlobRequestOptions options, OperationContext operationContext) at Microsoft.WindowsAzure.WebSites.Diagnostics.AzureBlobTraceListener.AppendStreamToBlob(Stream stream) at Microsoft.WindowsAzure.WebSites.Diagnostics.AzureBlobTraceListener.ConsumeBuffer() Request Information RequestID:5225782d-0001-0175-6d94-fc82dd000000 RequestDate:Fri, 14 Jul 2017 11:33:16 GMT StatusMessage:Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature. ErrorCode:AuthenticationFailed

用于在应用程序设置中声明AzureWebJobsDashboard和AzureWebJobsStorage的连接字符串: 在此处输入图片描述

Connection string used to declare AzureWebJobsDashboard and AzureWebJobsStorage in app settings: enter image description here

推荐答案

根据您的描述,我想您遇到该错误的原因是您的SAS令牌没有足够的权限来对blob进行CRUD.

According to your description, I guess the reason why you faced the error is your SAS token doesn't have enough permission to CRUD the blob.

SAS令牌必须是Blob容器SAS令牌,而不是Blob SAS令牌.

The SAS token must be the blob container SAS token not the blob SAS token.

此外,如果您设置了Azure Web应用程序的诊断日志应用程序日志记录"功能,它将在您的Web应用程序的应用程序设置中自动生成SAS令牌.

Besides, if you set the the azure web app's diagnostics logs Application Logging feature, it will auto generate a SAS token in your web app's appsetting.

更多细节,您可以参考下图:

More details, you could refer to below image:

在诊断日志中设置存储帐户.

Set the storage account in the diagnostics logs.

然后它将自动设置应用设置:

Then it will auto set the appsetting:

更新:

无法验证Microsoft Azure WebJobs SDK仪表板连接字符串. Microsoft Azure存储帐户连接字符串的格式不正确.

Failed to validate Microsoft Azure WebJobs SDK Dashboard connection string. The Microsoft Azure Storage account connection string is not formatted correctly.

如果将Web作业上载到Web应用程序,则Web作业需要两个appsetting.一个是仪表板连接字符串,另一个是AzureWebJobsStorage.

If you upload a webjobs to your web app, the web jobs need two appsetting. One is the Dashboard connection string, another one is the AzureWebJobsStorage.

这两个设置都需要存储连接字符串而不是存储SAS.

Both of these two setting need the storage connection string not the storage SAS.

您可以找到存储连接字符串,如下图所示:

You could find the storage connection string as below image shows:

1.打开存储访问密钥功能.

1.Open the storage access key feature.

2.复制连接字符串:

2.Copy the connection string:

3.在Web应用程序的appsetting中替换连接字符串.

3.Replace the connection string in the web app appsetting.

这篇关于Microsoft.WindowsAzure.Storage.StorageException:远程服务器返回错误:(403)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆