Azure Blob Storage Upload Error: (403) Forbidden

2019-07-27 13:53发布

问题:

We have created a new process to upload files to our Azure blob. When running the app locally, the files upload fine and without error. When we run the same process on our server, we get the error message:

MESSAGE: Forbidden: header 'Content-Type' value denied SOURCE: Microsoft.WindowsAzure.StorageClient TARGETSITE: T get_Result() STACKTRACE: at Microsoft.WindowsAzure.StorageClient.Tasks.Task1.get_Result() at Microsoft.WindowsAzure.StorageClient.Tasks.Task1.ExecuteAndWait() at Microsoft.WindowsAzure.StorageClient.TaskImplHelper.ExecuteImpl(Func`1 impl) at Microsoft.WindowsAzure.StorageClient.CloudBlob.UploadFromStream(Stream source, BlobRequestOptions options) at Microsoft.WindowsAzure.StorageClient.CloudBlob.UploadFromStream(Stream source)

Inner Exception:

MESSAGE: The remote server returned an error: (403) Forbidden.

SOURCE: System

TARGETSITE: System.Net.WebResponse EndGetResponse(System.IAsyncResult)

STACKTRACE: at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)

at Microsoft.WindowsAzure.StorageClient.EventHelper.ProcessWebResponse(WebRequest req, IAsyncResult asyncResult, EventHandler`1 handler, Object sender)

What is odd is that the file uploads still to Azure. Has anyone experienced this? We don't set a content type when we upload the file, as we set it when the file is downloaded. We tried hardcoding one in, and it still produced the same error.

回答1:

It turned out to be a Firefox issue. We had to modify the proxy to allow no content type to come back to us from Azure. It seems that the files were being uploaded, but Azure wanted to respond to our call to it, and our firewall was blocking the response. Ideally, Azure would fix the issue by including a content type in their response, so we don't need to make firewall changes such as this.