Support adding database managed identity policies#161
Merged
alex-slynko merged 5 commits intomainfrom Apr 10, 2026
Merged
Conversation
…tabases Agent-Logs-Url: https://github.com/github/KustoSchemaTools/sessions/10ba8c30-dcb5-4cce-8f5c-7f54024a1299 Co-authored-by: alex-slynko <4385389+alex-slynko@users.noreply.github.com>
- 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>
Contributor
There was a problem hiding this comment.
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+ManagedIdentityPolicymodel 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; |
There was a problem hiding this comment.
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; |
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>
ashleyvansp
approved these changes
Apr 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.