0
votes

Using Microsoft.WindowsAzure.Storage 2.1.0.3

Attemping to write a conosle app to move documents from one Azure Storage account to another account. The app lists all the containers using sourceClient.ListContainers(), loops through all containers in a foreach block getting a Shared Access Token for each, and then fires a StartCopyFromBlob request for each blob. The destination blob has the same naming structure, but is in a different account (e.g. sourceAzureUrl/testContainer/filename.ext -> destAzureUrl/testContainer/filename.ext).

Most of the files (98%) copy just fine, but when certain requests are sent, it returns with this exception: "The remote server returned an error: (403) Forbidden." When the CloudBlockBlob reference to the destination blob is created, the URL does not seem to be properly URL escaped which results in the exception. However, when this code is run inside of an MVC controller, the request is somehow properly URL escaped and the request is completed without error. The copied blob contains the unescaped name as well.

It appears that the reason is the blob/filename contains a "[" and/or "]" character (e.g. Roger_Smith[1].doc). If the the filename is URL encoded beforehand, the request is completed without error, but the filename in Azure Storage is its URL escaped incarnation and not the original filename (Roger_Smith%255b1%255d.doc instead of Roger_Smith[1].doc).

Is there a way to properly URL escape the copy request and still have the result blob have the unescaped name?

1

1 Answers

0
votes

Can you confirm you are running with .net 4.5? There is a uri escaping issue for the characters you mentioned (brackets) that was introduced in .net 4.5 that is incompatible with .net 4.0 (which is what the service is using to validate the response). As such it appears as if the message signature was incorrectly formed. We are working with the .net team on long term resolution for this. In the meantime you may consider running under .net 4.0 (with .net 4.5 installed to take advantage of GC improvements) or avoiding the bracket characters in the file name.