Azure Cosmos DB for NoSQL データベースがあり、その中に Container1 という名前のコンテナが存在します。 あなたは、Container1を使用するApp1という名前の新しいアプリを開発しています。 App1がContainer1内のドキュメントを削除しようとした際に、その操作がブロックされ、アプリにエラーが返されるようにする必要があります。 何を使うべきでしょうか?
正解:D
To block an application from deleting a document in an Azure Cosmos DB for NoSQL container while ensuring the application receives an error message, you should use a pre-trigger. Why use a Pre-trigger? Blocking Action: Pre-triggers run before a database operation (like a delete) is completed. If the trigger throws an exception, the entire transaction is aborted, effectively blocking the deletion. Error Reporting: When a pre-trigger throws an error, the Cosmos DB service returns that error back to the calling application, typically as a 400 Bad Request or similar exception depending on the SDK used. Granular Control: Unlike general Role-Based Access Control (RBAC) which might just deny the operation with a generic "Forbidden" message, a pre-trigger allows you to write custom JavaScript logic to validate the delete request and provide a specific error reason. Reference: https://learn.microsoft.com/en-us/azure/cosmos-db/how-to-write-stored-procedures-triggers-udfs