Data bricks Notebook Deployment using YAML code

Published Dec 28 2021 04:14 AM 2,767 Views
Microsoft

Purpose of this Blog:

  1. We have defined end-end workflow for code check-in using two methods
    • Notebook Revision History (standard check-in process which was defined to check-in the notebook code)
    • Azure Databricks Repos (No Repo Size Limitation from May 13th)
  2. Changes made externally to the Databricks notebook will not automatically sync with the Databricks Workspace. Due to this limitation, it is recommended that developers sync the entire git repository as detailed in the process below.
  3. We have written yaml template for CI and CD with Powershell code which can deploy notebooks from multiple folders and the powershell code in pipeline will create folder in the destination if the folder doesn't exist against the Data thirst extension which can only deploy notebooks in single folder.
  4. One stop for whole Databricks deployment workflow from code-check-in to pipelines with detailed explanation(which is used by stakeholders)

 

Developer Workflow (CI/CD)


Git Integration:

  1. Create a feature branch based on the main branch and link a work item to it.

    Akshay_Attota_2-1640691680049.png

     

  2. Login into your Azure Databricks Dev/Sandbox and click on user icon (top right) and open user settings.

    Akshay_Attota_3-1640691717309.png

     

  3. Click on Git Integration Tab and make sure you have selected Azure Devops Services

    Akshay_Attota_4-1640691752996.png

     

  4. There are two ways to check-in the code from Databricks UI (described below)
    1.Using Revision History after opening Notebooks
    2.Work with notebooks and folders in an Azure Databricks repo(Repos which is a recent development - 13th May)

 

Code Check-in into the Git repository from Databricks UI


I. Notebook Revision History:


  1. Go to notebook you want to make changes and deploy to another environment.

    Akshay_Attota_0-1640691850900.png

    Note: Developers need to make sure to maintain a shared/common folder for all the notebooks. You can make all required changes in your personal folder and then finally move these changes to the shared/common folder. The CI process will create the artifact from this shared/common folder.

  2. Click on the Revision history on top right.

    Akshay_Attota_1-1640691900171.png

     

  3. If it is a new notebook, you will be able to notice that git is not linked to the notebook or Git might be linked to older branch which might not exist.

  4. Click on the ‘Git:Not Linked’(New Notebook) or 'Git Synced'(Already existing notebook).

  5. We need to configure the Git Repository. (screenshot below)

    Akshay_Attota_2-1640691972589.png
  • Select feature branch from the list of branches in the drop down
  • Mention the URL of the repository in the format
    https://dev.azure.com/<organisationname>/<ProjectName>/_git/<Repo>
  • Mention the path of the notebook in the repository. In our case it is src/Databricks/ITDataEngineerADBDev2/notebooks/<folder name>/<notebook.py>
  1. Click on Save Notebook by adding a comment to integrate the code to the repository.

    Akshay_Attota_3-1640692009711.png

     

  2. We need to create a PR after the changes are reflected in the feature branch.

    Akshay_Attota_4-1640692082964.png

     

  3. After PR gets approved, the code now is merged into the main branch and CI-CD process will start from here.

Akshay_Attota_5-1640692120299.png

 

Note: Linking individual notebooks has the following limitation

 

II. Azure Databricks Repos:


Introduction

  • Repos is a newly introduced feature in Azure Databricks which is in Public Preview.
  • This feature used to have a 100mb limitation on the size of the linked repository but this feature is now working with larger repositories as of May 13th.
  • We can directly link a repository to the Databricks workspace to work on notebooks based on git branches.

Repos Check-in Process:

  1. Click on Repos tab and right click on the folder you want to work and then select "Add Repos".

    Akshay_Attota_0-1640692322727.png

     

  2. Fill in the Repo URL from Azure Devops and select the Git provider as "Azure Devops Services" and click on create.

    Akshay_Attota_1-1640692350046.png

     

  3. The repo gets added with folder name as repo name(Data in the screenshot below) and a selection with all the branch names(branch symbol with feature/ and down arrow in screenshot below). Click on the down arrow beside the branch name.

    Akshay_Attota_2-1640692387593.png

     

  4. After clicking on down arrow(previous screenshot), search and select your existing feature branch OR create a new feature branch (as shown in screenshot below).

    Akshay_Attota_3-1640692415036.png

     

  5. All the folders in the branch are visible (refer the screenshot below)

    Akshay_Attota_4-1640692445592.png

     

  6. Open the folder which contains the notebooks(refer the screenshot below). Create a new notebook and write code(Right click on the folder and select "create"---->"Notebook" like screenshot below) or edit an existing notebook in the folder.

     

     

    Akshay_Attota_5-1640692479441.png

     

     

  7. After creating a new notebook or editing an existing notebook, click on top left hand of the notebook which contains feature branch name. Then, new window will appear which will show the changes. Add Summary(mandatory) and Description(optional), then click on "commit and push".

Akshay_Attota_6-1640692523855.png

 

  1. Then a pop up with the following message appears that it is "committed and pushed" and then the user should raise a PR to merge the feature branch into the "main" branch.

Akshay_Attota_7-1640692551074.png

 

  • After successful PR merge, the CI-CD pipeline is run for the deployment of the notebooks to the higher environments(QA/Prod).

CI-CD Process


Continuous Integration(CI) pipeline:

The CI pipeline builds the artifact by copying the notebooks from main branch to staging directory.

It has two tasks:

  1. Copy Task - Copies from main branch to staging directory.

  2. Publish Artifacts - publishes artifacts from $(build.stagingdirectory)

  • YAML Template

 

 

name: Release-$(rev:r)

trigger: none

variables:
  workingDirectory: '$(System.DefaultWorkingDirectory)/<path>'

stages:
- stage: Build
  displayName: Build stage

  jobs:
  - job: Build
    displayName: Build
    steps:
    - task: CopyFiles@2
      displayName: 'Copy Files to:  $(build.artifactstagingdirectory)'
      inputs:
        SourceFolder: '$(workingDirectory)'
        TargetFolder: ' $(build.artifactstagingdirectory)'

    - task: PublishBuildArtifacts@1
      displayName: 'Publish Artifact: notebooks'
      inputs:
        ArtifactName: dev_release

 

 

Continuous Deployment(CD) pipeline:

Deployment with secure hosted agent

a. Run the release pipeline for the specified target environment.
This will download the previously generated Build Artifacts. It will also download secure connection strings from Azure Key Vault. Make sure your self hosted agent is configured properly as per Self-Hosted Agent.Then it will deploy notebooks to your Target Azure Databricks Workspace.

The code below shows how to run your release agent on a specific self hosted agent: Take note of the pool and demands configuration.

  • In the continuous deployment pipeline we have to deploy the artifacts build to Dev , QA, UAT and prod environments.
  • We will have approval gates setup before the deployment to each environment(stage) gets started.

 

 

stages:
- stage: Release
  displayName: Release stage

  jobs:
  - deployment: DeployDatabricks
    displayName: Deploy Databricks Notebooks
    pool:
      name: OTT-DEV-FanDataPool
      demands:
        - agent.name -equals <agent-name>
    environment: <env-name>

 

 

We have two steps for the deployment:

  1. Getting Key Vault Secrets PAT(Personal Access Token) and Target Data bricks Workspace URL from the Key Vault.

  2. Importing the Notebooks to the target Databricks using import Rest API.(PowerShell Task with Inline Script)

  • We can perform multiple folder notebook deployments using this script.

  • We are creating a folder(Folder in Repository similar to Sandbox/Dev environment) if it does not exist in the target(dev/QA/UAT/Prod) data bricks workspace and then importing the notebooks into the folder.

 

  • YAML template

 

 

name: Release-$(rev:r)

trigger: none

resources:
  pipelines:
    - pipeline: notebooks
      source: Databricks-CI
      trigger:
        branches:
          - main

variables:
  - name: azureSubscription
    value: '<serviceConnectionName>'
  - name: workingDirectory_shared
    value: '$(Pipeline.Workspace)/<path>/'

stages:
- stage: Release
  displayName: Release stage

  jobs:
  - deployment: DeployDatabricks
    displayName: Deploy Databricks Notebooks
    environment: DEV
    strategy:
      runOnce:
        deploy:
          steps:
          - task: AzureKeyVault@1
            inputs:
              azureSubscription: '$(azureSubscription)'
              KeyVaultName: $(dev_keyvault)
              SecretsFilter: 'databricks-pat,databricks-url'
              RunAsPreJob: true
          - task: AzurePowerShell@5
            inputs:
              azureSubscription: '$(azureSubscription)'
              ScriptType: 'InlineScript'
              Inline: |
                $filenames = get-childitem $(workingDirectory_shared) -recurse | where {$_.extension -eq ".py"};
                $filenames | ForEach-Object {
                  $NewNotebookName = $_.Name
                  #Get Our PAT Token for workspace from the Variable 
                  $Secret = "Bearer "+ "$(databricks-pat)";
                  #Set the URI for API Endpoint
                  $ImportNoteBookAPI = "$(databricks-url)"+"/api/2.0/workspace/import";
                  $FolderCheckAPI= "$(databricks-url)"+"/api/2.0/workspace/get-status";
                  $FolderCreateAPI = "$(databricks-url)"+"/api/2.0/workspace/mkdirs"
                  #Open and Import the Notebook to Workspace
                  $BinaryContents = [System.IO.File]::ReadAllBytes($_.FullName);
                  $EncodedContents = [System.Convert]::ToBase64String($BinaryContents);
                  $foldername = $_.FullName.split("\")[$_.FullName.split("\").length-2];
                  $folderpath = "/"+$foldername + "/";
                  $notebookpath = $folderpath + "$NewNotebookName"
                  #API Body for Importing Notebooks 
                  $ImportNoteBookBody = @{
                      content = "$EncodedContents"
                      language = "PYTHON"
                      overwrite = $true
                      format = "SOURCE"
                      path = $notebookpath 	
                  }
                  #Convert body to JSON
                  $ImportNoteBookBodyText = $ImportNoteBookBody | ConvertTo-Json

                  #API Body for Creating Folder 
                  $CreateFolderBody = @{
                      path = $folderpath 	
                  }
                  #Convert body to JSON
                  $CreateFolderBodyText = $CreateFolderBody | ConvertTo-Json
                  #Headers for all the API calls
                  $headers = @{
                      Authorization = $Secret
                  }
                  try{

                  #Check if the folder exists 
                  $CheckPath = $FolderCheckAPI + "?path="+ $folderpath; 
                  $CheckFolder = Invoke-RestMethod -Uri $CheckPath -Method Get -Headers $headers;
                  }
                  catch [System.Net.WebException] 
                 {
                  Write-Host "Entering the catch block and Creating Folder"; 
                  #Creating a Folder if it does not exists  
                  Invoke-RestMethod -Uri $FolderCreateAPI -Method Post -Headers $headers -Body $CreateFolderBodyText
                 }
                 #Importing a notebook to the Folder in Target DataBricks Workspace
                  Write-Host "Creating Notebook " + $notebookpath 
                  Invoke-RestMethod -Uri $ImportNoteBookAPI -Method Post -Headers $headers -Body $ImportNoteBookBodyText
                 }
                
              azurePowerShellVersion: 'LatestVersion'

 

 

 

%3CLINGO-SUB%20id%3D%22lingo-sub-3046952%22%20slang%3D%22en-US%22%3EData%20bricks%20Notebook%20Deployment%20using%20YAML%20code%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-3046952%22%20slang%3D%22en-US%22%3E%3CP%3EPurpose%20of%20this%20Blog%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3EWe%20have%20defined%20end-end%20workflow%20for%20code%20check-in%20using%20two%20methods%3CUL%3E%0A%3CLI%3ENotebook%20Revision%20History%20(standard%20check-in%20process%20which%20was%20defined%20to%20check-in%20the%20notebook%20code)%3C%2FLI%3E%0A%3CLI%3EAzure%20Databricks%20Repos%20(No%20Repo%20Size%20Limitation%20from%20May%2013th)%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3C%2FLI%3E%0A%3CLI%3EChanges%20made%20externally%20to%20the%20Databricks%20notebook%20will%20not%20automatically%20sync%20with%20the%20Databricks%20Workspace.%20Due%20to%20this%20limitation%2C%20it%20is%20recommended%20that%20developers%20sync%20the%20entire%20git%20repository%20as%20detailed%20in%20the%20process%20below.%3C%2FLI%3E%0A%3CLI%3EWe%20have%20written%20yaml%20template%20for%20CI%20and%20CD%20with%20Powershell%20code%20which%20can%20deploy%20notebooks%20from%20multiple%20folders%20and%20the%20powershell%20code%20in%20pipeline%20will%20create%20folder%20in%20the%20destination%20if%20the%20folder%20doesn't%20exist%20against%20the%20Data%20thirst%20extension%20which%20can%20only%20deploy%20notebooks%20in%20single%20folder.%3C%2FLI%3E%0A%3CLI%3EOne%20stop%20for%20whole%20Databricks%20deployment%20workflow%20from%20code-check-in%20to%20pipelines%20with%20detailed%20explanation(which%20is%20used%20by%20stakeholders)%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH1%20id%3D%22user-content-developer-workflow-(ci%252Fcd)%22%20id%3D%22toc-hId-2130744822%22%20id%3D%22toc-hId-2134340976%22%3EDeveloper%20Workflow%20(CI%2FCD)%3C%2FH1%3E%0A%3CHR%20%2F%3E%0A%3CH2%20id%3D%22user-content-**git-integration**%253A%22%20id%3D%22toc-hId--1473661000%22%20id%3D%22toc-hId--1470064846%22%3E%3CSTRONG%3EGit%20Integration%3C%2FSTRONG%3E%3A%3C%2FH2%3E%0A%3COL%3E%0A%3CLI%3E%3CP%3ECreate%20a%20feature%20branch%20based%20on%20the%20main%20branch%20and%20link%20a%20work%20item%20to%20it.%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_2-1640691680049.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336136i188C3BD65CD71B92%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_2-1640691680049.png%22%20alt%3D%22Akshay_Attota_2-1640691680049.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3ELogin%20into%20your%20Azure%20Databricks%20Dev%2FSandbox%20and%20click%20on%20user%20icon%20(top%20right)%20and%20open%20user%20settings.%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_3-1640691717309.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336137i0A5379286562F6A5%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_3-1640691717309.png%22%20alt%3D%22Akshay_Attota_3-1640691717309.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EClick%20on%20Git%20Integration%20Tab%20and%20make%20sure%20you%20have%20selected%20Azure%20Devops%20Services%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_4-1640691752996.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336138iAF4E2FADE56DACEF%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_4-1640691752996.png%22%20alt%3D%22Akshay_Attota_4-1640691752996.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EThere%20are%20two%20ways%20to%20check-in%20the%20code%20from%20Databricks%20UI%20(described%20below)%3CBR%20%2F%3E1.Using%20Revision%20History%20after%20opening%20Notebooks%3CBR%20%2F%3E2.Work%20with%20notebooks%20and%20folders%20in%20an%20Azure%20Databricks%20repo(Repos%20which%20is%20a%20recent%20development%20-%2013th%20May)%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22user-content-code-check-in-into-the-git-repository-from-databricks-ui%22%20id%3D%22toc-hId-1013851833%22%20id%3D%22toc-hId-1017447987%22%3ECode%20Check-in%20into%20the%20Git%20repository%20from%20Databricks%20UI%3C%2FH2%3E%0A%3CHR%20%2F%3E%0A%3CH3%20id%3D%22user-content-**i.-notebook-revision-history**%253A%22%20id%3D%22toc-hId-1704413307%22%20id%3D%22toc-hId-1708009461%22%3E%3CSTRONG%3EI.%20Notebook%20Revision%20History%3C%2FSTRONG%3E%3A%3C%2FH3%3E%0A%3CHR%20%2F%3E%0A%3COL%3E%0A%3CLI%3E%3CP%3EGo%20to%20notebook%20you%20want%20to%20make%20changes%20and%20deploy%20to%20another%20environment.%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_0-1640691850900.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336139iDE47CE747734C8E3%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_0-1640691850900.png%22%20alt%3D%22Akshay_Attota_0-1640691850900.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%3CEM%3E%3CSTRONG%3ENote%3A%20Developers%20need%20to%20make%20sure%20to%20maintain%20a%20shared%2Fcommon%20folder%20for%20all%20the%20notebooks.%20You%20can%20make%20all%20required%20changes%20in%20your%20personal%20folder%20and%20then%20finally%20move%20these%20changes%20to%20the%20shared%2Fcommon%20folder.%20The%20CI%20process%20will%20create%20the%20artifact%20from%20this%20shared%2Fcommon%20folder.%3C%2FSTRONG%3E%3C%2FEM%3E%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EClick%20on%20the%20Revision%20history%20on%20top%20right.%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_1-1640691900171.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336140i3621834423BDD3B9%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_1-1640691900171.png%22%20alt%3D%22Akshay_Attota_1-1640691900171.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EIf%20it%20is%20a%20new%20notebook%2C%20you%20will%20be%20able%20to%20notice%20that%20git%20is%20not%20linked%20to%20the%20notebook%20or%20Git%20might%20be%20linked%20to%20older%20branch%20which%20might%20not%20exist.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EClick%20on%20the%20%E2%80%98Git%3ANot%20Linked%E2%80%99(New%20Notebook)%20or%20'Git%20Synced'(Already%20existing%20notebook).%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EWe%20need%20to%20configure%20the%20Git%20Repository.%20(screenshot%20below)%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_2-1640691972589.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336141iCCDDD0699CD4A51A%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_2-1640691972589.png%22%20alt%3D%22Akshay_Attota_2-1640691972589.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CUL%3E%0A%3CLI%3ESelect%20feature%20branch%20from%20the%20list%20of%20branches%20in%20the%20drop%20down%3C%2FLI%3E%0A%3CLI%3EMention%20the%20URL%20of%20the%20repository%20in%20the%20format%3CBR%20%2F%3E%3CCODE%3E%3CA%20href%3D%22https%3A%2F%2Fdev.azure.com%2F%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3Ehttps%3A%2F%2Fdev.azure.com%2F%3C%2FA%3E%3CORGANISATIONNAME%3E%2F%3CPROJECTNAME%3E%2F_git%2F%3CREPO%3E%3C%2FREPO%3E%3C%2FPROJECTNAME%3E%3C%2FORGANISATIONNAME%3E%3C%2FCODE%3E%3C%2FLI%3E%0A%3CLI%3EMention%20the%20path%20of%20the%20notebook%20in%20the%20repository.%20In%20our%20case%20it%20is%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Esrc%2FDatabricks%2FITDataEngineerADBDev2%2Fnotebooks%2F%3CFOLDER%20name%3D%22%22%3E%2F%3CNOTEBOOK.PY%3E%3C%2FNOTEBOOK.PY%3E%3C%2FFOLDER%3E%3C%2FCODE%3E%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3COL%20start%3D%226%22%3E%0A%3CLI%3E%3CP%3EClick%20on%20Save%20Notebook%20by%20adding%20a%20comment%20to%20integrate%20the%20code%20to%20the%20repository.%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_3-1640692009711.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336142i40147E43F7E3FA0B%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_3-1640692009711.png%22%20alt%3D%22Akshay_Attota_3-1640692009711.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EWe%20need%20to%20create%20a%20PR%20after%20the%20changes%20are%20reflected%20in%20the%20feature%20branch.%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_4-1640692082964.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336143i38AE7B1DE585364E%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_4-1640692082964.png%22%20alt%3D%22Akshay_Attota_4-1640692082964.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EAfter%20PR%20gets%20approved%2C%20the%20code%20now%20is%20merged%20into%20the%20main%20branch%20and%20CI-CD%20process%20will%20start%20from%20here.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_5-1640692120299.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336144i8738AE03424738E4%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_5-1640692120299.png%22%20alt%3D%22Akshay_Attota_5-1640692120299.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CEM%3ENote%3A%20Linking%20individual%20notebooks%20has%20the%20following%20limitation%3C%2FEM%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EChanges%20made%20externally%20to%20the%20Databricks%20notebook%20(outside%20of%20the%20Databricks%20workspace)%20will%20not%20automatically%20sync%20with%20the%20Databricks%20Workspace.%20This%20issue%20is%20documented%20here%3A%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20class%3D%22%22%20href%3D%22https%3A%2F%2Fforums.databricks.com%2Fquestions%2F6752%2Fexternal-changes-to-git-in-synced-notebook.html*%22%20target%3D%22_blank%22%20rel%3D%22noopener%20noreferrer%20nofollow%22%3Ehttps%3A%2F%2Fforums.databricks.com%2Fquestions%2F6752%2Fexternal-changes-to-git-in-synced-notebook.html*%3C%2FA%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FLI%3E%0A%3CLI%3EDue%20to%20this%20limitation%2C%20it%20is%20recommended%20that%20developers%20sync%20the%20entire%20git%20repository%20as%20detailed%20below.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH3%20id%3D%22user-content-**ii.-azure-databricks-repos**%253A%22%20id%3D%22toc-hId--103041156%22%20id%3D%22toc-hId--99445002%22%3E%3CSTRONG%3EII.%20Azure%20Databricks%20Repos%3C%2FSTRONG%3E%3A%3C%2FH3%3E%0A%3CHR%20%2F%3E%0A%3CP%3E%3CSTRONG%3EIntroduction%3C%2FSTRONG%3E%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3ERepos%20is%20a%20newly%20introduced%20feature%20in%20Azure%20Databricks%20which%20is%20in%20Public%20Preview.%3C%2FLI%3E%0A%3CLI%3EThis%20feature%20used%20to%20have%20a%20100mb%20limitation%20on%20the%20size%20of%20the%20linked%20repository%20but%20this%20feature%20is%20now%20working%20with%20larger%20repositories%20as%20of%20May%2013th.%3C%2FLI%3E%0A%3CLI%3EWe%20can%20directly%20link%20a%20repository%20to%20the%20Databricks%20workspace%20to%20work%20on%20notebooks%20based%20on%20git%20branches.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%3CSTRONG%3ERepos%20Check-in%20Process%3A%3C%2FSTRONG%3E%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CP%3EClick%20on%20Repos%20tab%20and%20right%20click%20on%20the%20folder%20you%20want%20to%20work%20and%20then%20select%20%22Add%20Repos%22.%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_0-1640692322727.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336145iDCAE1FFBAB69511C%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_0-1640692322727.png%22%20alt%3D%22Akshay_Attota_0-1640692322727.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EFill%20in%20the%20Repo%20URL%20from%20Azure%20Devops%20and%20select%20the%20Git%20provider%20as%20%22Azure%20Devops%20Services%22%20and%20click%20on%20create.%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_1-1640692350046.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336146i1C8478858A13BAC6%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_1-1640692350046.png%22%20alt%3D%22Akshay_Attota_1-1640692350046.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EThe%20repo%20gets%20added%20with%20folder%20name%20as%20repo%20name(Data%20in%20the%20screenshot%20below)%20and%20a%20selection%20with%20all%20the%20branch%20names(branch%20symbol%20with%20feature%2F%20and%20down%20arrow%20in%20screenshot%20below).%20Click%20on%20the%20down%20arrow%20beside%20the%20branch%20name.%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_2-1640692387593.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336148iBF8D47B508BB1C26%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_2-1640692387593.png%22%20alt%3D%22Akshay_Attota_2-1640692387593.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EAfter%20clicking%20on%20down%20arrow(previous%20screenshot)%2C%20search%20and%20select%20your%20existing%20feature%20branch%20OR%20create%20a%20new%20feature%20branch%20(as%20shown%20in%20screenshot%20below).%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_3-1640692415036.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336149i694EE56D51C54466%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_3-1640692415036.png%22%20alt%3D%22Akshay_Attota_3-1640692415036.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EAll%20the%20folders%20in%20the%20branch%20are%20visible%20(refer%20the%20screenshot%20below)%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_4-1640692445592.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336150i02F7A85FF2F420C1%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_4-1640692445592.png%22%20alt%3D%22Akshay_Attota_4-1640692445592.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EOpen%20the%20folder%20which%20contains%20the%20notebooks(refer%20the%20screenshot%20below).%20Create%20a%20new%20notebook%20and%20write%20code(Right%20click%20on%20the%20folder%20and%20select%20%22create%22----%26gt%3B%22Notebook%22%20like%20screenshot%20below)%20or%20edit%20an%20existing%20notebook%20in%20the%20folder.%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3C%2FP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_5-1640692479441.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336151i2F5E3D3F98927B5D%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_5-1640692479441.png%22%20alt%3D%22Akshay_Attota_5-1640692479441.png%22%20%2F%3E%3C%2FSPAN%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EAfter%20creating%20a%20new%20notebook%20or%20editing%20an%20existing%20notebook%2C%20click%20on%20top%20left%20hand%20of%20the%20notebook%20which%20contains%20feature%20branch%20name.%20Then%2C%20new%20window%20will%20appear%20which%20will%20show%20the%20changes.%20Add%20Summary(mandatory)%20and%20Description(optional)%2C%20then%20click%20on%20%22commit%20and%20push%22.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_6-1640692523855.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336152i38A94478EEF41377%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_6-1640692523855.png%22%20alt%3D%22Akshay_Attota_6-1640692523855.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3COL%20start%3D%228%22%3E%0A%3CLI%3EThen%20a%20pop%20up%20with%20the%20following%20message%20appears%20that%20it%20is%20%22committed%20and%20pushed%22%20and%20then%20the%20user%20should%20raise%20a%20PR%20to%20merge%20the%20feature%20branch%20into%20the%20%22main%22%20branch.%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_7-1640692551074.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336153iB8B72613C0F55569%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_7-1640692551074.png%22%20alt%3D%22Akshay_Attota_7-1640692551074.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EAfter%20successful%20PR%20merge%2C%20the%20CI-CD%20pipeline%20is%20run%20for%20the%20deployment%20of%20the%20notebooks%20to%20the%20higher%20environments(QA%2FProd).%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CH1%20id%3D%22user-content-ci-cd-process%22%20id%3D%22toc-hId-1683407099%22%20id%3D%22toc-hId-1687003253%22%3ECI-CD%20Process%3C%2FH1%3E%0A%3CHR%20%2F%3E%0A%3CH2%20id%3D%22user-content-**continuous-integration(ci)-pipeline**%253A%22%20id%3D%22toc-hId--1920998723%22%20id%3D%22toc-hId--1917402569%22%3E%3CSTRONG%3EContinuous%20Integration(CI)%20pipeline%3C%2FSTRONG%3E%3A%3C%2FH2%3E%0A%3CP%3EThe%20CI%20pipeline%20builds%20the%20artifact%20by%20copying%20the%20notebooks%20from%20main%20branch%20to%20staging%20directory.%3C%2FP%3E%0A%3CP%3EIt%20has%20two%20tasks%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CP%3ECopy%20Task%20-%20Copies%20from%20main%20branch%20to%20staging%20directory.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EPublish%20Artifacts%20-%20publishes%20artifacts%20from%20%24(build.stagingdirectory)%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CUL%3E%0A%3CLI%3EYAML%20Template%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-yaml%22%3E%3CCODE%3Ename%3A%20Release-%24(rev%3Ar)%0A%0Atrigger%3A%20none%0A%0Avariables%3A%0A%20%20workingDirectory%3A%20'%24(System.DefaultWorkingDirectory)%2F%3CPATH%3E'%0A%0Astages%3A%0A-%20stage%3A%20Build%0A%20%20displayName%3A%20Build%20stage%0A%0A%20%20jobs%3A%0A%20%20-%20job%3A%20Build%0A%20%20%20%20displayName%3A%20Build%0A%20%20%20%20steps%3A%0A%20%20%20%20-%20task%3A%20CopyFiles%402%0A%20%20%20%20%20%20displayName%3A%20'Copy%20Files%20to%3A%20%20%24(build.artifactstagingdirectory)'%0A%20%20%20%20%20%20inputs%3A%0A%20%20%20%20%20%20%20%20SourceFolder%3A%20'%24(workingDirectory)'%0A%20%20%20%20%20%20%20%20TargetFolder%3A%20'%20%24(build.artifactstagingdirectory)'%0A%0A%20%20%20%20-%20task%3A%20PublishBuildArtifacts%401%0A%20%20%20%20%20%20displayName%3A%20'Publish%20Artifact%3A%20notebooks'%0A%20%20%20%20%20%20inputs%3A%0A%20%20%20%20%20%20%20%20ArtifactName%3A%20dev_release%3C%2FPATH%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CH2%20id%3D%22user-content-**continuous-deployment(cd)-pipeline**%253A%22%20id%3D%22toc-hId-566514110%22%20id%3D%22toc-hId-570110264%22%3E%3CSTRONG%3EContinuous%20Deployment(CD)%20pipeline%3C%2FSTRONG%3E%3A%3C%2FH2%3E%0A%3CP%3EDeployment%20with%20secure%20hosted%20agent%3C%2FP%3E%0A%3CP%3Ea.%20Run%20the%20release%20pipeline%20for%20the%20specified%20target%20environment.%3CBR%20%2F%3EThis%20will%20download%20the%20previously%20generated%20Build%20Artifacts.%20It%20will%20also%20download%20secure%20connection%20strings%20from%20Azure%20Key%20Vault.%20Make%20sure%20your%20self%20hosted%20agent%20is%20configured%20properly%20as%20per%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CA%20class%3D%22%22%20href%3D%22https%3A%2F%2Fdev.azure.com%2Fnbadev%2FDTC%2F_wiki%2Fwikis%2FDTC.wiki%3FwikiVersion%3DGBwikiMaster%26amp%3BpagePath%3D%2FWork%2520Stream%25209%2520%25252D%2520Data%2FData%2520Components%2520CI%25252DCD%2520Process%2FSelf%25252DHosted%2520Agent%22%20target%3D%22_blank%22%20rel%3D%22noopener%20nofollow%20noreferrer%22%3ESelf-Hosted%20Agent%3C%2FA%3E.Then%20it%20will%20deploy%20notebooks%20to%20your%20Target%20Azure%20Databricks%20Workspace.%3C%2FP%3E%0A%3CP%3EThe%20code%20below%20shows%20how%20to%20run%20your%20release%20agent%20on%20a%20specific%20self%20hosted%20agent%3A%20Take%20note%20of%20the%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Epool%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Eand%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3E%3CCODE%3Edemands%3C%2FCODE%3E%3CSPAN%3E%26nbsp%3B%3C%2FSPAN%3Econfiguration.%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3EIn%20the%20continuous%20deployment%20pipeline%20we%20have%20to%20deploy%20the%20artifacts%20build%20to%20Dev%20%2C%20QA%2C%20UAT%20and%20prod%20environments.%3C%2FLI%3E%0A%3CLI%3EWe%20will%20have%20approval%20gates%20setup%20before%20the%20deployment%20to%20each%20environment(stage)%20gets%20started.%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-yaml%22%3E%3CCODE%3Estages%3A%0A-%20stage%3A%20Release%0A%20%20displayName%3A%20Release%20stage%0A%0A%20%20jobs%3A%0A%20%20-%20deployment%3A%20DeployDatabricks%0A%20%20%20%20displayName%3A%20Deploy%20Databricks%20Notebooks%0A%20%20%20%20pool%3A%0A%20%20%20%20%20%20name%3A%20OTT-DEV-FanDataPool%0A%20%20%20%20%20%20demands%3A%0A%20%20%20%20%20%20%20%20-%20agent.name%20-equals%20%3CAGENT-NAME%3E%0A%20%20%20%20environment%3A%20%3CENV-NAME%3E%3C%2FENV-NAME%3E%3C%2FAGENT-NAME%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EWe%20have%20two%20steps%20for%20the%20deployment%3A%3C%2FP%3E%0A%3COL%3E%0A%3CLI%3E%3CP%3EGetting%20Key%20Vault%20Secrets%20PAT(Personal%20Access%20Token)%20and%20Target%20Data%20bricks%20Workspace%20URL%20from%20the%20Key%20Vault.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EImporting%20the%20Notebooks%20to%20the%20target%20Databricks%20using%20import%20Rest%20API.(PowerShell%20Task%20with%20Inline%20Script)%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FOL%3E%0A%3CUL%3E%0A%3CLI%3E%3CP%3EWe%20can%20perform%20multiple%20folder%20notebook%20deployments%20using%20this%20script.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3CLI%3E%3CP%3EWe%20are%20creating%20a%20folder(Folder%20in%20Repository%20similar%20to%20Sandbox%2FDev%20environment)%20if%20it%20does%20not%20exist%20in%20the%20target(dev%2FQA%2FUAT%2FProd)%20data%20bricks%20workspace%20and%20then%20importing%20the%20notebooks%20into%20the%20folder.%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CUL%3E%0A%3CLI%3E%3CP%3EYAML%20template%3C%2FP%3E%0A%3C%2FLI%3E%0A%3C%2FUL%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-yaml%22%3E%3CCODE%3Ename%3A%20Release-%24(rev%3Ar)%0A%0Atrigger%3A%20none%0A%0Aresources%3A%0A%20%20pipelines%3A%0A%20%20%20%20-%20pipeline%3A%20notebooks%0A%20%20%20%20%20%20source%3A%20Databricks-CI%0A%20%20%20%20%20%20trigger%3A%0A%20%20%20%20%20%20%20%20branches%3A%0A%20%20%20%20%20%20%20%20%20%20-%20main%0A%0Avariables%3A%0A%20%20-%20name%3A%20azureSubscription%0A%20%20%20%20value%3A%20'%3CSERVICECONNECTIONNAME%3E'%0A%20%20-%20name%3A%20workingDirectory_shared%0A%20%20%20%20value%3A%20'%24(Pipeline.Workspace)%2F%3CPATH%3E%2F'%0A%0Astages%3A%0A-%20stage%3A%20Release%0A%20%20displayName%3A%20Release%20stage%0A%0A%20%20jobs%3A%0A%20%20-%20deployment%3A%20DeployDatabricks%0A%20%20%20%20displayName%3A%20Deploy%20Databricks%20Notebooks%0A%20%20%20%20environment%3A%20DEV%0A%20%20%20%20strategy%3A%0A%20%20%20%20%20%20runOnce%3A%0A%20%20%20%20%20%20%20%20deploy%3A%0A%20%20%20%20%20%20%20%20%20%20steps%3A%0A%20%20%20%20%20%20%20%20%20%20-%20task%3A%20AzureKeyVault%401%0A%20%20%20%20%20%20%20%20%20%20%20%20inputs%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20azureSubscription%3A%20'%24(azureSubscription)'%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20KeyVaultName%3A%20%24(dev_keyvault)%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20SecretsFilter%3A%20'databricks-pat%2Cdatabricks-url'%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20RunAsPreJob%3A%20true%0A%20%20%20%20%20%20%20%20%20%20-%20task%3A%20AzurePowerShell%405%0A%20%20%20%20%20%20%20%20%20%20%20%20inputs%3A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20azureSubscription%3A%20'%24(azureSubscription)'%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20ScriptType%3A%20'InlineScript'%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20Inline%3A%20%7C%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24filenames%20%3D%20get-childitem%20%24(workingDirectory_shared)%20-recurse%20%7C%20where%20%7B%24_.extension%20-eq%20%22.py%22%7D%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24filenames%20%7C%20ForEach-Object%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24NewNotebookName%20%3D%20%24_.Name%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23Get%20Our%20PAT%20Token%20for%20workspace%20from%20the%20Variable%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24Secret%20%3D%20%22Bearer%20%22%2B%20%22%24(databricks-pat)%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23Set%20the%20URI%20for%20API%20Endpoint%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24ImportNoteBookAPI%20%3D%20%22%24(databricks-url)%22%2B%22%2Fapi%2F2.0%2Fworkspace%2Fimport%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24FolderCheckAPI%3D%20%22%24(databricks-url)%22%2B%22%2Fapi%2F2.0%2Fworkspace%2Fget-status%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24FolderCreateAPI%20%3D%20%22%24(databricks-url)%22%2B%22%2Fapi%2F2.0%2Fworkspace%2Fmkdirs%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23Open%20and%20Import%20the%20Notebook%20to%20Workspace%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24BinaryContents%20%3D%20%5BSystem.IO.File%5D%3A%3AReadAllBytes(%24_.FullName)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24EncodedContents%20%3D%20%5BSystem.Convert%5D%3A%3AToBase64String(%24BinaryContents)%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24foldername%20%3D%20%24_.FullName.split(%22%5C%22)%5B%24_.FullName.split(%22%5C%22).length-2%5D%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24folderpath%20%3D%20%22%2F%22%2B%24foldername%20%2B%20%22%2F%22%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24notebookpath%20%3D%20%24folderpath%20%2B%20%22%24NewNotebookName%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23API%20Body%20for%20Importing%20Notebooks%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24ImportNoteBookBody%20%3D%20%40%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20content%20%3D%20%22%24EncodedContents%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20language%20%3D%20%22PYTHON%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20overwrite%20%3D%20%24true%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20format%20%3D%20%22SOURCE%22%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20path%20%3D%20%24notebookpath%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23Convert%20body%20to%20JSON%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24ImportNoteBookBodyText%20%3D%20%24ImportNoteBookBody%20%7C%20ConvertTo-Json%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23API%20Body%20for%20Creating%20Folder%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24CreateFolderBody%20%3D%20%40%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20path%20%3D%20%24folderpath%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23Convert%20body%20to%20JSON%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24CreateFolderBodyText%20%3D%20%24CreateFolderBody%20%7C%20ConvertTo-Json%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23Headers%20for%20all%20the%20API%20calls%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24headers%20%3D%20%40%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Authorization%20%3D%20%24Secret%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20try%7B%0A%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23Check%20if%20the%20folder%20exists%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24CheckPath%20%3D%20%24FolderCheckAPI%20%2B%20%22%3Fpath%3D%22%2B%20%24folderpath%3B%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%24CheckFolder%20%3D%20Invoke-RestMethod%20-Uri%20%24CheckPath%20-Method%20Get%20-Headers%20%24headers%3B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20catch%20%5BSystem.Net.WebException%5D%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7B%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Write-Host%20%22Entering%20the%20catch%20block%20and%20Creating%20Folder%22%3B%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23Creating%20a%20Folder%20if%20it%20does%20not%20exists%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Invoke-RestMethod%20-Uri%20%24FolderCreateAPI%20-Method%20Post%20-Headers%20%24headers%20-Body%20%24CreateFolderBodyText%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%23Importing%20a%20notebook%20to%20the%20Folder%20in%20Target%20DataBricks%20Workspace%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Write-Host%20%22Creating%20Notebook%20%22%20%2B%20%24notebookpath%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20Invoke-RestMethod%20-Uri%20%24ImportNoteBookAPI%20-Method%20Post%20-Headers%20%24headers%20-Body%20%24ImportNoteBookBodyText%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%7D%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%0A%20%20%20%20%20%20%20%20%20%20%20%20%20%20azurePowerShellVersion%3A%20'LatestVersion'%3C%2FPATH%3E%3C%2FSERVICECONNECTIONNAME%3E%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-TEASER%20id%3D%22lingo-teaser-3046952%22%20slang%3D%22en-US%22%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EData%20bricks%20Notebook%20Deployment%20using%20YAML%20code%3C%2FP%3E%0A%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Akshay_Attota_0-1640690706651.png%22%20style%3D%22width%3A%20400px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F336132i95960104C98BE872%2Fimage-size%2Fmedium%3Fv%3Dv2%26amp%3Bpx%3D400%22%20role%3D%22button%22%20title%3D%22Akshay_Attota_0-1640690706651.png%22%20alt%3D%22Akshay_Attota_0-1640690706651.png%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%0A%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-TEASER%3E%3CLINGO-LABS%20id%3D%22lingo-labs-3046952%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EUpdates%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E
Version history
Last update:
‎Feb 02 2022 07:29 AM
Updated by: