2017-02-15 08:57

Azure mongodb服务'10'堆栈附近的语法不正确


I'm using azure mongo service as database

Connection was established using connect string provided in the portal, basic write operations are running perfectly but when trying to perform signing in I'm getting the following error. Syntax error, incorrect syntax near '10'

We are using php version 5.6 and Mongo Client library for mongo operation

The application is currently successfully running in mongo server setup in instance itself we are trying to migrate the db to azure service. Why is this error occuring ?

Mongo request causing error


  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享
  • 邀请回答


  • doujiabing1228 doujiabing1228 4年前

    Azure mongo service as database is currently in preview. I had a similar case with an other request and the Azure support told me that all requests are not supported yet. That's why you can have some requests that perfectly work with a "pure" mongoDB instance.

    In my case for example I discovered that the $elemMatch doesn't work.

        "_id": "1"
        "devices": {
            "$elemMatch": {
                 "device_id": "device_id"

    The support answered me this following response :

    Unfortunately we dont have a way to project specific elements from the array right now. We are working towards supporting $elemMatch in the project phase as well and it should be available by mid-March.

    You have to understand that mongo as service on Azure is a kind of wrapper to allow to use the mongoDB protocols to interact with their NoSQL technology : DocumentDB, moreover like I said in the beginning of my answer this feature is still in preview. That's also why for example you can't use Mongo Compass on Azure mongo service :

    As DocumentDB is a fully managed service, we do not support machine management/administration operations (like addShard/ query perfCounters/ query Memory&Connections) via the MongoDB api. From our investigation, MongoCompass relies on these commands for its normal flow and does not work if any of these commands fail (even if the normal crud api succeeds). I would recommend using RoboMongo which is an opensource tool to interact with the mongo apis

    So, if you want to keep the advantage to have a fully managed service which works with mongoDB api, you have to wait until the production version (Mid-march according to the support) or find an other way to execute this query.

    点赞 评论 复制链接分享