Skip to content

Commit

Permalink
Support for Default Azure Identity
Browse files Browse the repository at this point in the history
Signed-off-by: Piotr Karpala <[email protected]>
  • Loading branch information
karpikpl committed Jun 11, 2024
1 parent 32ca94b commit a00c272
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Azure.Identity" Version="1.11.4" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.40.0" />
<PackageReference Include="Microsoft.Extensions.Hosting" Version="6.0.1" />
<PackageReference Include="Microsoft.Extensions.Logging" Version="6.0.0" />
Expand Down
5 changes: 5 additions & 0 deletions src/Scaler.Demo/OrderProcessor/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.Net;
using System.Threading;
using System.Threading.Tasks;
using Azure.Identity;
using Keda.CosmosDb.Scaler.Demo.Shared;
using Microsoft.Azure.Cosmos;
using Microsoft.Extensions.Hosting;
Expand All @@ -25,6 +26,10 @@ public Worker(CosmosDbConfig cosmosDbConfig, ILogger<Worker> logger)

public override async Task StartAsync(CancellationToken cancellationToken)
{
var cosmosClient = _cosmosDbConfig.Connection.Contains("AccountKey")
? new CosmosClient(_cosmosDbConfig.Connection)
: new CosmosClient(_cosmosDbConfig.Connection, new DefaultAzureCredential());

Database leaseDatabase = await new CosmosClient(_cosmosDbConfig.LeaseConnection)
.CreateDatabaseIfNotExistsAsync(_cosmosDbConfig.LeaseDatabaseId, cancellationToken: cancellationToken);

Expand Down

0 comments on commit a00c272

Please sign in to comment.