How to fetch all the databricks resources from multiple subscriptions including sku from Azure Portal through Power shell

VaishnaviP 21 Reputation points
2022-05-26T18:24:33.407+00:00

I want to get all the azure databricks resources spanning in and around multiple subscriptions through a powershell script

Azure Databricks
Azure Databricks
An Apache Spark-based analytics platform optimized for Azure.
2,514 questions
{count} votes

Accepted answer
  1. Vidhya Sagar Karthikeyan 396 Reputation points
    2022-05-27T09:55:56.797+00:00

    Hi @PrahladVaishnavi-8523

    You can write your own query to fetch the data from all subscription. You can make use of Az PowerShell module to write the query.
    I wrote a script to fetch the workspace details in all the subscription

    To test the script, you need Az PowerShell module. You can install it by running Install-Module Az. Once the module is installed, login to Azure using Login-AzAccount command. After that, you can run the query below

    I also added the filter to subscriptions, if you don't need it just remove the where clause, and it should fetch from all subscriptions

    $subscriptionFilter = ("Sub1", "Sub2")
    $output = New-Object System.Collections.Generic.List[Object]
    $subscription = Get-AzSubscription | Where-Object Name -in $subscriptionFilter 
    $subscription | ForEach-Object { 
        $sName = $_.Name
        Get-AzDatabricksWorkspace -SubscriptionId $_.Id | ForEach-Object {
            $object = [PSCustomObject]@{
                WorkspaceName     = $_.Name
                SubscriptionName  = $sName
                ResourceGroupName = $_.ResourceGroupName
                Location          = $_.Location
                ResourceGroupId   = $_.ManagedResourceGroupId
            }    
            $output.Add($object)
        }
    }
    Write-Output $output | Format-Table
    

    Similarly, you can write additional scripts to fetch the VNET/Subnet, NSG details. Any VM related resources are volatile and will be destroyed after the job completion so it might not be worth to get it.

    Please mark this is answer if it helps


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.