I have a function that takes CSV files and uploads them to my azure blob using a memory stream, UploadFileToBlob(). The only parameters it takes are a byte[] array for the file and a string for the file name.
I have two files I am using this function to upload. One (inventory) works just fine. The other file (sales) gives the 400 bad request error "The TLS version of the connection is not permitted on this storage account."
This doesn't make sense to me, as the function works just fine for one file and not the other. I'm not sure what to check. I confirmed that the file and and blob name have no invalid characters. I tried changing some TLS settings on my machine but nothing made a difference.
What makes it weirder is that once in a while it works. Usually if I do the inventory file first the sales one will also work. But if I start with the sales one it won't work.
How do I investigate and resolve this?
CodePudding user response:
Try adding this before upload - System.Net.ServicePointManager.SecurityProtocol = System.Net.SecurityProtocolType.Tls12 | System.Net.SecurityProtocolType.Tls | System.Net.SecurityProtocolType.Tls11;
This line will ensure the latest security protocol for consuming the web service call.