From a00c27297118025012107b7d1e1165daa2ab4f23 Mon Sep 17 00:00:00 2001 From: Piotr Karpala Date: Mon, 10 Jun 2024 23:09:19 -0400 Subject: [PATCH] Support for Default Azure Identity Signed-off-by: Piotr Karpala --- .../Keda.CosmosDb.Scaler.Demo.OrderProcessor.csproj | 1 + src/Scaler.Demo/OrderProcessor/Worker.cs | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/src/Scaler.Demo/OrderProcessor/Keda.CosmosDb.Scaler.Demo.OrderProcessor.csproj b/src/Scaler.Demo/OrderProcessor/Keda.CosmosDb.Scaler.Demo.OrderProcessor.csproj index 2d07aa2..f696b13 100644 --- a/src/Scaler.Demo/OrderProcessor/Keda.CosmosDb.Scaler.Demo.OrderProcessor.csproj +++ b/src/Scaler.Demo/OrderProcessor/Keda.CosmosDb.Scaler.Demo.OrderProcessor.csproj @@ -5,6 +5,7 @@ + diff --git a/src/Scaler.Demo/OrderProcessor/Worker.cs b/src/Scaler.Demo/OrderProcessor/Worker.cs index 949a69d..eb2844a 100644 --- a/src/Scaler.Demo/OrderProcessor/Worker.cs +++ b/src/Scaler.Demo/OrderProcessor/Worker.cs @@ -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; @@ -25,6 +26,10 @@ public Worker(CosmosDbConfig cosmosDbConfig, ILogger 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);