exam questions

Exam AZ-204 All Questions

View all questions & answers for the AZ-204 exam

Exam AZ-204 topic 3 question 22 discussion

Actual exam question from Microsoft's AZ-204
Question #: 22
Topic #: 3
[All AZ-204 Questions]

HOTSPOT -
A company develops a series of mobile games. All games use a single leaderboard service.
You have the following requirements:
✑ Code must be scalable and allow for growth.
✑ Each record must consist of a playerId, gameId, score, and time played.
✑ When users reach a new high score, the system will save the new score using the SaveScore function below.
Each game is assigned an Id based on the series title.

You plan to store customer information in Azure Cosmos DB. The following data already exists in the database:

You develop the following code to save scores in the data store. (Line numbers are included for reference only.)

You develop the following code to query the database. (Line numbers are included for reference only.)

For each of the following statements, select Yes if the statement is true. Otherwise, select No.
NOTE: Each correct selection is worth one point.
Hot Area:

Show Suggested Answer Hide Answer
Suggested Answer:
Box 1: Yes -
Create a table.
A CloudTableClient object lets you get reference objects for tables and entities. The following code creates a CloudTableClient object and uses it to create a new
CloudTable object, which represents a table
// Retrieve storage account from connection-string.
CloudStorageAccount storageAccount =
CloudStorageAccount.parse(storageConnectionString);
// Create the table client.
CloudTableClient tableClient = storageAccount.createCloudTableClient();
// Create the table if it doesn't exist.
String tableName = "people";
CloudTable cloudTable = tableClient.getTableReference(tableName); cloudTable.createIfNotExists();

Box 2: No -
New records are inserted with TableOperation.insert. Old records are not updated.
To update old records TableOperation.insertOrReplace should be used instead.

Box 3: No -

Box 4: Yes -
Reference:
https://docs.microsoft.com/en-us/azure/cosmos-db/table-storage-how-to-use-java

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
yukkki
Highly Voted 1 year, 10 months ago
given answer is correct.
upvoted 16 times
[Removed]
1 year, 3 months ago
Incorrect. First one is "No"
upvoted 4 times
...
Esward
1 year, 9 months ago
yes, you are correct! given answers are correct
upvoted 3 times
...
...
OPT_001122
Highly Voted 2 years ago
the given answer seems correct
upvoted 8 times
...
vizay
Most Recent 1 week, 2 days ago
Think of CloudStorageAccount as a key that can open the simpler "Azure Storage Account" toolbox and also the "table-mimicking" machine inside the more powerful "Azure Cosmos DB" workshop. However, it won't work on the other machines in the "Azure Cosmos DB" workshop (the ones for SQL, MongoDB, etc.). Those need their own special keys and instructions (different SDKs).
upvoted 1 times
...
Woksi
9 months ago
Is the implementation of the PlayerScore viewable in the exam? Wouldn't questions about partition/row key would be settled there?
upvoted 2 times
...
raymond_abcd
9 months, 3 weeks ago
See: https://learn.microsoft.com/en-us/dotnet/api/overview/azure/data.tables-readme?view=azure-dotnet
upvoted 3 times
...
raymond_abcd
9 months, 3 weeks ago
CloudStorageClient is deprecated for CosmosDb it is now changed to TableServiceClient and then you have TableClient to store the data. So probably this question wil be different in the upcoming exam
upvoted 3 times
...
Azr0112
1 year, 1 month ago
Yes, SaveScore will work with CosmosDb. This is an example of Azure Cosmos DB for Table. https://learn.microsoft.com/en-us/azure/cosmos-db/table/quickstart-dotnet?tabs=azure-cli%2Cwindows
upvoted 1 times
...
[Removed]
1 year, 3 months ago
No, No, No, Yes
upvoted 3 times
...
[Removed]
1 year, 10 months ago
Inserting will fail, this would require InsertOrReplace to work
upvoted 3 times
...
bbq598
1 year, 10 months ago
For box 2 there will be an exception if the same partition key and row key already exist.
upvoted 2 times
warchoon
1 year, 8 months ago
So you need to answer box 3 first ;)
upvoted 1 times
...
...
Yumi21
1 year, 11 months ago
It seems that in the code no partition key for scoreTable is specified, which means that here we are using a single-partition collection. I would say in this case 3rd option is No, so no automatical partitioning will happen.
upvoted 2 times
...
TheExamMaster2020
2 years ago
Y,N,Y,Y
upvoted 1 times
...
coffecold
2 years, 1 month ago
What code should be there if doing automatic partitioning (C) remains a total secret to me. Should be somewhere on the table level...
upvoted 4 times
...
DivyaRajkumar
2 years, 1 month ago
The given answer looks right to me, https://docs.microsoft.com/en-us/dotnet/api/microsoft.azure.cosmos.table?view=azure-dotnet
upvoted 2 times
...
azurepaul
2 years, 2 months ago
CloudTableClient is for Table storage - CosmosClient is for Cosmos DB I don't think it will work with Cosmos
upvoted 6 times
PrepX
1 year, 4 months ago
A = No SaveScore() method uses a storage account connectionString: CloudStorageAccount storageAccount = CloudStorageAccount.Parse(connectionString); and uses storageAccount to create CloudTableClient. This is not a CosmosDB connection string, CosmosDB requires a Uri + credential (not given in given code!) So given code wil not work 100% to connect to CosmosDB even though it uses a compatible API.
upvoted 3 times
...
Enigma___
2 years, 1 month ago
Please do a simple bing search and you'll see it is Cosmos Db https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.cosmos.table.cloudtableclient?view=azure-dotnet
upvoted 1 times
...
ArturKon
2 years, 1 month ago
Cosmos DB offers Table API, you can use CosmosClient to connect to this.
upvoted 2 times
...
ArturKon
2 years, 1 month ago
https://learn.microsoft.com/en-us/dotnet/api/microsoft.azure.cosmos.table.cloudtableclient?view=azure-dotnet
upvoted 1 times
...
...
finnishr
2 years, 2 months ago
Correct 100%!
upvoted 2 times
...
BogdanG
2 years, 6 months ago
Answer is Correct.
upvoted 3 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago