Automate Azure Management Integration Tasks from PowerShell

Ready to get started?

Download for a free trial:

Download Now

Learn more:

Azure Management ADO.NET Provider

Rapidly create and deploy powerful .NET applications that integrate with live Azure Management data!

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

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

Cmdlets or ADO.NET?

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

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

Azure Data Management uses the OAuth 2 authentication standard. See the Getting Started section of the CData driver documentation for a guide.


  1. Install the module:

    Install-Module AzureDataManagementCmdlets
  2. Connect:

    $azuredatamanagement = Connect-AzureDataManagement
  3. Search for and retrieve data:

    $subscriptionid = "fadc4-4cdaf-fadc4-4cdaf" $subscriptions = Select-AzureDataManagement -Connection $azuredatamanagement -Table "Subscriptions" -Where "SubscriptionId = `'$SubscriptionId`'" $subscriptions

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

    $subscriptions = Invoke-AzureDataManagement -Connection $azuredatamanagement -Query 'SELECT * FROM Subscriptions WHERE SubscriptionId = @SubscriptionId' -Params @{'@SubscriptionId'='fadc4-4cdaf-fadc4-4cdaf'}


  1. Load the provider's assembly:

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

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

    $sql="SELECT DisplayName, AuthorizationSource from Subscriptions" $da= New-Object System.Data.CData.AzureDataManagement.AzureDataManagementDataAdapter($sql, $conn) $dt= New-Object System.Data.DataTable $da.Fill($dt) $dt.Rows | foreach { Write-Host $_.displayname $_.authorizationsource }

Update Azure Management Data


Update-AzureDataManagement -Connection $AzureDataManagement -Columns @('DisplayName','AuthorizationSource') -Values @('MyDisplayName', 'MyAuthorizationSource') -Table Subscriptions -Id "MyId"


$cmd = New-Object System.Data.CData.AzureDataManagement.AzureDataManagementCommand("UPDATE Subscriptions SET SubscriptionId='fadc4-4cdaf-fadc4-4cdaf' WHERE Id = @myId", $conn) $cmd.Parameters.Add(new System.Data.CData.AzureDataManagement.AzureDataManagementParameter("@myId","10456255-0015501366")) $cmd.ExecuteNonQuery()

Insert Azure Management Data


Add-AzureDataManagement -Connection $AzureDataManagement -Table Subscriptions -Columns @("DisplayName", "AuthorizationSource") -Values @("MyDisplayName", "MyAuthorizationSource")


$cmd = New-Object System.Data.CData.AzureDataManagement.AzureDataManagementCommand("INSERT INTO Subscriptions (SubscriptionId) VALUES (@mySubscriptionId)", $conn) $cmd.Parameters.Add(new System.Data.CData.AzureDataManagement.AzureDataManagementParameter("@mySubscriptionId","fadc4-4cdaf-fadc4-4cdaf")) $cmd.ExecuteNonQuery()

Delete Azure Management Data


Remove-AzureDataManagement -Connection $AzureDataManagement -Table "Subscriptions" -Id "MyId"


$cmd = New-Object System.Data.CData.AzureDataManagement.AzureDataManagementCommand("DELETE FROM Subscriptions WHERE Id=@myId", $conn) $cmd.Parameters.Add(new System.Data.CData.AzureDataManagement.AzureDataManagementParameter("@myId","001d000000YBRseAAH")) $cmd.ExecuteNonQuery()