Skip to content

Support adding database managed identity policies#161

Merged
alex-slynko merged 5 commits intomainfrom
alex-slynko/managed-identity-loader
Apr 10, 2026
Merged

Support adding database managed identity policies#161
alex-slynko merged 5 commits intomainfrom
alex-slynko/managed-identity-loader

Conversation

@alex-slynko
Copy link
Copy Markdown
Contributor

@alex-slynko alex-slynko commented Apr 10, 2026

  • Support for registering external tables by managed identity per database
  • Support for using UpdatePolicy per managed identity per database

Copilot AI and others added 4 commits April 9, 2026 15:39
- Add KustoManagedIdentityPolicyLoader to read managed identity policies
  from a live Kusto cluster during import mode
- Change ManagedIdentityPolicy to use CreateCombinedScript static method
  that generates a single script for all policies, avoiding duplicate Kind
  keys in ScriptCompareChange.ToDictionary()
- Sort policies by ObjectId and usages alphabetically for canonical diffs
- Add demo managedIdentityPolicies to DemoDatabase database.yml
- Update tests for new combined script API and add multi-policy test
- Add YAML round-trip test for managed identity policies

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Introduce DatabasePolicies class so managed identity lives under
policies.managedIdentity in YAML, making it extensible for future
database-level policies.

- Add DatabasePolicies model with ManagedIdentity property
- Replace Database.ManagedIdentityPolicies with Database.Policies
- Update DatabaseChanges, loader, tests, and demo YAML

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 10, 2026 07:50
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds first-class support for database-level managed identity policies to the schema model/diff pipeline, enabling desired-state YAML to define which managed identities are allowed for specific usages (e.g., external tables, native ingestion), and generating the appropriate KQL to apply those policies.

Changes:

  • Introduces DatabasePolicies + ManagedIdentityPolicy model types and a combined-script generator for .alter-merge database ... policy managed_identity.
  • Adds a Kusto loader to read existing managed identity policy state from a live database.
  • Extends database change generation and test/demo YAML coverage for managed identity policies.
Show a summary per file
File Description
KustoSchemaTools/Parser/KustoLoader/KustoManagedIdentityPolicyLoader.cs Loads managed identity policies from .show database policy managed_identity into the in-memory Database model.
KustoSchemaTools/Model/ManagedIdentityPolicy.cs Defines policy model and generates a single combined KQL script for all identities (stable ordering).
KustoSchemaTools/Model/DatabasePolicies.cs Adds a container for database-level policies (currently managed identity).
KustoSchemaTools/Model/Database.cs Adds Policies to the database model.
KustoSchemaTools/Changes/DatabaseChanges.cs Includes managed identity policy scripts in database-level script comparisons.
KustoSchemaTools.Tests/Parser/YamlDatabaseHandlerTests.cs Verifies managed identity policies deserialize from database.yml.
KustoSchemaTools.Tests/Model/ManagedIdentityPolicyTests.cs Adds unit tests for combined-script generation and change detection behavior.
KustoSchemaTools.Tests/DemoData/DemoDeployment/DemoDatabase/database.yml Adds sample managed identity policy configuration used by tests.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 8/8 changed files
  • Comments generated: 1

using Kusto.Data.Common;
using KustoSchemaTools.Model;
using KustoSchemaTools.Plugins;
using Newtonsoft.Json;
Copy link

Copilot AI Apr 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the unused using Newtonsoft.Json; directive (it’s not referenced in this loader). Keeping it adds noise and may introduce build warnings if the repo ever enables warnings-as-errors.

Suggested change
using Newtonsoft.Json;

Copilot uses AI. Check for mistakes.
MS docs say Policies (plural) but the actual Kusto cluster returns
Policy (singular). One-character fix.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@alex-slynko alex-slynko enabled auto-merge April 10, 2026 15:00
@alex-slynko alex-slynko merged commit 88c62f3 into main Apr 10, 2026
5 checks passed
@alex-slynko alex-slynko deleted the alex-slynko/managed-identity-loader branch April 10, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants