portal entry

select a category, or use search below
(searches all categories and all time range)

Connect coldfusion application with Azure cosmos db

| View in Portal
June 23, 2019 07:23:10 AM GMT
1 Comment
<p>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.</p>
<p>The post <a rel="nofollow" href="https://coldfusion.adobe.com/2019/06/connect-coldfusion-application-azure-cosmos-db/">Connect coldfusion application with Azure cosmos db</a> appeared first on <a rel="nofollow" href="https://coldfusion.adobe.com">ColdFusion</a>.</p>
Labels: Data Source, JDBC Connection, Question, ColdFusion, data source, jdbc connection, question


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: <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/create-sql-api-java" rel="nofollow">https://docs.microsoft.com/en-us/azure/cosmos-db/create-sql-api-java</a>. And there's a walkthroughs using it (<a href="https://docs.microsoft.com/en-us/azure/sql-database/sql-database-connect-query-java" rel="nofollow">https://docs.microsoft.com/en-us/azure/sql-database/sql-database-connect-query-java</a> and <a href="https://docs.microsoft.com/en-us/azure/cosmos-db/create-sql-api-java" rel="nofollow">https://docs.microsoft.com/en-us/azure/cosmos-db/create-sql-api-java</a>), 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 <a href="https://www.cdata.com/drivers/cosmosdb/jdbc/," rel="nofollow">https://www.cdata.com/drivers/cosmosdb/jdbc/,</a> 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: <a href="https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/17788768-jdbc-support" rel="nofollow">https://feedback.azure.com/forums/263030-azure-cosmos-db/suggestions/17788768-jdbc-support</a>. Finally, as for calling it via REST, that's documented here: <a href="https://docs.microsoft.com/en-us/rest/api/cosmos-db/" rel="nofollow">https://docs.microsoft.com/en-us/rest/api/cosmos-db/</a>.  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.
Comment by Charlie Arehart
2135 | June 25, 2019 03:18:18 AM GMT