Skip to content

Commit

Permalink
Use CreateContainerIfNotExistsAsync on the Cosmos SDK to be compatibl…
Browse files Browse the repository at this point in the history
…e with RBAC (dotnet#33473)

* Use CreateContainerIfNotExistsAsync on the Cosmos SDK to be compatible with RBAC

Fixes dotnet#33354

* Updates based on review feedback.
  • Loading branch information
ajcvickers authored Apr 5, 2024
1 parent ee68d71 commit 45448ef
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/EFCore.Cosmos/Storage/Internal/CosmosClientWrapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -201,22 +201,17 @@ private static async Task<bool> CreateContainerIfNotExistsOnceAsync(
CancellationToken cancellationToken = default)
{
var (parameters, wrapper) = parametersTuple;
using var response = await wrapper.Client.GetDatabase(wrapper._databaseId).CreateContainerStreamAsync(
var response = await wrapper.Client.GetDatabase(wrapper._databaseId).CreateContainerIfNotExistsAsync(
new Azure.Cosmos.ContainerProperties(parameters.Id, "/" + parameters.PartitionKey)
{
PartitionKeyDefinitionVersion = PartitionKeyDefinitionVersion.V2,
DefaultTimeToLive = parameters.DefaultTimeToLive,
AnalyticalStoreTimeToLiveInSeconds = parameters.AnalyticalStoreTimeToLiveInSeconds
},
parameters.Throughput,
throughput: parameters.Throughput?.Throughput,
cancellationToken: cancellationToken)
.ConfigureAwait(false);
if (response.StatusCode == HttpStatusCode.Conflict)
{
return false;
}

response.EnsureSuccessStatusCode();
return response.StatusCode == HttpStatusCode.Created;
}

Expand Down

0 comments on commit 45448ef

Please sign in to comment.