You have a database in an Azure Cosmos DB Core (SQL) API account. You need to create an Azure function that will access the database to retrieve records based on a variable named accountnumber. The solution must protect against SQL injection attacks. How should you define the command statement in the function?
Correct Answer: C
Azure Cosmos DB supports queries with parameters expressed by the familiar @ notation. Parameterized SQL provides robust handling and escaping of user input, and prevents accidental exposure of data through SQL injection. For example, you can write a query that takes lastName and address.state as parameters, and execute it for various values of lastName and address.state based on user input. SELECT * FROM Families f WHERE f.lastName = @lastName AND f.address.state = @addressState
Question 17
You need to configure an Apache Kafka instance to ingest data from an Azure Cosmos DB Core (SQL) API account. The data from a container named telemetry must be added to a Kafka topic named iot. The solution must store the data in a compact binary format. Which three configuration items should you include in the solution? Each correct answer presents part of the solution. NOTE: Each correct selection is worth one point.
Correct Answer: C,D,F
C: Avro is binary format, while JSON is text. F: Kafka Connect for Azure Cosmos DB is a connector to read from and write data to Azure Cosmos DB. The Azure Cosmos DB sink connector allows you to export data from Apache Kafka topics to an Azure Cosmos DB database. The connector polls data from Kafka to write to containers in the database based on the topics subscription. D: Create the Azure Cosmos DB sink connector in Kafka Connect. The following JSON body defines config for the sink connector. Extract: "connector.class": "com.azure.cosmos.kafka.connect.sink.CosmosDBSinkConnector", "key.converter": "org.apache.kafka.connect.json.AvroConverter" "connect.cosmos.containers.topicmap": "hotels#kafka" Incorrect Answers: B: JSON is plain text. Note, full example: { "name": "cosmosdb-sink-connector", "config": { "connector.class": "com.azure.cosmos.kafka.connect.sink.CosmosDBSinkConnector", "tasks.max": "1", "topics": [ "hotels" ], "value.converter": "org.apache.kafka.connect.json.AvroConverter", "value.converter.schemas.enable": "false", "key.converter": "org.apache.kafka.connect.json.AvroConverter", "key.converter.schemas.enable": "false", "connect.cosmos.connection.endpoint": "Error! Hyperlink reference not valid.", "connect.cosmos.master.key": "<cosmosdbprimarykey>", "connect.cosmos.databasename": "kafkaconnect", "connect.cosmos.containers.topicmap": "hotels#kafka" } } Reference: https://docs.microsoft.com/en-us/azure/cosmos-db/sql/kafka-connector-sink https://www.confluent.io/blog/kafka-connect-deep-dive-converters-serialization-explained/