![]() |
VOOZH | about |
The CData ADO.NET Provider for Azure is a standard ADO.NET Provider that make it easy to accomplish data cleansing, normalization, backup, and other integration tasks by enabling real-time and bidirectional access to Azure Table.
The ADO.NET Provider provides a SQL interface for Azure Table; this tutorial shows how to use the Provider to create, retrieve, update, and delete Azure Table data.
Once you have acquired the necessary connection properties, accessing Azure Table data in PowerShell can be enabled in three steps.
Specify your AccessKey and your Account to connect. Set the Account property to the Storage Account Name and set AccessKey to one of the Access Keys. Either the Primary or Secondary Access Keys can be used. To obtain these values, navigate to the Storage Accounts blade in the Azure portal. You can obtain the access key by selecting your account and clicking Access Keys in the Settings section.
Load the provider's assembly:
[Reflection.Assembly]::LoadFile("C:\Program Files\CData\CData ADO.NET Provider for Azure\lib\System.Data.CData.AzureTables.dll")
Connect to Azure Table:
$conn= New-Object System.Data.CData.AzureTables.AzureTablesConnection("AccessKey=myAccessKey;Account=myAccountName;")
$conn.Open()
Instantiate the AzureTablesDataAdapter, execute an SQL query, and output the results:
$sql="SELECT Name, Price from NorthwindProducts"
$da= New-Object System.Data.CData.AzureTables.AzureTablesDataAdapter($sql, $conn)
$dt= New-Object System.Data.DataTable
$da.Fill($dt)
$dt.Rows | foreach {
Write-Host $_.name $_.price
}
$cmd = New-Object System.Data.CData.AzureTables.AzureTablesCommand("UPDATE NorthwindProducts SET ShipCity='New York' WHERE Id = @myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.AzureTables.AzureTablesParameter("@myId","10456255-0015501366")))
$cmd.ExecuteNonQuery()
$cmd = New-Object System.Data.CData.AzureTables.AzureTablesCommand("INSERT INTO NorthwindProducts (ShipCity) VALUES (@myShipCity)", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.AzureTables.AzureTablesParameter("@myShipCity","New York")))
$cmd.ExecuteNonQuery()
$cmd = New-Object System.Data.CData.AzureTables.AzureTablesCommand("DELETE FROM NorthwindProducts WHERE Id=@myId", $conn)
$cmd.Parameters.Add((New-Object System.Data.CData.AzureTables.AzureTablesParameter("@myId","001d000000YBRseAAH")))
$cmd.ExecuteNonQuery()
CodeProject
Download a free trial of the Azure Data Provider to get started:
Download NowLearn more:
👁 Azure Storage IconRapidly create and deploy powerful .NET applications that integrate with live Azure Table Storage data!