Source Control For Azure Data Explorer(Kusto) Database Schemas

Published 07-23-2019 02:24 PM 2,454 Views
Microsoft

Compute workload team has a lot of logic encapsulated in Kusto stored functions. But since most of the development happens right in Kusto, we hit issues where a developer would make a mistake directly editing the function and it would mess up our production assets. We wanted a way to do code reviews on Kusto functions and have some safeguards in place, but there wasn’t an easy way to pull the entire database schema to the local file system in an easily reviewable format.

 

This is where Sync Kusto comes in handy. The tool lets the user pick either the local file system or a Kusto database as either the source or the target. The Compare button checks both schemas and determines the delta between the source and the target. After viewing the differences, the user can put a checkmark next to the ones they want to publish and then press the Update button.Visualize the differences between the source and the target before updating the target.Visualize the differences between the source and the target before updating the target.

Here’s the process that our team uses:

  1. We have a production database and a development database. The development database has the same schema as the production database, but generally data only lives in the production database and all the functions reference the data in the production database. Our entire schema lives in our repo.
  2. The developer makes and tests all changes in the development database.
  3. Once they are satisfied, the developer uses Sync Kusto to pull the changes to their local repo. The source is the development database and the target is their local repo file path.
  4. After the changes are in the local repo, the developer pushes a new branch and goes through the normal code review process.
  5. Once the pull request is approved, the developer opens Sync Kusto again. This time the source is their local repo (fully synced master branch) and the target is the production Kusto database. The developer presses Compare, verifies that all the changes are expected and then presses Update to deploy the changes.

For an added safety measure, our team also removes any direct human access to the production database. Only an AAD app has Admin permission on the production database and the key for the app id is stored in Azure Key Vault. Our team has access to the key but it stops us from accidentally making changes in the wrong database when we’re doing our development.

 

This tool is now available for everyone on GitHub: https://github.com/microsoft/synckusto. We hope that this is useful to you and look forward to your feedback and contributions!

%3CLINGO-SUB%20id%3D%22lingo-sub-770611%22%20slang%3D%22en-US%22%3ESource%20Control%20For%20Azure%20Data%20Explorer(Kusto)%20Database%20Schemas%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-770611%22%20slang%3D%22en-US%22%3E%3CP%3ECompute%20workload%26nbsp%3Bteam%20has%20a%20lot%20of%20logic%20encapsulated%20in%20Kusto%20%3CA%20href%3D%22https%3A%2F%2Fdocs.microsoft.com%2Fen-us%2Fazure%2Fkusto%2Fmanagement%2Ffunctions%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Estored%20functions%3C%2FA%3E.%20But%20since%20most%20of%20the%20development%20happens%20right%20in%20Kusto%2C%20we%20hit%20issues%20where%20a%20developer%20would%20make%20a%20mistake%20directly%20editing%20the%20function%20and%20it%20would%20mess%20up%20our%20production%20assets.%20We%20wanted%20a%20way%20to%20do%20code%20reviews%20on%20Kusto%20functions%20and%20have%20some%20safeguards%20in%20place%2C%20but%20there%20wasn%E2%80%99t%20an%20easy%20way%20to%20pull%20the%20entire%20database%20schema%20to%20the%20local%20file%20system%20in%20an%20easily%20reviewable%20format.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20is%20where%20Sync%20Kusto%20comes%20in%20handy.%20The%20tool%20lets%20the%20user%20pick%20either%20the%20local%20file%20system%20or%20a%20Kusto%20database%20as%20either%20the%20source%20or%20the%20target.%20The%20Compare%20button%20checks%20both%20schemas%20and%20determines%20the%20delta%20between%20the%20source%20and%20the%20target.%20After%20viewing%20the%20differences%2C%20the%20user%20can%20put%20a%20checkmark%20next%20to%20the%20ones%20they%20want%20to%20publish%20and%20then%20press%20the%20Update%20button.%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-center%22%20style%3D%22width%3A%20641px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F124221iD959FE278F06F2C1%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22synckustoscreenshot.png%22%20title%3D%22synckustoscreenshot.png%22%20%2F%3E%3CSPAN%20class%3D%22lia-inline-image-caption%22%20onclick%3D%22event.preventDefault()%3B%22%3EVisualize%20the%20differences%20between%20the%20source%20and%20the%20target%20before%20updating%20the%20target.%3C%2FSPAN%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3EHere%E2%80%99s%20the%20process%20that%20our%20team%20uses%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EWe%20have%20a%20production%20database%20and%20a%20development%20database.%20The%20development%20database%20has%20the%20same%20schema%20as%20the%20production%20database%2C%20but%20generally%20data%20only%20lives%20in%20the%20production%20database%20and%20all%20the%20functions%20reference%20the%20data%20in%20the%20production%20database.%20Our%20entire%20schema%20lives%20in%20our%20repo.%3C%2FLI%3E%0A%3CLI%3EThe%20developer%20makes%20and%20tests%20all%20changes%20in%20the%20development%20database.%3C%2FLI%3E%0A%3CLI%3EOnce%20they%20are%20satisfied%2C%20the%20developer%20uses%20Sync%20Kusto%20to%20pull%20the%20changes%20to%20their%20local%20repo.%20The%20source%20is%20the%20development%20database%20and%20the%20target%20is%20their%20local%20repo%20file%20path.%3C%2FLI%3E%0A%3CLI%3EAfter%20the%20changes%20are%20in%20the%20local%20repo%2C%20the%20developer%20pushes%20a%20new%20branch%20and%20goes%20through%20the%20normal%20code%20review%20process.%3C%2FLI%3E%0A%3CLI%3EOnce%20the%20pull%20request%20is%20approved%2C%20the%20developer%20opens%20Sync%20Kusto%20again.%20This%20time%20the%20source%20is%20their%20local%20repo%20(fully%20synced%20master%20branch)%20and%20the%20target%20is%20the%20production%20Kusto%20database.%20The%20developer%20presses%20Compare%2C%20verifies%20that%20all%20the%20changes%20are%20expected%20and%20then%20presses%20Update%20to%20deploy%20the%20changes.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3EFor%20an%20added%20safety%20measure%2C%20our%20team%20also%20removes%20any%20direct%20human%20access%20to%20the%20production%20database.%20Only%20an%20AAD%20app%20has%20Admin%20permission%20on%20the%20production%20database%20and%20the%20key%20for%20the%20app%20id%20is%20stored%20in%20Azure%20Key%20Vault.%20Our%20team%20has%20access%20to%20the%20key%20but%20it%20stops%20us%20from%20accidentally%20making%20changes%20in%20the%20wrong%20database%20when%20we%E2%80%99re%20doing%20our%20development.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThis%20tool%20is%20now%20available%20for%20everyone%20on%20GitHub%3A%20%3CA%20href%3D%22https%3A%2F%2Fgithub.com%2Fmicrosoft%2Fsynckusto%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%22%3Ehttps%3A%2F%2Fgithub.com%2Fmicrosoft%2Fsynckusto%3C%2FA%3E.%20We%20hope%20that%20this%20is%20useful%20to%20you%20and%20look%20forward%20to%20your%20feedback%20and%20contributions!%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-770611%22%20slang%3D%22en-US%22%3E%3CP%3EThe%20Sync%20Kusto%20tool%20(now%20available%20on%20GitHub)%20makes%20it%20easy%20to%20copy%20Kusto%20database%20schemas%20between%20Kusto%20clusters%20and%20the%20local%20file%20system%20enabling%20teams%20to%20do%20pull%20requests%20before%20safely%20deploying%20their%20changes%20to%20production.%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20style%3D%22width%3A%20638px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Fgxcuf89792.i.lithium.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F124223iD6EB8A3B97C605EB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20alt%3D%22synckustoscreenshot_small.png%22%20title%3D%22synckustoscreenshot_small.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3C%2FLINGO-TEASER%3E
Version history
Last update:
‎Aug 06 2019 04:06 AM
Updated by: