Sunday 20 September 2020

DocumentDB Data Migration Tool Error: The remote server returned an error: (400) Bad Request

 Hey everyone, welcome back to SQL SOMETHING!!!

Today, we are taking a look at migrating Azure Cosmos DB data to a JSON file that will be stored in Azure Blob Storage. This will be using the Microsoft DocumentDB Data Migration Tool. Our focus is also more on the following error that  may occur when trying to write to an Azure Blob Storage Account:


The remote server returned an error: (400) Bad Request

 


Let's take a look at the solution.


Export the Cosmos collection to a JSON file in Azure Blob Storage

To this end we will use a tool provided by Microsoft: the DocumentDB Data Migration Tool.

This tool allows us to import and export data to/from a Cosmos collection (aka a DocumentDB collection). We will be focusing on exporting the data to a JSON file.

Documentation on using the tool can be found in great detail here (big thanks to SQL Roadie for this). 

We will be doing something different, however. Unlike in the link above, we will not be exporting to a local JSON file, but we will be exporting to Azure Blob Storage.

It is here you may run into the error:

The remote server returned an error: (400) Bad Request



Now this error is a liar. Or at the very least it can be... misleading.

It seems to indicate that maybe it’s a network issue or a permissions issue. Which I suppose it's maybe kinda the former?

Well regardless, no amount of super privileges were getting me past this point.

HOWEVER.

If you scroll all the way to the bottom of the error message (which I did not do for an ENTIRE day), you might see something else:

The TLS version of the connection is not permitted...



Here is the culprit. When I created the storage account, I used the recommended latest and greatest settings i.e. I used TLS 1.2. This tool however is only compatible with lower versions of TLS so I went into Storage Account configuration settings and temporarily bumped the TLS down to 1.0.


 



I was then able to (finally) export the data. 😊


DISCLAIMER: As stated, I’m not an expert so please, PLEASE feel free to politely correct or comment as you see fit. Your feedback is always welcomed. :-)

 

No comments:

Post a Comment