az CLIaz group create --name TodoRG --location germanywestcentral
az storage account create \
--name todostorage1234 \
--resource-group TodoRG \
--sku Standard_LRS \
--kind StorageV2
az storage account show-connection-string \
--name todostorage1234 \
--resource-group TodoRG \
--query connectionString --output tsvAzureTables.Core/ ← TodoItem, ITodoRepository
AzureTables.Infrastructure/ ← AzureTableTodoRepository
AzureTables/ ← Console App (Program.cs)
AzureTables.Tests/ ← xUnit (kein Azure nötig)
internal class TodoEntity : ITableEntity
{
public string PartitionKey { get; set; } = "todos";
public string RowKey { get; set; } = string.Empty;
public DateTimeOffset? Timestamp { get; set; }
public ETag ETag { get; set; }
public string Title { get; set; } = string.Empty;
public bool Done { get; set; }
}internal — nur innerhalb der Infrastructure sichtbar.RowKey entspricht der Id des TodoItem.public class AzureTableTodoRepository : ITodoRepository
{
private readonly TableClient _client;
public AzureTableTodoRepository(string connectionString, string tableName = "todos")
{
_client = new TableClient(connectionString, tableName);
_client.CreateIfNotExists();
}
public async Task<List<TodoItem>> GetAllAsync()
{
var result = new List<TodoItem>();
await foreach (var entity in _client.QueryAsync<TodoEntity>())
result.Add(new TodoItem { Id = entity.RowKey, Title = entity.Title, Done = entity.Done });
return result;
}
}Azure Table Storage – Todo Demo
================================
Drei Einträge gespeichert.
Alle Todos (3):
[ ] Azure CLI einrichten
[ ] Table Storage ausprobieren
[ ] Eintrag löschen üben
Finaler Zustand (2):
[x] Azure CLI einrichten
[ ] Table Storage ausprobieren
Alle Einträge bereinigt.
ITodoRepository in Core, AzureTableTodoRepository in InfrastructureTodoEntity internal: Mapping zwischen Cloud-SDK und Domain-Modell explizit