I've created an Azure Cosmos DB (selecting MongoDB as the language), and while creating a new document through the Azure portal (website) it fails and says:
{"code":400,"body":"Command insert failed: document does not contain shard key."}
I tried to create the following document through the website:
{
"wordpress_id": "test"
}
And this:
{
"id" : "replace_with_new_document_id",
"wordpress_id": "test"
}
"wordpress_id" is a "Shard key" (or partition key) that I defined when I created the collection. It is also a Unique key.
This is what I see in the "Scale & Settings" tab.
This is the error I see when I try to create the document.
Am I missing something?
Do you know why this is happening?
Am I missing something? Do you know why this is happening?
I also could reproduce this issue if I created a shared collection from Azure portal.
According to the azure official document, we could know that we could create the shared collection with favorite tool,driver, or SDK.
With the MongoDB API, you can create a sharded collection through your favorite tool, driver, or SDK.
I do a demo with studio3t tool. The Mongo Shell I used
db.runCommand( { shardCollection: "databaseName.collectionName", key: { KeyName: "hashed" } } )
Run the Mongo Shell from the studio3t
After that we could create the document from Azure portal correctly.
Related
i’ve done all actions by this guide https://www.prisma.io/docs/getting-started/setup-prisma/start-from-scratch/mongodb-typescript-mongodb
Now Im trying to add some information to database and get an error massage
Storage engine does not support read concern: { readConcern: { level: \"majority\", provenance: \"clientSupplied\" } })
my version of mongodb 4.4.15
we have a replicaset and enableMajorityReadConcern: false setting
How can i solve this problem with create method ?
Im expecting successful create operation
I'm building a multitenant application and I'm using Keycloak for authentication and authorization.
Foreach each tenant, the idea is to have a dedicated Keycloak realm. Each tenant will have exactly the same roles and clients.
I have tried to export one existing realm, use it as template and import it for new tenant. Problem: I'm facing database constraint violation due to internal id.
Question: Is there an elegant way to achieve this, having a template to create a new realm ?
Be sure that the feature for uploading script is enabled. For a deployment with a docker-compose just add this:
command: -Dkeycloak.profile.feature.upload_scripts=enabled
Export your realm (the one to be used as model)
Remove all line containing "id:" and "_id:"
Search and replace template realm name by the new realm name
In Keycloak UI admin console, Add new realm, provide the file and that is all.
You can use the cleaned exported file as template.
Can't comment due to rep,
but I'd like to add to #Youssouf Maiga's answer,
that you should also modify any fields that contain values under "authenticationFlowBindingOverrides":
Replace any entries that have values assigned under "direct_grant" or "browser"
i.e
"authenticationFlowBindingOverrides": {
"direct_grant": "f5d1wb45e-27eb-4466-937439-9cc8a615ad65e",
"browser": "5b23141a1c-7af8d-410e-a9b451f-0eec12039c72e9"
},
replaced with
"authenticationFlowBindingOverrides": {},
I tried cloning my realm based on this and got an error saying:
"Unable to resolve auth flow binding override for: direct_grant" when importing the modified realm export.
Keycloak version 16.1.1
What you could do is configure everything using the Keycloak Terraform provider. That way you only have to define the configuration once, in code, and then apply it using Terraform. See for the documentation: https://registry.terraform.io/providers/mrparkers/keycloak/latest/docs
An advantage of this is that you can put your code in an SCM tool (e.g. git), so you can track your changes, and go back to a previous version if necessary.
unable to fetch single access key value from array,
i followed this reference https://stackoverflow.com/a/50407157/11191182
"storageAccountAccessKey": "[listKeys(resourceId('Microsoft.Storage/storageAccounts', parameters('StorageAccountName')), '2017-10-01').key]",
Error
The
language expression property 'key1' doesn't exist, available properties are 'keys'.'",
.key1 is an old version of the function listKeys. The syntax now is .keys[0].value.
"StorageAccount": "[Concat('DefaultEndpointsProtocol=https;AccountName=',variables('StorageAccountName'),';AccountKey=',listKeys(resourceId('Microsoft.Storage/storageAccounts', variables('StorageAccountName')), providers('Microsoft.Storage', 'storageAccounts').apiVersions[0]).keys[0].value)]"
Update:
For .key1 syntax you can try using the older version api (2015-05-01-preview). Please refer to below example:
"accessKey": "[listKeys(variables('storageAccountid'),'2015-05-01-preview').key1]"
For more information please refer to blog Retrieve Azure Storage Key in ARM Script
I'm trying to create a hash index in ArangoDB via its HTTP API via CURL.
Within my ArangoDB I have several databases like:
production
staging
test
As mentioned in the docs in https://docs.arangodb.com/3.4/HTTP/Indexes/Hash.html one should call the "Index API" with an URL scheme as follows:
http://localhost:8529/_api/index?collection=products
Applied to my use case I have the following URL:
http://localhost:8529/_api/index?colletion=NodesElectric
Executing the CURL command always returns with an error like:
{
"error": true,
"errorMessage": "collection or view not found",
"code": 404,
"errorNum": 1203
}
I suppose that the problem is caused by having the collection "NodesElectric" in all databases "production", "staging",...
My question is how do I specify the according database for the mentioned collection?
Have not found an hint in the docs herein.
Thanks for any help!
Any operation triggered via ArangoDB's HTTP REST API is executed in the context
of exactly one database. To explicitly specify the database in a
request, the request URI must contain the database name in front of
the actual path:
http://localhost:8529/_db/mydb/... where ... is the actual path to the
accessed resource. In the example, the resource will be accessed in
the context of the database mydb. Actual URLs in the context of mydb
could look like this:
http://localhost:8529/_db/mydb/_api/version
This information can be found in the documentation:
https://docs.arangodb.com/3.4/HTTP/Database/
If no database is specified in the request URL, the _system database is used by default.
To create a hash index on collection NodesElectric in your database production the following URL has to be used:
http://localhost:8529/_db/production/_api/index?collection=NodesElectric
I have setup a Azure Function with a Azure Cosmos DB(document) output. The cosmos database is configured to be a MongoDB.
And added the following simple code to try and add a new document:
module.exports = function (context, eventHubMessages) {
context.bindings.document = {
text : "Test data"
}
context.done();
};
When i test run i get success, but when i try to open the the collection using Studio 3T i get:
Query failed with error code 1 and error message 'Unknown server error occurred when processing this request.'
When i use the same code to write to a DocumentDB i get success and i can view data in Azure. Do you need to use a different API to save data to mongoDB?
The DocumentDB output binding is using the DocumentDB API to connect and save information in the database. But your database (from what you are saying) is using the MongoDB API, they are different APIs (links point to the docs).
As you surely know, MongoDB has some requirements (like the existence of an "_id" attribute) that are covered when you connect to the database from a MongoDB client (either an SDK or a third-party client), but since you are communicating through the DocumentDB API, it's probably failing to fulfill those requirements.
You might want to try and use the Mongo driver in the function to connect to your Cosmos DB database through the MongoDB API.