-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Managed Identity support for connecting to Cosmos DB, Update dependencies with latest. #71
base: main
Are you sure you want to change the base?
Conversation
README.md
Outdated
|
||
- **`databaseId`** - ID of Cosmos DB database that contains the monitored container. | ||
|
||
- **`containerId`** - ID of the monitored container. | ||
|
||
- **`leaseConnection`** - Connection string of the Cosmos DB account that contains the lease container. This can be same or different from the value of `connection` metadata. | ||
- **`leaseEndpoint`** - Endpoint URL of the Cosmos DB account that contains the lease container. This can be same or different from the value of `connection` metadata. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
`connection` metadata
to `endpoint` metadata
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
images/architecture.pptx
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What changes were made to the PowerPoint file?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
None
COPY src/Scaler.Demo/OrderGenerator/ src/Scaler.Demo/OrderGenerator/ | ||
COPY src/Scaler.Demo/Shared/ src/Scaler.Demo/Shared/ | ||
ARG BUILD_CONFIGURATION=Release | ||
WORKDIR /src |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should WORKDIR be /src/Scaler.Demo/OrderGenerator
? Other files inside /src
will not be required to be copied for either build or restore.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
On second thought, the earlier Dockerfile was small and used to work. Can you minimize the changes to each Dockerfile, and keep it close to the original?
@@ -1,6 +1,7 @@ | |||
{ | |||
"CosmosDbConfig": { | |||
"Connection": "<connection-string-of-monitored-container-account>", | |||
"Endpoint": "https://{Cosmos Account Name}.documents.azure.com:443/", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Either keep just the 'Endpoint' config or make it clear that either one of the two properties are required.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In case of Order Generator, we are not deploying it on AKS. It just used locally to generate CosmosDB records and trigger the Change Feed, hence Order Generator is using connection string method to authenticate.
var credential = new DefaultAzureCredential(); | ||
|
||
leaseDatabase = new Microsoft.Azure.Cosmos.CosmosClient(_cosmosDbConfig.LeaseEndpoint, credential, clientOptions) | ||
.GetDatabase(_cosmosDbConfig.LeaseDatabaseId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will check the demo project's Readme but creating the lease database here prevents user from that manual step.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No new database is getting created, the code has been modified to handle AAD based CS based authentications
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you create the lease database in that case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
namespace Keda.CosmosDb.Scaler | ||
{ | ||
internal sealed class CosmosDbMetricProvider : ICosmosDbMetricProvider | ||
{ | ||
private readonly CosmosDbFactory _factory; | ||
private readonly ILogger<CosmosDbMetricProvider> _logger; | ||
|
||
static Meter s_meter = new Meter("OrderProcessor.CFStore", "1.0.0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Set visibility of properties explicitly. Use standard C# property names and put newlines between property declarations and methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
.GetContainer(scalerMetadata.DatabaseId, scalerMetadata.ContainerId) | ||
.GetChangeFeedEstimator(scalerMetadata.ProcessorName, leaseContainer); | ||
var credential = new DefaultAzureCredential(); | ||
var cosmosClient = new CosmosClient(scalerMetadata.Endpoint, credential); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Use GetCosmosClient
to have a single connection if both endpoints happen to be same.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK
} | ||
|
||
s_CFRecordsReceived.Add(lagCount); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't find s_*
variables are used anywhere. Can you explain what do they achieve?
@@ -39,8 +41,16 @@ private string LeaseAccountHost | |||
{ | |||
get | |||
{ | |||
var builder = new DbConnectionStringBuilder { ConnectionString = this.LeaseConnection }; | |||
return new Uri((string)builder["AccountEndpoint"]).Host; | |||
if(!string.IsNullOrEmpty(this.LeaseConnection)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we support connection string based connections or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this was a miss
@@ -18,10 +18,10 @@ public CosmosDbScalerServiceTests() | |||
} | |||
|
|||
[Theory] | |||
[InlineData("connection")] | |||
[InlineData("endpoint")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Retain support for connection-string based connections and have tests for both scenarios.
int partitionCount = 0; | ||
|
||
using (FeedIterator<ChangeFeedProcessorState> iterator = estimator.GetCurrentStateIterator()) | ||
long lagCount=0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Put proper spacing.
@@ -1,16 +1,23 @@ | |||
# https://hub.docker.com/_/microsoft-dotnet | |||
#See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this Dockerfile generated using Visual Studio?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes, the original was not working. So, had to overwrite with VS generated Docker.
Provide a description of what has been changed
Checklist
Fixes #