Connecting springDataMongo app to Cosmos Db instead of MongoDb - mongodb

I have an existing java springboot application that uses springDataMongo api to connect to an underlying Mongodb instance.
I need to use the existing springDataMongo api classes but instead of Mongodb, I need to connect Cosmos Db.
I have looked it up on documentation for azure Cosmos db api for Mongodb but didn't get hold of what I am trying to do.
Can someone let me know if what I am doing is possible and if yes, point me to a relevant documentation for the same.

Yes, it is possible to connect to Azure Cosmos DB MongoDB API using springDataMongo.
What you need to do is copy the Cosmos DB connection string from the Azure portal and then put it into spring.data.mongodb.uri in application.properties file of your spring boot project.
application.properties
#mongodb
spring.data.mongodb.uri=mongodb://[username]:[passowrd]#[cosmosdbName].documents.azure.com:10255/?ssl=true
spring.data.mongodb.database=[dababaseName]
After that done, you can check this guide out: Accessing Data with MongoDB.

Related

How to async between Mongodb and azure search

I'm using Mongodb on azure (not Mongodb Atlas), I installed manually Mongodb on three VMs on Azure, what I'm looking for is, everytime a new record is inserted or updated or delete on Mongodb I want this change to be refletcted on Azure Search, do you have any idea How van I do that ?
There is no built in Azure Search Indexer for Mongo, one option is to migrate your existing Mongo DBs to Azure Cosmos with the Mongo API. See this doc.
Another option is to use the Azure Search push API, for which you need to watch for changes in the Mongo DB, see this and based on those newly added or deleted docs then use the Push API the make changes to the index, see this tutorial using the .NET Azure search sdk https://learn.microsoft.com/en-us/azure/search/tutorial-optimize-indexing-push-api
If you migrate your current MongoDB to Azure Cosmos DB API for MongoDB as suggested in this thread, Azure Cognitive Search has a Cosmos DB Mongo DB indexer in Public Preview and you can opt to have it enabled according to that documentation and give it a try.

Migrate data from azure mongodb to azure search

I'm using Microsodt azure cloud provider in my project,where i have a mongodb installed on a VM on azure and also I have azure cognitive search instance . what I want to do is to migrate the data which i have on mongodb to azure search in order to create indexes and then use the restful apis on the client application.
my question is, is there a way to move data from mongodb to azure search please ?
Unfortunately there is not a built in Mongo DB connector for Azure Search as of now. However you have two options.
Migrate from Mongodb to Azure Cosmos DB (Mongo API) and then create an Azure Search Indexer for the Azure Cosmos DB in question, see https://learn.microsoft.com/en-us/azure/dms/tutorial-mongodb-cosmos-db-online
Write a custom code application that pulls data from Mongo and then send it to Azure Search indexes, you can do this by using the push API, take a look at https://learn.microsoft.com/en-us/azure/search/tutorial-optimize-indexing-push-api

MongoDB Atlas doesn't appear in my Linked Services list in Azure Data Factory 2

I'm trying to create a service link for Atlas mongodb in Microsoft Azure Data Factory v2.
According to this link now we can copy data from MongoDB Atlas using Azure Data Factory 2.
I can find mongodb connection but not the one from Atlas.
I searched my Linked Services list but MongoDB Atlas doesn't appear anywhere.
How can I get this up ?
Does it any thing to have with the region or the cloud servers location?
Any ideas?
Might be a bug, something for Azure to resolve. I got it listed in numerous of regions, US East being one of them. Can you create a new ADF in US East, setup MongoDB Atlas linked service with the necessary connection strings then output the configuration via JSON.
Then try running Az to create the linked service inside the ADF that you need, with properties value set from the previous linked service created - https://learn.microsoft.com/en-us/cli/azure/ext/datafactory/datafactory/linked-service?view=azure-cli-latest#ext_datafactory_az_datafactory_linked_service_create
Then just drop the newly created ADF.
This week I tried again and now it appears in my list.
It seems like the updates was not propagated in our servers.
Thanks

Azure Cosmos DB Mongo - Resource tokens

I am investigating NoSQL Technologies for use in a project and Azure Cosmos Mongo API has arisen as an option. As part of Microsofts recommended architecture there is a Resource broker component middleware which retains ownership of the CosmosDB Master access key, and that can generate/distribute resource tokens for finer-grained access to consuming clients.
The documentation does not seem to allude to the Mongo API anywhere however and I cannot find information anywhere about it, is this pattern not available for the Cosmos Mongo API database? If that is the case, and Cosmos Mongo API requires access simply to a Master key, how would fine-grained access control and least privilege access be able to work?
There is an alternative question on Stackoverflow around creation of resource tokens but I would want to use an ORM such as mongoose in order to connect to CosmosDB with a resource token to avoid having to distribute Master keys out to many services.
Any answers greatly appreciated!
Resource Tokens are not possible with MongoDB API for Cosmos DB because MongoDB clients do not understand what to do with these. If you are looking at using Cosmos DB as a managed NoSQL database I recommend using the Core (SQL) API.
For more information on this see, Resource Tokens. There are also two reference implementations for token brokers, a Xamarin sample app and another built by Citrix.
Hope this is helpful.

Delete a row from mongodb database in azure

I am an azure newbie who has a mongodb database on Azure cloud storage. I am trying to delete a row with a specific value from the Query explorer in Azure, but I keep getting this error. Am I missing something?
delete from users where _id='...' doesnt work
neither does delete * from users where _id='' work
this works perfectly even if am doing SQL on a mongodb database while querying
I think you are using Microsoft DocumentDB (not mongoDB). DocumentDB is available on Azure and supports SQL-like queries.
I suggest taking a look at the documentation: https://azure.microsoft.com/en-us/documentation/articles/documentdb-sql-query/
According to the docs INSERT, UPDATE, and DELETE are only available through the REST API and not in the query language.