Advent of 2020, Day 28 – Infrastructure as Code and how to automate, script and deploy Azure Databricks with Powershell

Series of Azure Databricks posts:

Yesterday we looked into bringing the capabilities of Databricks closer to your client machine. And making that coding, data wrangling and data science little bit more convenient.

Today we will look into deploying Databricks workspace using Powershell.

You will need nothing CLI, Powershell and all that you already have. So, let’s go into CLI and get the Azure Powershell Module.

In CLI type:

if ($PSVersionTable.PSEdition -eq 'Desktop' -and (Get-Module -Name AzureRM -ListAvailable)) {
    Write-Warning -Message ('Az module not installed. Having both the AzureRM and ' +
      'Az modules installed at the same time is not supported.')
} else {
    Install-Module -Name Az -AllowClobber -Scope CurrentUser
}

After that, you can connect to your Azure subscription:

Connect-AzAccount

You will be prompted to add your credentials. And once you enter them, you will get the results on your Account, tenantID, Environment and Subscription Name.

Once connected, we will look into Databricks module. To list all the modules:

Get-Module -ListAvailable

To explore what is available for Az.Databricks, lets see with the following PS command:

Get-Command -Module Az.Databricks

Now we can create a new Workspace. In this manner, you can also create “semi” automation, but ARM will make this next steps even easier.

New-AzDatabricksWorkspace  `
   -Name databricks-test  `
   -ResourceGroupName testgroup  `
   -Location eastus  `
   -ManagedResourceGroupName databricks-group  `
   -Sku standard

Or we can use ARM (Azure Resource Manager) deployment:

$templateFile = "/users/template.json"
New-AzResourceGroupDeployment `
  -Name blanktemplate `
  -ResourceGroupName myResourceGroup `
  -TemplateFile $templateFile

Or you can go through Deployment process in Azure Portal:

And select a Github template to create a new Azure Databricks workspace:

Or you can go under “Build your own template” and get my Github Repository IaC folder with template.json and Parameters.json files and paste the content in here.

Add First the new resource group:

New-AzResourceGroup -Name RG_123xyz  -Location “westeurope”

And at the end generate the JSON files for your automated deployment. Adding with parameters file:

$templateFile = "/users/tomazkastrun/Documents/GitHub/Azure-Databricks/iac/template.json"
PS /Users/tomazkastrun> $parameterFile=“/users/tomazkastrun/Documents/GitHub/Azure-Databricks/iac/parameters.json”
New-AzResourceGroupDeployment -Name DataBricksDeployment -ResourceGroupName RG_123xyz -TemplateFile $templateFile -TemplateParameterFile $parameterFile

This will take some time:

But you can always check the happening in Azure Portal:

And you can see the deployment status: 1 Deploying. And once you are finished, you will have the PowerShell returning you the status:

These values will be same as the one in parameters.JSON file. In this manner you can automate your deployment and continuous integration (CI) and continuous deployment (CD).

Tomorrow we will dig into Apache Spark.

Complete set of code and the Notebook is available at the Github repository.

Happy Coding and Stay Healthy!

Tagged with: , , , , , , , , , , ,
Posted in Azure Databricks, Uncategorized
7 comments on “Advent of 2020, Day 28 – Infrastructure as Code and how to automate, script and deploy Azure Databricks with Powershell
  1. […] Tomaz Kastrun continues a series on Databricks: […]

    Like

  2. […] by data_admin [This article was first published on R – TomazTsql, and kindly contributed to R-bloggers]. (You can report issue about the content on this page […]

    Like

  3. […] article was first published on R – TomazTsql, and kindly contributed to R-bloggers]. (You can report issue about the content on this page here) […]

    Liked by 1 person

  4. […] Dec 28: Infrastructure as Code and how to automate, script and deploy Azure Databricks with Powershell […]

    Liked by 1 person

  5. […] article was first published on R – TomazTsql, and kindly contributed to R-bloggers]. (You can report issue about the content on this page […]

    Liked by 1 person

  6. […] Dec 28: Infrastructure as Code and how to automate, script and deploy Azure Databricks with Powershell […]

    Liked by 1 person

  7. […] Dec 28: Infrastructure as Code and how to automate, script and deploy Azure Databricks with Powershell […]

    Liked by 1 person

Leave a comment

Follow TomazTsql on WordPress.com
Programs I Use: SQL Search
Programs I Use: R Studio
Programs I Use: Plan Explorer
Rdeči Noski – Charity

Rdeči noski

100% of donations made here go to charity, no deductions, no fees. For CLOWNDOCTORS - encouraging more joy and happiness to children staying in hospitals (http://www.rednoses.eu/red-noses-organisations/slovenia/)

€2.00

Top SQL Server Bloggers 2018
TomazTsql

Tomaz doing BI and DEV with SQL Server and R, Python, Power BI, Azure and beyond

Discover WordPress

A daily selection of the best content published on WordPress, collected for you by humans who love to read.

Revolutions

Tomaz doing BI and DEV with SQL Server and R, Python, Power BI, Azure and beyond

tenbulls.co.uk

tenbulls.co.uk - attaining enlightenment with the Microsoft Data and Cloud Platforms with a sprinkling of Open Source and supporting technologies!

SQL DBA with A Beard

He's a SQL DBA and he has a beard

Reeves Smith's SQL & BI Blog

A blog about SQL Server and the Microsoft Business Intelligence stack with some random Non-Microsoft tools thrown in for good measure.

SQL Server

for Application Developers

Business Analytics 3.0

Data Driven Business Models

SQL Database Engine Blog

Tomaz doing BI and DEV with SQL Server and R, Python, Power BI, Azure and beyond

Search Msdn

Tomaz doing BI and DEV with SQL Server and R, Python, Power BI, Azure and beyond

R-bloggers

Tomaz doing BI and DEV with SQL Server and R, Python, Power BI, Azure and beyond

R-bloggers

R news and tutorials contributed by hundreds of R bloggers

Data Until I Die!

Data for Life :)

Paul Turley's SQL Server BI Blog

sharing my experiences with the Microsoft data platform, SQL Server BI, Data Modeling, SSAS Design, Power Pivot, Power BI, SSRS Advanced Design, Power BI, Dashboards & Visualization since 2009

Grant Fritchey

Intimidating Databases and Code

Madhivanan's SQL blog

A modern business theme

Alessandro Alpi's Blog

DevOps could be the disease you die with, but don’t die of.

Paul te Braak

Business Intelligence Blog

Sql Insane Asylum (A Blog by Pat Wright)

Information about SQL (PostgreSQL & SQL Server) from the Asylum.

Gareth's Blog

A blog about Life, SQL & Everything ...