Automate Azure Data Catalog Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Azure Data Catalog ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with Azure Data Catalog.



Are you looking for a quick and easy way to access Azure Data Catalog data from PowerShell? We show how to use the Cmdlets for Azure Data Catalog and the CData ADO.NET Provider for Azure Data Catalog to connect to Azure Data Catalog data and synchronize, automate, download, and more.

The CData Cmdlets for Azure Data Catalog are standard PowerShell cmdlets that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time access to Azure Data Catalog.

Cmdlets or ADO.NET?

The cmdlets are not only a PowerShell interface to the Azure Data Catalog API, but also an SQL interface; this tutorial shows how to use both to retrieve Azure Data Catalog data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Azure Data Catalog. To access Azure Data Catalog data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Azure Data Catalog.

After obtaining the needed connection properties, accessing Azure Data Catalog data in PowerShell consists of three basic steps.

You can optionally set the following to read the different catalog data returned from Azure Data Catalog.

    CatalogName: Set this to the CatalogName associated with your Azure Data Catalog. To get your Catalog name, navigate to your Azure Portal home page > Data Catalog > Catalog Name

Connect Using OAuth Authentication

You must use OAuth to authenticate with Azure Data Catalog. OAuth requires the authenticating user to interact with Azure Data Catalog using the browser. For more information, refer to the OAuth section in the help documentation.

PowerShell

  1. Install the module:

    Install-Module AzureDataCatalogCmdlets
  2. Connect:

    $azuredatacatalog = Connect-AzureDataCatalog
  3. Search for and retrieve data:

    $name = "FactProductInventory" $tables = Select-AzureDataCatalog -Connection $azuredatacatalog -Table "Tables" -Where "Name = `'$Name`'" $tables

    You can also use the Invoke-AzureDataCatalog cmdlet to execute SQL commands:

    $tables = Invoke-AzureDataCatalog -Connection $azuredatacatalog -Query 'SELECT * FROM Tables WHERE Name = @Name' -Params @{'@Name'='FactProductInventory'}

ADO.NET

  1. Load the provider's assembly:

    [Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Azure Data Catalog\lib\System.Data.CData.AzureDataCatalog.dll")
  2. Connect to Azure Data Catalog:

    $conn= New-Object System.Data.CData.AzureDataCatalog.AzureDataCatalogConnection("InitiateOAuth=GETANDREFRESH") $conn.Open()
  3. Instantiate the AzureDataCatalogDataAdapter, execute an SQL query, and output the results:

    $sql="SELECT DslAddressDatabase, Type from Tables" $da= New-Object System.Data.CData.AzureDataCatalog.AzureDataCatalogDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.dsladdressdatabase $_.type }