0
0
Azurecloud~10 mins

Table storage basics in Azure - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new Azure Table client.

Azure
from azure.data.tables import TableServiceClient

connection_string = "DefaultEndpointsProtocol=https;AccountName=example;AccountKey=key;EndpointSuffix=core.windows.net"
service = TableServiceClient.from_connection_string([1])
Drag options to blanks, or click blank then click option'
Aconnection_string
Btable_name
Caccount_key
Dendpoint_suffix
Attempts:
3 left
💡 Hint
Common Mistakes
Using account key instead of connection string
Using table name instead of connection string
2fill in blank
medium

Complete the code to create a new table named 'Customers'.

Azure
table_client = service.get_table_client(table_name=[1])
table_client.create_table()
Drag options to blanks, or click blank then click option'
A"Customers"
B"Orders"
C"Products"
D"Invoices"
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong table name
Forgetting quotes around the table name
3fill in blank
hard

Fix the error in the code to insert an entity into the table.

Azure
entity = {'PartitionKey': 'USA', 'RowKey': '001', 'Name': 'John Doe'}
table_client.[1](entity=entity)
Drag options to blanks, or click blank then click option'
Adelete_entity
Bupdate_entity
Cinsert_entity
Dget_entity
Attempts:
3 left
💡 Hint
Common Mistakes
Using update_entity instead of insert_entity
Using get_entity which only retrieves data
4fill in blank
hard

Fill both blanks to query entities with PartitionKey 'USA' and RowKey greater than '005'.

Azure
filter_query = "PartitionKey eq '[1]' and RowKey [2] '005'"
entities = table_client.query_entities(filter=filter_query)
Drag options to blanks, or click blank then click option'
AUSA
Bgt
Clt
DCanada
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong PartitionKey value
Using 'lt' instead of 'gt' for RowKey comparison
5fill in blank
hard

Fill all three blanks to update the 'Name' property of an entity with PartitionKey 'USA' and RowKey '001'.

Azure
entity = table_client.get_entity(partition_key=[1], row_key=[2])
entity['Name'] = [3]
table_client.update_entity(entity=entity)
Drag options to blanks, or click blank then click option'
A'USA'
B'001'
C'Jane Smith'
D'Canada'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong keys for get_entity
Forgetting quotes around string values