Skip to content

Commit 1b2714f

Browse files
committed
Use a separate Task to init table
This might fix the issue we're facing (somewhat randomly) in Azure Functions. Fixes #58 (hopefully)
1 parent a56d489 commit 1b2714f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/TableStorage/DocumentRepository`1.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,13 @@ async Task<T> PutStringAsync(T entity, CancellationToken cancellation = default)
275275

276276
#endregion
277277

278-
async Task<CloudTable> GetTableAsync(string tableName)
278+
Task<CloudTable> GetTableAsync(string tableName) => Task.Run(async () =>
279279
{
280280
var tableClient = storageAccount.CreateCloudTableClient();
281281
var table = tableClient.GetTableReference(tableName);
282282
await table.CreateIfNotExistsAsync();
283283
return table;
284-
}
284+
});
285285

286286
class BinaryDocumentEntity : TableEntity, IDocumentEntity
287287
{

src/TableStorage/TableEntityRepository.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,12 @@ public async Task<ITableEntity> PutAsync(ITableEntity entity, CancellationToken
110110
return (ITableEntity)result.Result;
111111
}
112112

113-
async Task<CloudTable> GetTableAsync(string tableName)
113+
Task<CloudTable> GetTableAsync(string tableName) => Task.Run(async () =>
114114
{
115115
var tableClient = storageAccount.CreateCloudTableClient();
116116
var table = tableClient.GetTableReference(tableName);
117117
await table.CreateIfNotExistsAsync();
118118
return table;
119-
}
119+
});
120120
}
121121
}

src/TableStorage/TableRepository`1.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ public async Task<T> PutAsync(T entity, CancellationToken cancellation = default
164164
return ToEntity((DynamicTableEntity)result.Result);
165165
}
166166

167-
async Task<CloudTable> GetTableAsync(string tableName)
167+
Task<CloudTable> GetTableAsync(string tableName) => Task.Run(async () =>
168168
{
169169
var tableClient = storageAccount.CreateCloudTableClient();
170170
var table = tableClient.GetTableReference(tableName);
171171
await table.CreateIfNotExistsAsync();
172172
return table;
173-
}
173+
});
174174

175175
/// <summary>
176176
/// Uses JSON deserialization to convert from the persisted entity data

0 commit comments

Comments
 (0)