From e0f191cbe56b0f89e2f32c8e2d92e56bf619ac6b Mon Sep 17 00:00:00 2001 From: Egil Hansen Date: Tue, 30 Sep 2025 15:44:10 +0000 Subject: [PATCH] Fix table creation logging to reflect existing tables correctly The `CreateIfNotExistsAsync` method's response will have a 409-statuscode if the table already exists and will always return the `TableItem` if the call is successful. --- src/Azure/Shared/Storage/AzureTableDataManager.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Azure/Shared/Storage/AzureTableDataManager.cs b/src/Azure/Shared/Storage/AzureTableDataManager.cs index f4a92020c14..212ea9abd7e 100644 --- a/src/Azure/Shared/Storage/AzureTableDataManager.cs +++ b/src/Azure/Shared/Storage/AzureTableDataManager.cs @@ -81,10 +81,10 @@ public async Task InitTableAsync() { TableServiceClient tableCreationClient = await GetCloudTableCreationClientAsync(); var table = tableCreationClient.GetTableClient(TableName); - var tableItem = await table.CreateIfNotExistsAsync(); - var didCreate = tableItem is not null; + var response = await table.CreateIfNotExistsAsync(); + var alreadyExisted = response.GetRawResponse().Status == (int)HttpStatusCode.Conflict; - LogInfoTableCreation(Logger, didCreate ? "Created" : "Attached to", TableName); + LogInfoTableCreation(Logger, alreadyExisted ? "Attached to" : "Created", TableName); Table = table; } catch (TimeoutException te)