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.
db.users_collections.find({
"_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.