![]() |
VOOZH | about |
The CData Cmdlets for Azure DevOps 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 DevOps.
The Cmdlets are not only a PowerShell interface to Azure DevOps, but also an SQL interface; this tutorial shows how to use both to retrieve Azure DevOps data. We also show examples of the ADO.NET equivalent, which is possible with the CData ADO.NET Provider for Azure DevOps. To access Azure DevOps data from other .NET applications, like LINQPad, use the CData ADO.NET Provider for Azure DevOps.
Once you have acquired the necessary connection properties, accessing Azure DevOps data in PowerShell can be enabled in three steps.
You can connect to your Azure DevOps account by providing the Organization and PersonalAccessToken.
To generate one, log in to your Azure DevOps Organization account and navigate to Profile -> Personal Access Tokens -> New Token. The generated token will be displayed.
If you wish to authenticate to Azure DevOps using OAuth refer to the online Help documentation for an authentication guide.
Install the module:
Install-Module AzureDevOpsCmdlets
Connect:
$azuredevops = Connect-AzureDevOps -AuthScheme "$AuthScheme" -Organization "$Organization" -ProjectId "$ProjectId" -PersonalAccessToken "$PersonalAccessToken" -InitiateOAuth "$InitiateOAuth"
Search for and retrieve data:
$reason = "Manual" $builds = Select-AzureDevOps -Connection $azuredevops -Table "Builds" -Where "Reason = `'$Reason`'" $builds
You can also use the Invoke-AzureDevOps cmdlet to execute SQL commands:
$builds = Invoke-AzureDevOps -Connection $azuredevops -Query 'SELECT * FROM Builds WHERE Reason = @Reason' -Params @{'@Reason'='Manual'}
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Azure DevOps\lib\System.Data.CData.AzureDevOps.dll")
Connect to Azure DevOps:
$conn= New-Object System.Data.CData.AzureDevOps.AzureDevOpsConnection("AuthScheme=Basic;Organization=MyAzureDevOpsOrganization;ProjectId=MyProjectId;PersonalAccessToken=MyPAT;InitiateOAuth=GETANDREFRESH;")
$conn.Open()
Instantiate the AzureDevOpsDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Id, BuildNumber from Builds"
$da= New-Object System.Data.CData.AzureDevOps.AzureDevOpsDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.id $_.buildnumber
}
Download a free trial of the Azure DevOps Data Provider to get started:
Download NowLearn more:
👁 Azure DevOps IconRapidly create and deploy powerful .NET applications that integrate with Azure DevOps.