0
0
Azurecloud~30 mins

Table storage basics in Azure - Mini Project: Build & Apply

Choose your learning style9 modes available
Table storage basics
📖 Scenario: You are working on a simple cloud app that needs to store user information in a table format. Azure Table Storage is a good choice for this because it stores data in tables with rows and columns, like a spreadsheet.Imagine you want to keep track of users with their unique IDs, names, and email addresses.
🎯 Goal: Build a basic Azure Table Storage setup by creating a table, adding user data entries, and configuring the table to be ready for queries.
📋 What You'll Learn
Create a table client connected to a storage account
Define a table named 'Users'
Add user entities with PartitionKey, RowKey, Name, and Email
Set up the table to allow querying user data
💡 Why This Matters
🌍 Real World
Azure Table Storage is used to store large amounts of structured, non-relational data. This project shows how to set up and use it for simple user data storage.
💼 Career
Understanding how to create tables, add entities, and query data in Azure Table Storage is essential for cloud developers and engineers working with Microsoft Azure.
Progress0 / 4 steps
1
Create the Azure Table client and define the table name
Write code to create a TableServiceClient using the connection string "DefaultEndpointsProtocol=https;AccountName=examplestorage;AccountKey=examplekey;EndpointSuffix=core.windows.net". Then create a table_client for the table named "Users".
Azure
Need a hint?

Use TableServiceClient.from_connection_string() with the exact connection string. Then get the table client for the table named "Users".

2
Create the 'Users' table if it does not exist
Add code to create the table named "Users" using the table_client. Use the method create_table() and handle the case where the table might already exist.
Azure
Need a hint?

Use table_client.create_table() inside a try-except block to catch ResourceExistsError.

3
Add user entities to the 'Users' table
Write code to add two user entities to the table_client. Each entity must have PartitionKey, RowKey, Name, and Email. Use table_client.create_entity() to add these entities. Use these exact values:
1. PartitionKey: "User", RowKey: "001", Name: "Alice", Email: "alice@example.com"
2. PartitionKey: "User", RowKey: "002", Name: "Bob", Email: "bob@example.com"
Azure
Need a hint?

Define two dictionaries with the exact keys and values. Use table_client.create_entity() to add each entity.

4
Query the 'Users' table for all user entities
Add code to query all entities from the table_client using list_entities(). Store the result in a variable called users. This will prepare the table for reading user data.
Azure
Need a hint?

Use table_client.list_entities() and assign it to users.