June 23, 2019
Connect coldfusion application with Azure cosmos db
Comments
(3)
June 23, 2019
Connect coldfusion application with Azure cosmos db
Newbie 1 posts
Followers: 0 people
(3)

Hi All,

I have one requirement to fetch data from Azure cosmos db. But did not find any way to integrate with coldfusion app. Any help would be appreciated.

3 Comments
2019-10-10 20:28:27
2019-10-10 20:28:27

Cosmos DB is accessed by an API, so it is possible to write a interface for Cosmos DB to make it easier to use it as a data source.

I’ve written a little demo for this: https://github.com/dominicr/CFCosmosDB

Like
2019-10-07 12:40:44
2019-10-07 12:40:44

As Charlie points out, there is an API interface to Cosmos DB. I have a small demo of this https://github.com/dominicr/CFCosmosDB

Like
2019-06-25 03:18:18
2019-06-25 03:18:18

Good news: you can indeed “fetch” data from Cosmos DB from CF.

Bad news: if you mean you want to use SQL, you will find the “easy” option to be expensive. There’s another way to send SQL from CF to Cosmos DB from CF, but you would need to leverage the MS-provided Java SDK. That would not be trivial for most users.

Moderately encouraging news: if you are open to using other means to “fetch” the data, there are other options, such as the option to query it via REST. That’s easily done from CF, using CFHTTP.

Explanation:

First, note that CF queries are generally done by way of a JDBC connection from CF to the DB. Sadly, there is no MS-provided (let alone Adobe-provided) JDBC driver for Cosmos.

There IS a third party company (cdata) who make lots of money filling in such gaps: they DO offer a JDBC driver for Cosmos DB, and you COULD use that with CF (there are docs about how to use easily 3rd party JDBC drivers with CF). But they charge a lot. In fact, the “desktop” price is quoted as near $2000, while the “server” price you have to “get a quote”. That’s always a scary prospect.

So I said there were other ways to “fetch” data from Cosmos using CF. What are they?

Well, first, MS does provide a “Java SDK”, and you could implement that into CF (it has had for intergrating Java libraries since 4.51).  You can learn more about that Java SDK for Cosmos  here: https://docs.microsoft.com/en-us/azure/cosmos-db/create-sql-api-java. And there’s a walkthroughs using it (https://docs.microsoft.com/en-us/azure/sql-database/sql-database-connect-query-java and https://docs.microsoft.com/en-us/azure/cosmos-db/create-sql-api-java), but it would be up to you to figure out how implement such Java API calls into CFML: not hard, but not trivial for those new to the topic.

As for the JDBC driver, which would be easy, the vendor’s site is https://www.cdata.com/drivers/cosmosdb/jdbc/, but again it’ll cost ya. As for any plans for MS to offer one for free perhaps, that was discussed but nothing promised here: https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/17788768-jdbc-support.

Finally, as for calling it via REST, that’s documented here: https://docs.microsoft.com/en-us/rest/api/cosmos-db/.  You would just need  to implement those URLs using CFHTTP (and if needed CFHTTPPARAM).

I leave all that as exercises for your consideration. But this seems for now the most complete answer you’ll find to “how can I connect CF to Cosmos DB”. I’d look to hearing how it may help you, and to the thoughts of anyone else with more insights. I’d then like to put together a blog post pulling this together for those who may not find what I’ve offered here.

Like
(1)
Add Comment